gqlite 1.2.3 → 1.3.1
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.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +21 -0
- data/ext/gqlitedb/Cargo.toml +77 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/arithmetic.rs +1 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/stats.rs +27 -49
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators.rs +7 -7
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/capi.rs +10 -9
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/expression_analyser.rs +6 -4
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/variables_manager.rs +27 -31
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler.rs +66 -59
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/connection.rs +42 -84
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/error.rs +105 -34
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/containers.rs +22 -27
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/edge.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/math.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/node.rs +1 -1
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/path.rs +16 -21
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +25 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +6 -6
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +28 -20
- data/ext/gqlitedb/src/graph.rs +11 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +163 -200
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +4 -3
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +8 -5
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/ast.rs +44 -52
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/gql.pest +1 -1
- data/ext/{gqliterb/vendor/gqlitedb/src/parser/parser.rs → gqlitedb/src/parser/parser_impl.rs} +50 -28
- data/ext/gqlitedb/src/parser.rs +4 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/prelude.rs +3 -2
- data/ext/gqlitedb/src/query_result.rs +88 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/redb.rs +226 -148
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/sqlite.rs +111 -128
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store.rs +22 -22
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/evaluators.rs +32 -76
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store.rs +95 -111
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/ast.rs +29 -29
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/programs.rs +14 -14
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/compare.rs +13 -20
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/contains.rs +2 -2
- data/ext/gqlitedb/src/value.rs +225 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value_table.rs +15 -5
- data/ext/gqliterb/Cargo.toml +12 -35
- data/ext/gqliterb/src/lib.rs +59 -39
- data/ext/graphcore/Cargo.toml +19 -0
- data/ext/graphcore/README.MD +4 -0
- data/ext/graphcore/release.toml +1 -0
- data/ext/graphcore/src/error.rs +28 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/graph.rs +134 -38
- data/ext/graphcore/src/lib.rs +15 -0
- data/ext/graphcore/src/prelude.rs +4 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/serialize_with.rs +2 -2
- data/ext/graphcore/src/table.rs +272 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/value/value_map.rs +44 -49
- data/ext/graphcore/src/value.rs +413 -0
- metadata +92 -88
- data/ext/gqliterb/.cargo/config.toml +0 -2
- data/ext/gqliterb/Cargo.lock +0 -1116
- data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +0 -2115
- data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +0 -138
- data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +0 -4
- data/ext/gqliterb/vendor/gqlitedb/src/value.rs +0 -609
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/askama.toml +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/mod.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_divan.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_iai.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/release.toml +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/containers.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/count.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/consts.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/string.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/mod.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/pgql.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/compiler.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/parser.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/redb.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/sqlite.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/utils.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/call_stats.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_count_for_node.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete_by_nodes.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_select.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_update.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_create_table.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_get.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_set.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_select.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_update.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/table_exists.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_from_1_01.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_graph_from_1_01.sql +0 -0
|
@@ -71,7 +71,7 @@ pub(crate) fn create_named_node() -> Program
|
|
|
71
71
|
skip: None,
|
|
72
72
|
order_by: vec![],
|
|
73
73
|
},
|
|
74
|
-
|
|
74
|
+
variables_sizes: create_variable_size(2, 0),
|
|
75
75
|
},
|
|
76
76
|
]
|
|
77
77
|
}
|
|
@@ -133,7 +133,7 @@ pub(crate) fn create_named_node_double_return() -> Program
|
|
|
133
133
|
skip: None,
|
|
134
134
|
order_by: vec![],
|
|
135
135
|
},
|
|
136
|
-
|
|
136
|
+
variables_sizes: create_variable_size(3, 0),
|
|
137
137
|
},
|
|
138
138
|
]
|
|
139
139
|
}
|
|
@@ -161,7 +161,7 @@ pub(crate) fn double_with_return() -> Program
|
|
|
161
161
|
skip: None,
|
|
162
162
|
order_by: vec![],
|
|
163
163
|
},
|
|
164
|
-
|
|
164
|
+
variables_sizes: create_variable_size(2, 0),
|
|
165
165
|
},
|
|
166
166
|
Block::With {
|
|
167
167
|
variables: vec![
|
|
@@ -182,7 +182,7 @@ pub(crate) fn double_with_return() -> Program
|
|
|
182
182
|
skip: None,
|
|
183
183
|
order_by: vec![],
|
|
184
184
|
},
|
|
185
|
-
|
|
185
|
+
variables_sizes: create_variable_size(4, 0),
|
|
186
186
|
},
|
|
187
187
|
Block::Return {
|
|
188
188
|
variables: vec![(
|
|
@@ -199,7 +199,7 @@ pub(crate) fn double_with_return() -> Program
|
|
|
199
199
|
skip: None,
|
|
200
200
|
order_by: vec![],
|
|
201
201
|
},
|
|
202
|
-
|
|
202
|
+
variables_sizes: create_variable_size(2, 0),
|
|
203
203
|
},
|
|
204
204
|
]
|
|
205
205
|
}
|
|
@@ -234,7 +234,7 @@ pub(crate) fn unwind() -> Program
|
|
|
234
234
|
skip: None,
|
|
235
235
|
order_by: vec![],
|
|
236
236
|
},
|
|
237
|
-
|
|
237
|
+
variables_sizes: create_variable_size(1, 0),
|
|
238
238
|
},
|
|
239
239
|
]
|
|
240
240
|
}
|
|
@@ -243,7 +243,7 @@ pub(crate) fn unwind() -> Program
|
|
|
243
243
|
pub(crate) fn match_loop() -> Program
|
|
244
244
|
{
|
|
245
245
|
vec![
|
|
246
|
-
Block::
|
|
246
|
+
Block::Match {
|
|
247
247
|
blocks: vec![BlockMatch::MatchEdge {
|
|
248
248
|
instructions: vec![
|
|
249
249
|
Instruction::Push {
|
|
@@ -288,7 +288,7 @@ pub(crate) fn match_loop() -> Program
|
|
|
288
288
|
skip: None,
|
|
289
289
|
order_by: vec![],
|
|
290
290
|
},
|
|
291
|
-
|
|
291
|
+
variables_sizes: create_variable_size(1, 0),
|
|
292
292
|
},
|
|
293
293
|
]
|
|
294
294
|
}
|
|
@@ -297,7 +297,7 @@ pub(crate) fn match_loop() -> Program
|
|
|
297
297
|
pub(crate) fn optional_match() -> Program
|
|
298
298
|
{
|
|
299
299
|
vec![
|
|
300
|
-
Block::
|
|
300
|
+
Block::Match {
|
|
301
301
|
blocks: vec![BlockMatch::MatchNode {
|
|
302
302
|
instructions: vec![
|
|
303
303
|
Instruction::Push {
|
|
@@ -327,7 +327,7 @@ pub(crate) fn optional_match() -> Program
|
|
|
327
327
|
skip: None,
|
|
328
328
|
order_by: vec![],
|
|
329
329
|
},
|
|
330
|
-
|
|
330
|
+
variables_sizes: create_variable_size(1, 0),
|
|
331
331
|
},
|
|
332
332
|
]
|
|
333
333
|
}
|
|
@@ -336,7 +336,7 @@ pub(crate) fn optional_match() -> Program
|
|
|
336
336
|
pub(crate) fn match_count(function_manager: &functions::Manager) -> Program
|
|
337
337
|
{
|
|
338
338
|
vec![
|
|
339
|
-
Block::
|
|
339
|
+
Block::Match {
|
|
340
340
|
blocks: vec![BlockMatch::MatchNode {
|
|
341
341
|
instructions: vec![
|
|
342
342
|
Instruction::Push {
|
|
@@ -378,7 +378,7 @@ pub(crate) fn match_count(function_manager: &functions::Manager) -> Program
|
|
|
378
378
|
skip: None,
|
|
379
379
|
order_by: vec![],
|
|
380
380
|
},
|
|
381
|
-
|
|
381
|
+
variables_sizes: create_variable_size(2, 1),
|
|
382
382
|
},
|
|
383
383
|
]
|
|
384
384
|
}
|
|
@@ -387,7 +387,7 @@ pub(crate) fn match_count(function_manager: &functions::Manager) -> Program
|
|
|
387
387
|
pub(crate) fn aggregation(function_manager: &functions::Manager) -> Program
|
|
388
388
|
{
|
|
389
389
|
vec![
|
|
390
|
-
Block::
|
|
390
|
+
Block::Match {
|
|
391
391
|
blocks: vec![BlockMatch::MatchNode {
|
|
392
392
|
instructions: vec![
|
|
393
393
|
Instruction::Push {
|
|
@@ -449,7 +449,7 @@ pub(crate) fn aggregation(function_manager: &functions::Manager) -> Program
|
|
|
449
449
|
skip: None,
|
|
450
450
|
order_by: vec![],
|
|
451
451
|
},
|
|
452
|
-
|
|
452
|
+
variables_sizes: create_variable_size(3, 1),
|
|
453
453
|
},
|
|
454
454
|
]
|
|
455
455
|
}
|
|
@@ -43,11 +43,7 @@ fn compare_map(lhs: &value::ValueMap, rhs: &value::ValueMap) -> Ordering
|
|
|
43
43
|
o => o.into(),
|
|
44
44
|
}
|
|
45
45
|
})
|
|
46
|
-
.find(|p|
|
|
47
|
-
{
|
|
48
|
-
Ordering::Equal => false,
|
|
49
|
-
_ => true,
|
|
50
|
-
})
|
|
46
|
+
.find(|p| !matches!(p, Ordering::Equal))
|
|
51
47
|
.unwrap_or(Ordering::Equal)
|
|
52
48
|
}
|
|
53
49
|
else if lhs.len() < rhs.len()
|
|
@@ -74,7 +70,7 @@ fn compare_f64(lhs: &f64, rhs: &f64) -> Ordering
|
|
|
74
70
|
|
|
75
71
|
fn compare_node(lhs: &graph::Node, rhs: &graph::Node) -> Ordering
|
|
76
72
|
{
|
|
77
|
-
lhs.key.uuid.cmp(&rhs.key.uuid).into()
|
|
73
|
+
lhs.key().uuid().cmp(&rhs.key().uuid()).into()
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
|
|
@@ -83,6 +79,12 @@ pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
|
|
|
83
79
|
match lhs
|
|
84
80
|
{
|
|
85
81
|
Value::Null => Ordering::ComparedNull,
|
|
82
|
+
Value::Key(kl) => match rhs
|
|
83
|
+
{
|
|
84
|
+
Value::Key(kr) => kl.uuid().cmp(&kr.uuid()).into(),
|
|
85
|
+
Value::Null => Ordering::ComparedNull,
|
|
86
|
+
_ => Ordering::Null,
|
|
87
|
+
},
|
|
86
88
|
Value::Boolean(bl) => match rhs
|
|
87
89
|
{
|
|
88
90
|
Value::Boolean(br) => bl.cmp(br).into(),
|
|
@@ -175,30 +177,21 @@ pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
|
|
|
175
177
|
},
|
|
176
178
|
Value::Edge(lhs) => match rhs
|
|
177
179
|
{
|
|
178
|
-
Value::Edge(rhs) =>
|
|
179
|
-
{
|
|
180
|
-
lhs.key.uuid.cmp(&rhs.key.uuid).into()
|
|
181
|
-
// let labels_cmp = lhs.labels.cmp(&rhs.labels);
|
|
182
|
-
// match labels_cmp
|
|
183
|
-
// {
|
|
184
|
-
// std::cmp::Ordering::Equal => compare_map(&lhs.properties, &rhs.properties),
|
|
185
|
-
// o => o.into(),
|
|
186
|
-
// }
|
|
187
|
-
}
|
|
180
|
+
Value::Edge(rhs) => lhs.key().uuid().cmp(&rhs.key().uuid()).into(),
|
|
188
181
|
_ => Ordering::Null,
|
|
189
182
|
},
|
|
190
183
|
Value::Path(lhs) => match rhs
|
|
191
184
|
{
|
|
192
185
|
Value::Path(rhs) =>
|
|
193
186
|
{
|
|
194
|
-
let labels_cmp = lhs.labels.cmp(
|
|
187
|
+
let labels_cmp = lhs.labels().cmp(rhs.labels());
|
|
195
188
|
match labels_cmp
|
|
196
189
|
{
|
|
197
|
-
std::cmp::Ordering::Equal => match compare_map(
|
|
190
|
+
std::cmp::Ordering::Equal => match compare_map(lhs.properties(), rhs.properties())
|
|
198
191
|
{
|
|
199
|
-
Ordering::Equal => match compare_node(
|
|
192
|
+
Ordering::Equal => match compare_node(lhs.source(), rhs.source())
|
|
200
193
|
{
|
|
201
|
-
Ordering::Equal => compare_node(
|
|
194
|
+
Ordering::Equal => compare_node(lhs.destination(), rhs.destination()),
|
|
202
195
|
o => o,
|
|
203
196
|
},
|
|
204
197
|
o => o,
|
|
@@ -8,7 +8,7 @@ pub(crate) enum ContainResult
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/// Compute contains, according to OpenCypher specification, specifically handling the comparison with null.
|
|
11
|
-
pub(crate) fn contains(container: &
|
|
11
|
+
pub(crate) fn contains(container: &[value::Value], value: &value::Value) -> ContainResult
|
|
12
12
|
{
|
|
13
13
|
if value.is_null()
|
|
14
14
|
{
|
|
@@ -27,7 +27,7 @@ pub(crate) fn contains(container: &Vec<value::Value>, value: &value::Value) -> C
|
|
|
27
27
|
for v_c in container.iter()
|
|
28
28
|
{
|
|
29
29
|
use value::ContainResult;
|
|
30
|
-
match value::compare(v_c,
|
|
30
|
+
match value::compare(v_c, value)
|
|
31
31
|
{
|
|
32
32
|
value::Ordering::Equal => return ContainResult::True,
|
|
33
33
|
value::Ordering::ComparedNull => has_compared_to_null = true,
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
mod compare;
|
|
2
|
+
mod contains;
|
|
3
|
+
|
|
4
|
+
pub(crate) use compare::{compare, Ordering};
|
|
5
|
+
pub(crate) use contains::{contains, ContainResult};
|
|
6
|
+
|
|
7
|
+
pub use graphcore::{array, value_map, Value, ValueMap, ValueTryIntoRef};
|
|
8
|
+
|
|
9
|
+
pub(crate) trait ValueExt
|
|
10
|
+
{
|
|
11
|
+
fn access<'a>(&self, path: impl Iterator<Item = &'a String>) -> Value;
|
|
12
|
+
fn compare(&self, rhs: &Value) -> crate::value::Ordering;
|
|
13
|
+
|
|
14
|
+
/// Compute the order between self and rhs, for OrderBy, according to the OpenCypher specification.
|
|
15
|
+
/// This order is total.
|
|
16
|
+
fn orderability(&self, rhs: &Value) -> std::cmp::Ordering;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fn orderability_map(lhs: &ValueMap, rhs: &ValueMap) -> std::cmp::Ordering
|
|
20
|
+
{
|
|
21
|
+
let o = lhs.len().cmp(&rhs.len());
|
|
22
|
+
match o
|
|
23
|
+
{
|
|
24
|
+
std::cmp::Ordering::Equal => lhs
|
|
25
|
+
.iter()
|
|
26
|
+
.map(|(key, value)| value.orderability(rhs.get(key).unwrap_or(&Value::Null)))
|
|
27
|
+
.find(|p| *p != std::cmp::Ordering::Equal)
|
|
28
|
+
.unwrap_or(std::cmp::Ordering::Equal),
|
|
29
|
+
o => o,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
fn orderability_float(lhs: &f64, rhs: &f64) -> std::cmp::Ordering
|
|
33
|
+
{
|
|
34
|
+
if lhs.is_nan()
|
|
35
|
+
{
|
|
36
|
+
if rhs.is_nan()
|
|
37
|
+
{
|
|
38
|
+
std::cmp::Ordering::Equal
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
{
|
|
42
|
+
std::cmp::Ordering::Greater
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if rhs.is_nan()
|
|
46
|
+
{
|
|
47
|
+
std::cmp::Ordering::Less
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
{
|
|
51
|
+
lhs.total_cmp(rhs)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
impl ValueExt for Value
|
|
55
|
+
{
|
|
56
|
+
fn access<'a>(&self, mut path: impl Iterator<Item = &'a String>) -> Value
|
|
57
|
+
{
|
|
58
|
+
match path.next()
|
|
59
|
+
{
|
|
60
|
+
Some(name) => match self
|
|
61
|
+
{
|
|
62
|
+
Value::Node(node) => match node.properties().get(name)
|
|
63
|
+
{
|
|
64
|
+
Some(val) => val.access(path),
|
|
65
|
+
None => Value::Null,
|
|
66
|
+
},
|
|
67
|
+
Value::Edge(edge) => match edge.properties().get(name)
|
|
68
|
+
{
|
|
69
|
+
Some(val) => val.access(path),
|
|
70
|
+
None => Value::Null,
|
|
71
|
+
},
|
|
72
|
+
Value::Map(obj) => match obj.get(name)
|
|
73
|
+
{
|
|
74
|
+
Some(val) => val.access(path),
|
|
75
|
+
None => Value::Null,
|
|
76
|
+
},
|
|
77
|
+
_ => Value::Null,
|
|
78
|
+
},
|
|
79
|
+
None => self.to_owned(),
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
fn compare(&self, rhs: &Value) -> crate::value::Ordering
|
|
83
|
+
{
|
|
84
|
+
crate::value::compare(self, rhs)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Compute the order between self and rhs, for OrderBy, according to the OpenCypher specification.
|
|
88
|
+
/// This order is total.
|
|
89
|
+
fn orderability(&self, rhs: &Value) -> std::cmp::Ordering
|
|
90
|
+
{
|
|
91
|
+
match self
|
|
92
|
+
{
|
|
93
|
+
Value::Null => match rhs
|
|
94
|
+
{
|
|
95
|
+
Value::Null => std::cmp::Ordering::Equal,
|
|
96
|
+
_ => std::cmp::Ordering::Greater,
|
|
97
|
+
},
|
|
98
|
+
Value::Key(lhs) => match rhs
|
|
99
|
+
{
|
|
100
|
+
Value::Null => std::cmp::Ordering::Less,
|
|
101
|
+
Value::Key(rhs) => lhs.uuid().cmp(&rhs.uuid()),
|
|
102
|
+
_ => std::cmp::Ordering::Greater,
|
|
103
|
+
},
|
|
104
|
+
Value::Integer(lhs) => match rhs
|
|
105
|
+
{
|
|
106
|
+
Value::Null | Value::Key(..) => std::cmp::Ordering::Less,
|
|
107
|
+
Value::Integer(rhs) => lhs.cmp(rhs),
|
|
108
|
+
Value::Float(rhs) => orderability_float(&(*lhs as f64), rhs),
|
|
109
|
+
_ => std::cmp::Ordering::Greater,
|
|
110
|
+
},
|
|
111
|
+
Value::Float(lhs) => match rhs
|
|
112
|
+
{
|
|
113
|
+
Value::Null | Value::Key(..) => std::cmp::Ordering::Less,
|
|
114
|
+
Value::Integer(rhs) => orderability_float(lhs, &(*rhs as f64)),
|
|
115
|
+
Value::Float(rhs) => orderability_float(lhs, rhs),
|
|
116
|
+
_ => std::cmp::Ordering::Greater,
|
|
117
|
+
},
|
|
118
|
+
Value::Boolean(lhs) => match rhs
|
|
119
|
+
{
|
|
120
|
+
Value::Null | Value::Key(..) | Value::Integer(..) | Value::Float(..) =>
|
|
121
|
+
{
|
|
122
|
+
std::cmp::Ordering::Less
|
|
123
|
+
}
|
|
124
|
+
Value::Boolean(rhs) => lhs.cmp(rhs),
|
|
125
|
+
_ => std::cmp::Ordering::Greater,
|
|
126
|
+
},
|
|
127
|
+
Value::String(lhs) => match rhs
|
|
128
|
+
{
|
|
129
|
+
Value::Null
|
|
130
|
+
| Value::Key(..)
|
|
131
|
+
| Value::Integer(..)
|
|
132
|
+
| Value::Float(..)
|
|
133
|
+
| Value::Boolean(..) => std::cmp::Ordering::Less,
|
|
134
|
+
Value::String(rhs) => lhs.cmp(rhs),
|
|
135
|
+
_ => std::cmp::Ordering::Greater,
|
|
136
|
+
},
|
|
137
|
+
Value::Path(lhs) => match rhs
|
|
138
|
+
{
|
|
139
|
+
Value::Null
|
|
140
|
+
| Value::Key(..)
|
|
141
|
+
| Value::Integer(..)
|
|
142
|
+
| Value::Float(..)
|
|
143
|
+
| Value::Boolean(..)
|
|
144
|
+
| Value::String(..) => std::cmp::Ordering::Less,
|
|
145
|
+
Value::Path(rhs) =>
|
|
146
|
+
{
|
|
147
|
+
match orderability_map(lhs.source().properties(), rhs.source().properties())
|
|
148
|
+
{
|
|
149
|
+
std::cmp::Ordering::Equal =>
|
|
150
|
+
{
|
|
151
|
+
match orderability_map(lhs.properties(), rhs.properties())
|
|
152
|
+
{
|
|
153
|
+
std::cmp::Ordering::Equal => orderability_map(
|
|
154
|
+
lhs.destination().properties(),
|
|
155
|
+
rhs.destination().properties(),
|
|
156
|
+
),
|
|
157
|
+
o => o,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
o => o,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
_ => std::cmp::Ordering::Greater,
|
|
164
|
+
},
|
|
165
|
+
Value::Array(lhs) => match rhs
|
|
166
|
+
{
|
|
167
|
+
Value::Null
|
|
168
|
+
| Value::Key(..)
|
|
169
|
+
| Value::Integer(..)
|
|
170
|
+
| Value::Float(..)
|
|
171
|
+
| Value::Boolean(..)
|
|
172
|
+
| Value::String(..)
|
|
173
|
+
| Value::Path(..) => std::cmp::Ordering::Less,
|
|
174
|
+
Value::Array(rhs) => lhs
|
|
175
|
+
.iter()
|
|
176
|
+
.zip(rhs.iter())
|
|
177
|
+
.map(|(lhs, rhs)| Self::orderability(lhs, rhs))
|
|
178
|
+
.find(|p| *p != std::cmp::Ordering::Equal)
|
|
179
|
+
.unwrap_or(lhs.len().cmp(&rhs.len())),
|
|
180
|
+
_ => std::cmp::Ordering::Greater,
|
|
181
|
+
},
|
|
182
|
+
Value::Edge(lhs) => match rhs
|
|
183
|
+
{
|
|
184
|
+
Value::Null
|
|
185
|
+
| Value::Key(..)
|
|
186
|
+
| Value::Integer(..)
|
|
187
|
+
| Value::Float(..)
|
|
188
|
+
| Value::Boolean(..)
|
|
189
|
+
| Value::String(..)
|
|
190
|
+
| Value::Path(..)
|
|
191
|
+
| Value::Array(..) => std::cmp::Ordering::Less,
|
|
192
|
+
Value::Edge(rhs) => orderability_map(lhs.properties(), rhs.properties()),
|
|
193
|
+
_ => std::cmp::Ordering::Greater,
|
|
194
|
+
},
|
|
195
|
+
Value::Node(lhs) => match rhs
|
|
196
|
+
{
|
|
197
|
+
Value::Null
|
|
198
|
+
| Value::Key(..)
|
|
199
|
+
| Value::Integer(..)
|
|
200
|
+
| Value::Float(..)
|
|
201
|
+
| Value::Boolean(..)
|
|
202
|
+
| Value::String(..)
|
|
203
|
+
| Value::Path(..)
|
|
204
|
+
| Value::Array(..)
|
|
205
|
+
| Value::Edge(..) => std::cmp::Ordering::Less,
|
|
206
|
+
Value::Node(rhs) => orderability_map(lhs.properties(), rhs.properties()),
|
|
207
|
+
_ => std::cmp::Ordering::Greater,
|
|
208
|
+
},
|
|
209
|
+
Value::Map(lhs) => match rhs
|
|
210
|
+
{
|
|
211
|
+
Value::Null
|
|
212
|
+
| Value::Key(..)
|
|
213
|
+
| Value::Integer(..)
|
|
214
|
+
| Value::Float(..)
|
|
215
|
+
| Value::Boolean(..)
|
|
216
|
+
| Value::String(..)
|
|
217
|
+
| Value::Path(..)
|
|
218
|
+
| Value::Array(..)
|
|
219
|
+
| Value::Edge(..)
|
|
220
|
+
| Value::Node(..) => std::cmp::Ordering::Less,
|
|
221
|
+
Value::Map(rhs) => orderability_map(lhs, rhs),
|
|
222
|
+
},
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -53,7 +53,7 @@ impl Row
|
|
|
53
53
|
{
|
|
54
54
|
Err(
|
|
55
55
|
InternalError::InvalidIndex {
|
|
56
|
-
index
|
|
56
|
+
index,
|
|
57
57
|
length: self.values.len(),
|
|
58
58
|
}
|
|
59
59
|
.into(),
|
|
@@ -138,11 +138,11 @@ impl MutableRowInterface for Row
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
impl
|
|
141
|
+
impl From<Row> for value::Value
|
|
142
142
|
{
|
|
143
|
-
fn
|
|
143
|
+
fn from(v: Row) -> Self
|
|
144
144
|
{
|
|
145
|
-
value::Value::Array(
|
|
145
|
+
value::Value::Array(v.values)
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -154,6 +154,16 @@ impl FromIterator<value::Value> for Row
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
impl IntoIterator for Row
|
|
158
|
+
{
|
|
159
|
+
type Item = value::Value;
|
|
160
|
+
type IntoIter = <Vec<Self::Item> as IntoIterator>::IntoIter;
|
|
161
|
+
fn into_iter(self) -> Self::IntoIter
|
|
162
|
+
{
|
|
163
|
+
self.values.into_iter()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
157
167
|
pub(crate) trait Header
|
|
158
168
|
{
|
|
159
169
|
fn columns(&self) -> usize;
|
|
@@ -443,7 +453,7 @@ impl Iterator for IntoRowIter
|
|
|
443
453
|
else
|
|
444
454
|
{
|
|
445
455
|
let v: Vec<_> = self.data.by_ref().take(self.columns).collect();
|
|
446
|
-
if v.
|
|
456
|
+
if v.is_empty()
|
|
447
457
|
{
|
|
448
458
|
None
|
|
449
459
|
}
|
data/ext/gqliterb/Cargo.toml
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
|
-
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
|
2
|
-
#
|
|
3
|
-
# When uploading crates to the registry Cargo will automatically
|
|
4
|
-
# "normalize" Cargo.toml files for maximal compatibility
|
|
5
|
-
# with all versions of Cargo and also rewrite `path` dependencies
|
|
6
|
-
# to registry (e.g., crates.io) dependencies.
|
|
7
|
-
#
|
|
8
|
-
# If you are reading this file be aware that the original Cargo.toml
|
|
9
|
-
# will likely look very different (and much more reasonable).
|
|
10
|
-
# See Cargo.toml.orig for the original contents.
|
|
11
|
-
|
|
12
1
|
[package]
|
|
13
|
-
edition = "2021"
|
|
14
2
|
name = "gqliterb"
|
|
15
|
-
version = "0.5.3"
|
|
16
|
-
build = false
|
|
17
|
-
autolib = false
|
|
18
|
-
autobins = false
|
|
19
|
-
autoexamples = false
|
|
20
|
-
autotests = false
|
|
21
|
-
autobenches = false
|
|
22
3
|
description = "Crate with the Ruby bindings for GQLite."
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
license =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[package.metadata.release]
|
|
29
|
-
release = false
|
|
4
|
+
version.workspace = true
|
|
5
|
+
edition.workspace = true
|
|
6
|
+
license.workspace = true
|
|
7
|
+
homepage.workspace = true
|
|
8
|
+
repository.workspace = true
|
|
30
9
|
|
|
31
10
|
[lib]
|
|
32
|
-
name = "gqliterb"
|
|
33
11
|
crate-type = ["cdylib"]
|
|
34
|
-
path = "src/lib.rs"
|
|
35
12
|
|
|
36
|
-
[dependencies
|
|
37
|
-
|
|
38
|
-
|
|
13
|
+
[dependencies]
|
|
14
|
+
gqlitedb = { workspace = true }
|
|
15
|
+
magnus = "0.8"
|
|
39
16
|
|
|
40
|
-
[dependencies
|
|
41
|
-
|
|
17
|
+
[build-dependencies]
|
|
18
|
+
rb-sys-env = "0.2"
|
|
42
19
|
|
|
43
|
-
[
|
|
44
|
-
|
|
20
|
+
[package.metadata.release]
|
|
21
|
+
release = false
|