gqlite 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +20 -0
  3. data/ext/gqlitedb/Cargo.toml +77 -0
  4. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
  5. data/ext/gqlitedb/gqlite_bench_data/README.MD +6 -0
  6. data/ext/gqlitedb/gqlite_bench_data/scripts/generate_smaller_pokec.rb +85 -0
  7. data/ext/gqlitedb/gqlite_bench_data/scripts/to_efficient_pokec.rb +34 -0
  8. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/release.toml +2 -2
  9. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/arithmetic.rs +1 -0
  10. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/stats.rs +27 -49
  11. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators.rs +7 -7
  12. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/capi.rs +34 -10
  13. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/expression_analyser.rs +10 -4
  14. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/variables_manager.rs +36 -39
  15. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler.rs +46 -41
  16. data/ext/gqlitedb/src/connection.rs +300 -0
  17. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/error.rs +113 -50
  18. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/containers.rs +21 -26
  19. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/edge.rs +3 -3
  20. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/math.rs +3 -3
  21. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/node.rs +2 -2
  22. data/ext/gqlitedb/src/functions/path.rs +75 -0
  23. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +3 -3
  24. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/string.rs +1 -1
  25. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +7 -7
  26. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +29 -31
  27. data/ext/gqlitedb/src/graph.rs +11 -0
  28. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +178 -224
  29. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +8 -2
  30. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +9 -5
  31. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/ast.rs +54 -76
  32. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/gql.pest +9 -4
  33. data/ext/{gqliterb/vendor/gqlitedb/src/parser/parser.rs → gqlitedb/src/parser/parser_impl.rs} +86 -34
  34. data/ext/gqlitedb/src/parser.rs +4 -0
  35. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/prelude.rs +3 -2
  36. data/ext/gqlitedb/src/query_result.rs +88 -0
  37. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/redb.rs +260 -170
  38. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/sqlite.rs +157 -142
  39. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store.rs +30 -23
  40. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/evaluators.rs +41 -85
  41. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/redb.rs +12 -5
  42. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/sqlite.rs +12 -5
  43. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store.rs +106 -114
  44. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/ast.rs +29 -29
  45. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/programs.rs +4 -4
  46. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/compare.rs +13 -20
  47. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/contains.rs +2 -2
  48. data/ext/gqlitedb/src/value.rs +225 -0
  49. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value_table.rs +22 -18
  50. data/ext/gqliterb/Cargo.toml +12 -34
  51. data/ext/gqliterb/src/lib.rs +67 -39
  52. data/ext/graphcore/Cargo.toml +19 -0
  53. data/ext/graphcore/README.MD +4 -0
  54. data/ext/graphcore/release.toml +1 -0
  55. data/ext/graphcore/src/error.rs +28 -0
  56. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/graph.rs +146 -35
  57. data/ext/graphcore/src/lib.rs +16 -0
  58. data/ext/graphcore/src/prelude.rs +4 -0
  59. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/serialize_with.rs +2 -2
  60. data/ext/graphcore/src/table.rs +272 -0
  61. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/value/value_map.rs +44 -49
  62. data/ext/graphcore/src/value.rs +413 -0
  63. metadata +94 -83
  64. data/ext/gqliterb/.cargo/config.toml +0 -2
  65. data/ext/gqliterb/Cargo.lock +0 -1109
  66. data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +0 -2060
  67. data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +0 -132
  68. data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +0 -208
  69. data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +0 -48
  70. data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +0 -4
  71. data/ext/gqliterb/vendor/gqlitedb/src/value.rs +0 -559
  72. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/askama.toml +0 -0
  73. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/mod.rs +0 -0
  74. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_divan.rs +0 -0
  75. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_iai.rs +0 -0
  76. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/containers.rs +0 -0
  77. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/count.rs +0 -0
  78. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/consts.rs +0 -0
  79. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/mod.rs +0 -0
  80. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/pgql.rs +0 -0
  81. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/compiler.rs +0 -0
  82. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/parser.rs +0 -0
  83. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates.rs +0 -0
  84. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests.rs +0 -0
  85. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/utils.rs +0 -0
  86. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/call_stats.sql +0 -0
  87. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_count_for_node.sql +0 -0
  88. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_create.sql +0 -0
  89. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete.sql +0 -0
  90. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete_by_nodes.sql +0 -0
  91. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_select.sql +0 -0
  92. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_update.sql +0 -0
  93. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_create.sql +0 -0
  94. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_delete.sql +0 -0
  95. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_create_table.sql +0 -0
  96. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_get.sql +0 -0
  97. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_set.sql +0 -0
  98. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_create.sql +0 -0
  99. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_delete.sql +0 -0
  100. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_select.sql +0 -0
  101. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_update.sql +0 -0
  102. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/table_exists.sql +0 -0
  103. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_from_1_01.sql +0 -0
  104. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_graph_from_1_01.sql +0 -0
@@ -112,30 +112,35 @@ pub(crate) trait Store
112
112
  fn create_graph(
113
113
  &self,
114
114
  transaction: &mut Self::TransactionBox,
115
- name: &String,
116
- _ignore_if_exists: bool,
115
+ name: impl AsRef<str>,
116
+ ignore_if_exists: bool,
117
117
  ) -> Result<()>;
118
118
  /// Delete a graph
119
- fn delete_graph(&self, transaction: &mut Self::TransactionBox, name: &String) -> Result<()>;
119
+ fn drop_graph(
120
+ &self,
121
+ transaction: &mut Self::TransactionBox,
122
+ name: impl AsRef<str>,
123
+ if_exists: bool,
124
+ ) -> Result<()>;
120
125
  /// Create nodes and add them to a graph
121
- fn create_nodes<'a, T: Iterator<Item = &'a crate::graph::Node>>(
126
+ fn create_nodes<'a, T: IntoIterator<Item = &'a crate::graph::Node>>(
122
127
  &self,
123
128
  transaction: &mut Self::TransactionBox,
124
- graph_name: &String,
129
+ graph_name: impl AsRef<str>,
125
130
  nodes_iter: T,
126
131
  ) -> Result<()>;
127
132
  /// Create nodes and add them to a graph
128
133
  fn update_node(
129
134
  &self,
130
135
  transaction: &mut Self::TransactionBox,
131
- graph_name: &String,
136
+ graph_name: impl AsRef<str>,
132
137
  node: &graph::Node,
133
138
  ) -> Result<()>;
134
139
  /// Delete nodes according to a given query
135
140
  fn delete_nodes(
136
141
  &self,
137
142
  transaction: &mut Self::TransactionBox,
138
- graph_name: &String,
143
+ graph_name: impl AsRef<str>,
139
144
  query: SelectNodeQuery,
140
145
  detach: bool,
141
146
  ) -> Result<()>;
@@ -143,27 +148,27 @@ pub(crate) trait Store
143
148
  fn select_nodes(
144
149
  &self,
145
150
  transaction: &mut Self::TransactionBox,
146
- graph_name: &String,
151
+ graph_name: impl AsRef<str>,
147
152
  query: SelectNodeQuery,
148
153
  ) -> Result<Vec<crate::graph::Node>>;
149
154
  /// Add edge
150
- fn create_edges<'a, T: Iterator<Item = &'a crate::graph::Edge>>(
155
+ fn create_edges<'a, T: IntoIterator<Item = &'a crate::graph::SinglePath>>(
151
156
  &self,
152
157
  transaction: &mut Self::TransactionBox,
153
- graph_name: &String,
158
+ graph_name: impl AsRef<str>,
154
159
  edges_iter: T,
155
160
  ) -> Result<()>;
156
161
  fn update_edge(
157
162
  &self,
158
163
  transaction: &mut Self::TransactionBox,
159
- graph_name: &String,
164
+ graph_name: impl AsRef<str>,
160
165
  edge: &graph::Edge,
161
166
  ) -> Result<()>;
162
167
  /// Delete nodes according to a given query
163
168
  fn delete_edges(
164
169
  &self,
165
170
  transaction: &mut Self::TransactionBox,
166
- graph_name: &String,
171
+ graph_name: impl AsRef<str>,
167
172
  query: SelectEdgeQuery,
168
173
  directivity: graph::EdgeDirectivity,
169
174
  ) -> Result<()>;
@@ -171,7 +176,7 @@ pub(crate) trait Store
171
176
  fn select_edges(
172
177
  &self,
173
178
  transaction: &mut Self::TransactionBox,
174
- graph_name: &String,
179
+ graph_name: impl AsRef<str>,
175
180
  query: SelectEdgeQuery,
176
181
  directivity: graph::EdgeDirectivity,
177
182
  ) -> Result<Vec<EdgeResult>>;
@@ -188,7 +193,7 @@ pub(crate) trait Store
188
193
 
189
194
  pub(crate) struct EdgeResult
190
195
  {
191
- pub(crate) edge: graph::Edge,
196
+ pub(crate) path: graph::SinglePath,
192
197
  pub(crate) reversed: bool,
193
198
  }
194
199
 
@@ -250,6 +255,7 @@ impl SelectNodeQuery
250
255
  select_all: false,
251
256
  }
252
257
  }
258
+ #[allow(dead_code)]
253
259
  pub(crate) fn select_labels(labels: impl Into<Vec<String>>) -> Self
254
260
  {
255
261
  Self {
@@ -279,14 +285,14 @@ impl SelectNodeQuery
279
285
  }
280
286
  if let Some(keys) = &self.keys
281
287
  {
282
- if !keys.iter().any(|x| node.key == *x)
288
+ if !keys.iter().any(|x| node.key() == *x)
283
289
  {
284
290
  return false;
285
291
  }
286
292
  }
287
293
  if let Some(labels) = &self.labels
288
294
  {
289
- if !labels.iter().all(|x| node.labels.contains(x))
295
+ if !labels.iter().all(|x| node.labels().contains(x))
290
296
  {
291
297
  return false;
292
298
  }
@@ -295,12 +301,12 @@ impl SelectNodeQuery
295
301
  {
296
302
  if !properties
297
303
  .iter()
298
- .all(|(k, v)| node.properties.get(k) == Some(v))
304
+ .all(|(k, v)| node.properties().get(k) == Some(v))
299
305
  {
300
306
  return false;
301
307
  }
302
308
  }
303
- return true;
309
+ true
304
310
  }
305
311
  }
306
312
 
@@ -323,6 +329,7 @@ pub(crate) struct SelectEdgeQuery
323
329
 
324
330
  impl SelectEdgeQuery
325
331
  {
332
+ #[allow(dead_code)]
326
333
  pub(crate) fn is_select_only_keys(&self) -> bool
327
334
  {
328
335
  self.keys.is_some()
@@ -402,18 +409,18 @@ impl SelectEdgeQuery
402
409
  destination: destination_query,
403
410
  }
404
411
  }
405
- pub(crate) fn is_match(&self, edge: &graph::Edge) -> bool
412
+ pub(crate) fn is_match(&self, edge: &graph::Path) -> bool
406
413
  {
407
414
  if let Some(keys) = &self.keys
408
415
  {
409
- if !keys.iter().any(|x| edge.key == *x)
416
+ if !keys.iter().any(|x| edge.key() == *x)
410
417
  {
411
418
  return false;
412
419
  }
413
420
  }
414
421
  if let Some(labels) = &self.labels
415
422
  {
416
- if !labels.iter().all(|x| edge.labels.contains(x))
423
+ if !labels.iter().all(|x| edge.labels().contains(x))
417
424
  {
418
425
  return false;
419
426
  }
@@ -422,11 +429,11 @@ impl SelectEdgeQuery
422
429
  {
423
430
  if !properties
424
431
  .iter()
425
- .all(|(k, v)| edge.properties.get(k) == Some(v))
432
+ .all(|(k, v)| edge.properties().get(k) == Some(v))
426
433
  {
427
434
  return false;
428
435
  }
429
436
  }
430
- return self.source.is_match(&edge.source) && self.destination.is_match(&edge.destination);
437
+ self.source.is_match(edge.source()) && self.destination.is_match(edge.destination())
431
438
  }
432
439
  }
@@ -9,7 +9,7 @@ use crate::{
9
9
  fn test_evaluate_simple_create_node()
10
10
  {
11
11
  let temp_file = crate::tests::create_tmp_file();
12
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
12
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
13
13
 
14
14
  eval_program(&store, &programs::simple_create(), &Default::default()).unwrap();
15
15
  check_stats(&store, None, 1, 0, 0, 0);
@@ -19,22 +19,19 @@ fn test_evaluate_simple_create_node()
19
19
  fn test_evaluate_create_named_node()
20
20
  {
21
21
  let temp_file = crate::tests::create_tmp_file();
22
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
22
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
23
23
 
24
24
  let value = eval_program(&store, &programs::create_named_node(), &Default::default()).unwrap();
25
25
  check_stats(&store, None, 1, 0, 0, 1);
26
26
 
27
- assert_eq!(
28
- value,
29
- value::array![value::array!["p"], value::array!["foo"]]
30
- );
27
+ assert_eq!(value, graphcore::table![("p"), [["foo"]]].into());
31
28
  }
32
29
 
33
30
  #[test]
34
31
  fn test_evaluate_create_named_node_double_return()
35
32
  {
36
33
  let temp_file = crate::tests::create_tmp_file();
37
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
34
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
38
35
 
39
36
  let value = eval_program(
40
37
  &store,
@@ -44,47 +41,40 @@ fn test_evaluate_create_named_node_double_return()
44
41
  .unwrap();
45
42
  check_stats(&store, None, 1, 0, 0, 2);
46
43
 
47
- assert_eq!(
48
- value,
49
- value::array![value::array!["id", "p"], value::array![12, "foo"]]
50
- );
44
+ assert_eq!(value, graphcore::table![("id", "p"), [[12, "foo"]]].into());
51
45
  }
52
46
 
53
47
  #[test]
54
48
  fn test_evaluate_double_with_return()
55
49
  {
56
50
  let temp_file = crate::tests::create_tmp_file();
57
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
51
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
58
52
 
59
53
  let value = eval_program(&store, &programs::double_with_return(), &Default::default()).unwrap();
60
54
  check_stats(&store, None, 0, 0, 0, 0);
61
55
 
62
- assert_eq!(value, value::array![value::array!["a"], value::array![1]]);
56
+ assert_eq!(value, crate::table![("a"), [[1,]]].into());
63
57
  }
64
58
 
65
59
  #[test]
66
60
  fn test_evaluate_unwind()
67
61
  {
68
62
  let temp_file = crate::tests::create_tmp_file();
69
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
63
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
70
64
 
71
65
  let value = eval_program(&store, &programs::unwind(), &Default::default()).unwrap();
72
66
  check_stats(&store, None, 0, 0, 0, 0);
73
67
 
74
- assert_eq!(value, value::array![value::array!["i"], value::array![0]]);
68
+ assert_eq!(value, crate::table![("i"), [[0,]]].into());
75
69
  }
76
70
 
77
71
  #[test]
78
72
  fn test_evaluate_match_loop()
79
73
  {
80
74
  let temp_file = crate::tests::create_tmp_file();
81
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
75
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
82
76
 
83
- let node = graph::Node {
84
- key: graph::Key { uuid: 1 },
85
- labels: vec![],
86
- properties: Default::default(),
87
- };
77
+ let node = graph::Node::new(graph::Key::new(1), vec![], Default::default());
88
78
  let mut tx = store.begin_write().unwrap();
89
79
  store
90
80
  .create_nodes(&mut tx, &"default".to_string(), vec![&node].into_iter())
@@ -93,13 +83,13 @@ fn test_evaluate_match_loop()
93
83
  .create_edges(
94
84
  &mut tx,
95
85
  &"default".to_string(),
96
- vec![&graph::Edge {
97
- key: graph::Key { uuid: 2 },
98
- source: node.clone(),
99
- destination: node.clone(),
100
- labels: vec![],
101
- properties: Default::default(),
102
- }]
86
+ vec![&graph::Path::new(
87
+ graph::Key::new(2),
88
+ node.clone(),
89
+ vec![],
90
+ Default::default(),
91
+ node.clone(),
92
+ )]
103
93
  .into_iter(),
104
94
  )
105
95
  .unwrap();
@@ -108,32 +98,26 @@ fn test_evaluate_match_loop()
108
98
  let value = eval_program(&store, &programs::match_loop(), &Default::default()).unwrap();
109
99
  check_stats(&store, None, 1, 1, 0, 0);
110
100
 
111
- assert_eq!(
112
- value,
113
- value::array![value::array!["n"], value::array![node]]
114
- );
101
+ assert_eq!(value, crate::table![("n"), [[node]]].into());
115
102
  }
116
103
 
117
104
  #[test]
118
105
  fn test_evaluate_optional_match()
119
106
  {
120
107
  let temp_file = crate::tests::create_tmp_file();
121
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
108
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
122
109
 
123
110
  let value = eval_program(&store, &programs::optional_match(), &Default::default()).unwrap();
124
111
  check_stats(&store, None, 0, 0, 0, 0);
125
112
 
126
- assert_eq!(
127
- value,
128
- value::array![value::array!["a"], value::array![value::Value::Null]]
129
- );
113
+ assert_eq!(value, crate::table![("a"), [[value::Value::Null]]].into());
130
114
  }
131
115
 
132
116
  #[test]
133
117
  fn test_evaluate_match_count()
134
118
  {
135
119
  let temp_file = crate::tests::create_tmp_file();
136
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
120
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
137
121
  let function_manager = functions::Manager::new();
138
122
  let program = programs::match_count(&function_manager);
139
123
 
@@ -141,17 +125,10 @@ fn test_evaluate_match_count()
141
125
  let value = eval_program(&store, &program, &Default::default()).unwrap();
142
126
  check_stats(&store, None, 0, 0, 0, 0);
143
127
 
144
- assert_eq!(
145
- value,
146
- value::array![value::array!["count(*)"], value::array![0]]
147
- );
128
+ assert_eq!(value, crate::table![("count(*)"), [[0]]].into());
148
129
 
149
130
  // Count 1
150
- let node = graph::Node {
151
- key: graph::Key { uuid: 1 },
152
- labels: vec![],
153
- properties: Default::default(),
154
- };
131
+ let node = graph::Node::new(graph::Key::new(1), vec![], Default::default());
155
132
  let mut tx = store.begin_write().unwrap();
156
133
  store
157
134
  .create_nodes(&mut tx, &"default".to_string(), vec![&node].into_iter())
@@ -162,36 +139,29 @@ fn test_evaluate_match_count()
162
139
  let value = eval_program(&store, &program, &Default::default()).unwrap();
163
140
  check_stats(&store, None, 1, 0, 0, 0);
164
141
 
165
- assert_eq!(
166
- value,
167
- value::array![value::array!["count(*)"], value::array![1]]
168
- );
142
+ assert_eq!(value, crate::table![("count(*)"), [[1]]].into());
169
143
  }
170
144
 
171
145
  #[test]
172
146
  fn test_evaluate_aggregation()
173
147
  {
174
148
  let temp_file = crate::tests::create_tmp_file();
175
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
149
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
176
150
  let function_manager = functions::Manager::new();
177
151
  let program = programs::aggregation(&function_manager);
178
152
 
179
153
  let nodes = vec![
180
- graph::Node {
181
- key: graph::Key { uuid: 1 },
182
- labels: vec![],
183
- properties: value::map!("name" => "a", "num" => 33),
184
- },
185
- graph::Node {
186
- key: graph::Key { uuid: 2 },
187
- labels: vec![],
188
- properties: value::map!("name" => "a"),
189
- },
190
- graph::Node {
191
- key: graph::Key { uuid: 3 },
192
- labels: vec![],
193
- properties: value::map!("name" => "b", "num" => 42),
194
- },
154
+ graph::Node::new(
155
+ graph::Key::new(1),
156
+ vec![],
157
+ value::value_map!("name" => "a", "num" => 33),
158
+ ),
159
+ graph::Node::new(graph::Key::new(2), vec![], value::value_map!("name" => "a")),
160
+ graph::Node::new(
161
+ graph::Key::new(3),
162
+ vec![],
163
+ value::value_map!("name" => "b", "num" => 42),
164
+ ),
195
165
  ];
196
166
  let mut tx = store.begin_write().unwrap();
197
167
  store
@@ -204,24 +174,10 @@ fn test_evaluate_aggregation()
204
174
  check_stats(&store, None, 3, 0, 0, 5);
205
175
 
206
176
  assert!(
207
- value
208
- == value::array![
209
- value::array!["n.name", "count(n.num)"],
210
- value::array!["a", 1],
211
- value::array!["b", 1]
212
- ]
213
- || value
214
- == value::array![
215
- value::array!["n.name", "count(n.num)"],
216
- value::array!["b", 1],
217
- value::array!["a", 1]
218
- ],
219
- "left ({}) == right ({} in any order) failed",
177
+ value == crate::table![("n.name", "count(n.num)"), [["a", 1], ["b", 1]]].into()
178
+ || value == crate::table![("n.name", "count(n.num)"), [["b", 1], ["a", 1]]].into(),
179
+ "left ({}) == right ({:?} in any order) failed",
220
180
  value,
221
- value::array![
222
- value::array!["n.name", "count(n.num)"],
223
- value::array!["a", 1],
224
- value::array!["b", 1]
225
- ],
181
+ crate::table![("n.name", "count(n.num)"), [["a", 1], ["b", 1]]],
226
182
  );
227
183
  }
@@ -1,8 +1,15 @@
1
+ #[test]
2
+ fn test_in_memory()
3
+ {
4
+ let store = crate::store::redb::Store::in_memory().unwrap();
5
+ super::test_select_nodes(store);
6
+ }
7
+
1
8
  #[test]
2
9
  fn test_graphs()
3
10
  {
4
11
  let temp_file = crate::tests::create_tmp_file();
5
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
12
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
6
13
  super::test_graphs(store);
7
14
  }
8
15
 
@@ -10,7 +17,7 @@ fn test_graphs()
10
17
  fn test_select_nodes()
11
18
  {
12
19
  let temp_file = crate::tests::create_tmp_file();
13
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
20
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
14
21
  super::test_select_nodes(store);
15
22
  }
16
23
 
@@ -18,7 +25,7 @@ fn test_select_nodes()
18
25
  fn test_update_nodes()
19
26
  {
20
27
  let temp_file = crate::tests::create_tmp_file();
21
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
28
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
22
29
  super::test_update_nodes(store);
23
30
  }
24
31
 
@@ -26,7 +33,7 @@ fn test_update_nodes()
26
33
  fn test_select_edges()
27
34
  {
28
35
  let temp_file = crate::tests::create_tmp_file();
29
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
36
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
30
37
  super::test_select_edges(store);
31
38
  }
32
39
 
@@ -34,6 +41,6 @@ fn test_select_edges()
34
41
  fn test_update_edges()
35
42
  {
36
43
  let temp_file = crate::tests::create_tmp_file();
37
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
44
+ let store = crate::store::redb::Store::open(temp_file.path()).unwrap();
38
45
  super::test_update_edges(store);
39
46
  }
@@ -1,8 +1,15 @@
1
+ #[test]
2
+ fn test_in_memory()
3
+ {
4
+ let store = crate::store::sqlite::Store::in_memory().unwrap();
5
+ super::test_select_nodes(store);
6
+ }
7
+
1
8
  #[test]
2
9
  fn test_graphs()
3
10
  {
4
11
  let temp_file = crate::tests::create_tmp_file();
5
- let store = crate::store::redb::Store::new(temp_file.path()).unwrap();
12
+ let store = crate::store::sqlite::Store::open(temp_file.path()).unwrap();
6
13
  super::test_graphs(store);
7
14
  }
8
15
 
@@ -10,7 +17,7 @@ fn test_graphs()
10
17
  fn test_select_nodes()
11
18
  {
12
19
  let temp_file = crate::tests::create_tmp_file();
13
- let store = crate::store::sqlite::Store::new(temp_file.path()).unwrap();
20
+ let store = crate::store::sqlite::Store::open(temp_file.path()).unwrap();
14
21
  super::test_select_nodes(store);
15
22
  }
16
23
 
@@ -18,7 +25,7 @@ fn test_select_nodes()
18
25
  fn test_update_nodes()
19
26
  {
20
27
  let temp_file = crate::tests::create_tmp_file();
21
- let store = crate::store::sqlite::Store::new(temp_file.path()).unwrap();
28
+ let store = crate::store::sqlite::Store::open(temp_file.path()).unwrap();
22
29
  super::test_update_nodes(store);
23
30
  }
24
31
 
@@ -26,7 +33,7 @@ fn test_update_nodes()
26
33
  fn test_select_edges()
27
34
  {
28
35
  let temp_file = crate::tests::create_tmp_file();
29
- let store = crate::store::sqlite::Store::new(temp_file.path()).unwrap();
36
+ let store = crate::store::sqlite::Store::open(temp_file.path()).unwrap();
30
37
  super::test_select_edges(store);
31
38
  }
32
39
 
@@ -34,6 +41,6 @@ fn test_select_edges()
34
41
  fn test_update_edges()
35
42
  {
36
43
  let temp_file = crate::tests::create_tmp_file();
37
- let store = crate::store::sqlite::Store::new(temp_file.path()).unwrap();
44
+ let store = crate::store::sqlite::Store::open(temp_file.path()).unwrap();
38
45
  super::test_update_edges(store);
39
46
  }