gqlite 1.2.3 → 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.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +20 -0
- data/ext/gqlitedb/Cargo.toml +77 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
- data/ext/gqlitedb/gqlite_bench_data/README.MD +6 -0
- data/ext/gqlitedb/gqlite_bench_data/scripts/generate_smaller_pokec.rb +85 -0
- data/ext/gqlitedb/gqlite_bench_data/scripts/to_efficient_pokec.rb +34 -0
- 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 +37 -41
- 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 +21 -26
- 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 +15 -20
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +6 -6
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +20 -20
- data/ext/gqlitedb/src/graph.rs +11 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +160 -194
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +2 -1
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +9 -4
- 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 +4 -4
- 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 +60 -38
- 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 +16 -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 +94 -83
- 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
|
@@ -9,6 +9,7 @@ use crate::{
|
|
|
9
9
|
use interpreter::instructions;
|
|
10
10
|
|
|
11
11
|
#[derive(Debug, Clone)]
|
|
12
|
+
#[allow(clippy::enum_variant_names)]
|
|
12
13
|
enum Value
|
|
13
14
|
{
|
|
14
15
|
GraphValue(value::Value),
|
|
@@ -34,7 +35,7 @@ macro_rules! try_into_gv_impl {
|
|
|
34
35
|
fn try_into(self) -> crate::Result<$vn>
|
|
35
36
|
{
|
|
36
37
|
let a: value::Value = self.try_into()?;
|
|
37
|
-
a.try_into()
|
|
38
|
+
Ok(a.try_into()?)
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
impl TryPopInto<$vn> for Stack
|
|
@@ -42,12 +43,12 @@ macro_rules! try_into_gv_impl {
|
|
|
42
43
|
fn try_pop_into(&mut self) -> crate::Result<$vn>
|
|
43
44
|
{
|
|
44
45
|
self.try_pop()?.try_into()
|
|
45
|
-
.map_err(|e: ErrorType| error::map_error!(e, Error::
|
|
46
|
+
.map_err(|e: ErrorType| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
46
47
|
}
|
|
47
48
|
fn try_drain_into(&mut self, n: usize) -> Result<Vec<$vn>>
|
|
48
49
|
{
|
|
49
50
|
self.try_drain(n)?.map(|x| x.try_into()).collect::<Result<_>>()
|
|
50
|
-
.map_err(|e| error::map_error!(e, Error::
|
|
51
|
+
.map_err(|e| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
};
|
|
@@ -84,13 +85,13 @@ macro_rules! try_into_impl {
|
|
|
84
85
|
fn try_pop_into(&mut self) -> Result<$type>
|
|
85
86
|
{
|
|
86
87
|
self.try_pop()?.try_into()
|
|
87
|
-
.map_err(|e: ErrorType| error::map_error!(e, Error::
|
|
88
|
+
.map_err(|e: ErrorType| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
88
89
|
|
|
89
90
|
}
|
|
90
91
|
fn try_drain_into(&mut self, n: usize) -> Result<Vec<$type>>
|
|
91
92
|
{
|
|
92
93
|
self.try_drain(n)?.map(|x| x.try_into()).collect::<Result<_>>()
|
|
93
|
-
.map_err(|e| error::map_error!(e, Error::
|
|
94
|
+
.map_err(|e| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
};
|
|
@@ -104,7 +105,7 @@ impl From<store::SelectNodeQuery> for Value
|
|
|
104
105
|
{
|
|
105
106
|
fn from(value: store::SelectNodeQuery) -> Self
|
|
106
107
|
{
|
|
107
|
-
Self::NodeQuery(value
|
|
108
|
+
Self::NodeQuery(value)
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -112,7 +113,7 @@ impl From<store::SelectEdgeQuery> for Value
|
|
|
112
113
|
{
|
|
113
114
|
fn from(value: store::SelectEdgeQuery) -> Self
|
|
114
115
|
{
|
|
115
|
-
Self::EdgeQuery(value
|
|
116
|
+
Self::EdgeQuery(value)
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -183,7 +184,7 @@ impl Stack
|
|
|
183
184
|
Ok(self.stack.drain((self.stack.len() - len)..))
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
fn
|
|
187
|
+
fn into_vec(self) -> Vec<Value>
|
|
187
188
|
{
|
|
188
189
|
self.stack
|
|
189
190
|
}
|
|
@@ -214,12 +215,12 @@ where
|
|
|
214
215
|
fn try_pop_into(&mut self) -> Result<T>
|
|
215
216
|
{
|
|
216
217
|
self.try_pop()?.try_into()
|
|
217
|
-
.map_err(|e: ErrorType| error::map_error!(e, Error::
|
|
218
|
+
.map_err(|e: ErrorType| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
218
219
|
}
|
|
219
220
|
fn try_drain_into(&mut self, n: usize) -> Result<Vec<T>>
|
|
220
221
|
{
|
|
221
222
|
self.try_drain(n)?.map(|x| x.try_into()).collect::<Result<Vec<_>>>()
|
|
222
|
-
.map_err(|e| error::map_error!(e, Error::
|
|
223
|
+
.map_err(|e| error::map_error!(e, Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
|
|
@@ -234,11 +235,11 @@ fn execute_boolean_operator(
|
|
|
234
235
|
let b: value::Value = b.try_into()?;
|
|
235
236
|
match instruction
|
|
236
237
|
{
|
|
237
|
-
|
|
238
|
+
instructions::Instruction::AndBinaryOperator =>
|
|
238
239
|
{
|
|
239
240
|
if a.is_null()
|
|
240
241
|
{
|
|
241
|
-
if b.is_null() || <value::Value as TryInto<bool>>::try_into(b)?
|
|
242
|
+
if b.is_null() || <value::Value as TryInto<bool>>::try_into(b)?
|
|
242
243
|
{
|
|
243
244
|
stack.push(value::Value::Null);
|
|
244
245
|
}
|
|
@@ -267,11 +268,11 @@ fn execute_boolean_operator(
|
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
|
|
271
|
+
instructions::Instruction::OrBinaryOperator =>
|
|
271
272
|
{
|
|
272
273
|
if a.is_null()
|
|
273
274
|
{
|
|
274
|
-
if b.is_null() ||
|
|
275
|
+
if b.is_null() || !<value::Value as TryInto<bool>>::try_into(b)?
|
|
275
276
|
{
|
|
276
277
|
stack.push(value::Value::Null);
|
|
277
278
|
}
|
|
@@ -287,20 +288,17 @@ fn execute_boolean_operator(
|
|
|
287
288
|
{
|
|
288
289
|
stack.push(true);
|
|
289
290
|
}
|
|
291
|
+
else if b.is_null()
|
|
292
|
+
{
|
|
293
|
+
stack.push(value::Value::Null);
|
|
294
|
+
}
|
|
290
295
|
else
|
|
291
296
|
{
|
|
292
|
-
|
|
293
|
-
{
|
|
294
|
-
stack.push(value::Value::Null);
|
|
295
|
-
}
|
|
296
|
-
else
|
|
297
|
-
{
|
|
298
|
-
stack.push(b);
|
|
299
|
-
}
|
|
297
|
+
stack.push(b);
|
|
300
298
|
}
|
|
301
299
|
}
|
|
302
300
|
}
|
|
303
|
-
|
|
301
|
+
instructions::Instruction::XorBinaryOperator =>
|
|
304
302
|
{
|
|
305
303
|
if a.is_null() || b.is_null()
|
|
306
304
|
{
|
|
@@ -323,7 +321,7 @@ fn execute_boolean_operator(
|
|
|
323
321
|
|
|
324
322
|
fn execute_binary_operator<T: Into<crate::value::Value>>(
|
|
325
323
|
stack: &mut Stack,
|
|
326
|
-
operand: impl FnOnce(crate::value::Value, crate::value::Value) -> Result<T>,
|
|
324
|
+
operand: impl FnOnce(crate::value::Value, crate::value::Value) -> Result<T, graphcore::Error>,
|
|
327
325
|
) -> Result<()>
|
|
328
326
|
{
|
|
329
327
|
let a = stack.try_pop()?;
|
|
@@ -359,22 +357,22 @@ fn eval_instructions(
|
|
|
359
357
|
let props: value::Value = stack.try_pop_into()?;
|
|
360
358
|
let dst: graph::Node = stack.try_pop_into()?;
|
|
361
359
|
let src: graph::Node = stack.try_pop_into()?;
|
|
362
|
-
stack.push(crate::graph::
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
360
|
+
stack.push(crate::graph::Path::new(
|
|
361
|
+
graph::Key::default(),
|
|
362
|
+
src,
|
|
363
|
+
labels.to_owned(),
|
|
364
|
+
props.into_map(),
|
|
365
|
+
dst,
|
|
366
|
+
));
|
|
369
367
|
}
|
|
370
368
|
instructions::Instruction::CreateNodeLiteral { labels } =>
|
|
371
369
|
{
|
|
372
370
|
let props: value::Value = stack.try_pop_into()?;
|
|
373
|
-
stack.push(crate::graph::Node
|
|
374
|
-
|
|
375
|
-
labels
|
|
376
|
-
|
|
377
|
-
|
|
371
|
+
stack.push(crate::graph::Node::new(
|
|
372
|
+
crate::graph::Key::default(),
|
|
373
|
+
labels.clone(),
|
|
374
|
+
props.into_map(),
|
|
375
|
+
));
|
|
378
376
|
}
|
|
379
377
|
instructions::Instruction::CreateEdgeQuery { labels } =>
|
|
380
378
|
{
|
|
@@ -387,7 +385,7 @@ fn eval_instructions(
|
|
|
387
385
|
{
|
|
388
386
|
stack.push(store::SelectEdgeQuery::select_source_destination_keys(
|
|
389
387
|
src,
|
|
390
|
-
[ed.key],
|
|
388
|
+
[ed.key()],
|
|
391
389
|
dst,
|
|
392
390
|
));
|
|
393
391
|
}
|
|
@@ -406,8 +404,8 @@ fn eval_instructions(
|
|
|
406
404
|
{
|
|
407
405
|
stack.push(store::SelectEdgeQuery::select_none());
|
|
408
406
|
}
|
|
409
|
-
_ => Err(
|
|
410
|
-
value: props,
|
|
407
|
+
_ => Err(RunTimeError::InvalidValueCast {
|
|
408
|
+
value: Box::new(props),
|
|
411
409
|
typename: "Edge properties",
|
|
412
410
|
})?,
|
|
413
411
|
}
|
|
@@ -419,7 +417,7 @@ fn eval_instructions(
|
|
|
419
417
|
{
|
|
420
418
|
value::Value::Node(no) =>
|
|
421
419
|
{
|
|
422
|
-
stack.push(store::SelectNodeQuery::select_keys([no.key]));
|
|
420
|
+
stack.push(store::SelectNodeQuery::select_keys([no.key()]));
|
|
423
421
|
}
|
|
424
422
|
value::Value::Map(ob) =>
|
|
425
423
|
{
|
|
@@ -432,8 +430,8 @@ fn eval_instructions(
|
|
|
432
430
|
{
|
|
433
431
|
stack.push(store::SelectNodeQuery::select_none());
|
|
434
432
|
}
|
|
435
|
-
_ => Err(
|
|
436
|
-
value: props,
|
|
433
|
+
_ => Err(RunTimeError::InvalidValueCast {
|
|
434
|
+
value: Box::new(props),
|
|
437
435
|
typename: "Node properties",
|
|
438
436
|
})?,
|
|
439
437
|
}
|
|
@@ -519,7 +517,7 @@ fn eval_instructions(
|
|
|
519
517
|
value::Value::Array(array) =>
|
|
520
518
|
{
|
|
521
519
|
let idx: i64 = index.try_into()
|
|
522
|
-
.map_err(|e:
|
|
520
|
+
.map_err(|e: graphcore::Error| error::map_error!(e.into(), Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))?;
|
|
523
521
|
stack.push(
|
|
524
522
|
array
|
|
525
523
|
.get(idx as usize)
|
|
@@ -527,24 +525,36 @@ fn eval_instructions(
|
|
|
527
525
|
.to_owned(),
|
|
528
526
|
);
|
|
529
527
|
}
|
|
530
|
-
value::Value::Map(map)
|
|
531
|
-
| value::Value::Node(graph::Node {
|
|
532
|
-
key: _,
|
|
533
|
-
labels: _,
|
|
534
|
-
properties: map,
|
|
535
|
-
})
|
|
536
|
-
| value::Value::Edge(graph::Edge {
|
|
537
|
-
key: _,
|
|
538
|
-
source: _,
|
|
539
|
-
destination: _,
|
|
540
|
-
labels: _,
|
|
541
|
-
properties: map,
|
|
542
|
-
}) =>
|
|
528
|
+
value::Value::Map(map) =>
|
|
543
529
|
{
|
|
544
530
|
let idx: String = index.try_into()
|
|
545
|
-
|
|
531
|
+
.map_err(|e: graphcore::Error| error::map_error!(e.into(), Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::MapElementAccessByNonString ))?;
|
|
546
532
|
stack.push(map.get(&idx).unwrap_or(&value::Value::Null).to_owned());
|
|
547
533
|
}
|
|
534
|
+
value::Value::Node(node) =>
|
|
535
|
+
{
|
|
536
|
+
let idx: String = index.try_into()
|
|
537
|
+
.map_err(|e: graphcore::Error| error::map_error!(e.into(), Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))?;
|
|
538
|
+
stack.push(
|
|
539
|
+
node
|
|
540
|
+
.properties()
|
|
541
|
+
.get(&idx)
|
|
542
|
+
.unwrap_or(&value::Value::Null)
|
|
543
|
+
.to_owned(),
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
value::Value::Edge(edge) =>
|
|
547
|
+
{
|
|
548
|
+
let idx: String = index.try_into()
|
|
549
|
+
.map_err(|e: graphcore::Error| error::map_error!(e.into(), Error::RunTime(RunTimeError::InvalidValueCast{..}) => RunTimeError::InvalidArgumentType ))?;
|
|
550
|
+
stack.push(
|
|
551
|
+
edge
|
|
552
|
+
.properties()
|
|
553
|
+
.get(&idx)
|
|
554
|
+
.unwrap_or(&value::Value::Null)
|
|
555
|
+
.to_owned(),
|
|
556
|
+
);
|
|
557
|
+
}
|
|
548
558
|
value::Value::Null => stack.push(value::Value::Null),
|
|
549
559
|
_ => Err(error::RunTimeError::InvalidArgumentType)?,
|
|
550
560
|
}
|
|
@@ -571,8 +581,7 @@ fn eval_instructions(
|
|
|
571
581
|
// Get the array out of the stack
|
|
572
582
|
let v: value::Value = stack.try_pop_into()?;
|
|
573
583
|
// if either end or start are null, return null
|
|
574
|
-
if end.as_ref().
|
|
575
|
-
|| start.as_ref().map_or(false, |s| s.is_null())
|
|
584
|
+
if end.as_ref().is_some_and(|e| e.is_null()) || start.as_ref().is_some_and(|s| s.is_null())
|
|
576
585
|
{
|
|
577
586
|
stack.push(value::Value::Null);
|
|
578
587
|
}
|
|
@@ -587,14 +596,14 @@ fn eval_instructions(
|
|
|
587
596
|
(Some(start), Some(end)) => Some(end - start),
|
|
588
597
|
_ => None,
|
|
589
598
|
};
|
|
590
|
-
if length.
|
|
599
|
+
if length.is_some_and(|l| l >= v.len() as i64)
|
|
591
600
|
{
|
|
592
601
|
stack.push(v);
|
|
593
602
|
}
|
|
594
603
|
else
|
|
595
604
|
{
|
|
596
605
|
// If start is negative, it should be made into a positive number
|
|
597
|
-
while start.
|
|
606
|
+
while start.is_some_and(|x| x < 0)
|
|
598
607
|
{
|
|
599
608
|
start = start.map(|x| x + v.len() as i64);
|
|
600
609
|
end = end.map(|x| x + v.len() as i64);
|
|
@@ -738,7 +747,7 @@ fn eval_instructions(
|
|
|
738
747
|
execute_binary_operator::<value::Value>(stack, |a, b| {
|
|
739
748
|
if b.is_null()
|
|
740
749
|
{
|
|
741
|
-
Ok(value::Value::Null
|
|
750
|
+
Ok(value::Value::Null)
|
|
742
751
|
}
|
|
743
752
|
else
|
|
744
753
|
{
|
|
@@ -755,7 +764,7 @@ fn eval_instructions(
|
|
|
755
764
|
execute_binary_operator::<value::Value>(stack, |a, b| {
|
|
756
765
|
if b.is_null()
|
|
757
766
|
{
|
|
758
|
-
Ok(value::Value::Null
|
|
767
|
+
Ok(value::Value::Null)
|
|
759
768
|
}
|
|
760
769
|
else
|
|
761
770
|
{
|
|
@@ -796,13 +805,14 @@ fn eval_instructions(
|
|
|
796
805
|
Ok(())
|
|
797
806
|
}
|
|
798
807
|
|
|
808
|
+
#[allow(clippy::too_many_arguments)]
|
|
799
809
|
pub(crate) fn eval_update_property<TStore: store::Store>(
|
|
800
810
|
store: &TStore,
|
|
801
|
-
|
|
811
|
+
tx: &mut TStore::TransactionBox,
|
|
802
812
|
graph_name: &String,
|
|
803
813
|
row: &mut value_table::Row,
|
|
804
814
|
target: value_table::ColId,
|
|
805
|
-
path: &
|
|
815
|
+
path: &[String],
|
|
806
816
|
instructions: &instructions::Instructions,
|
|
807
817
|
parameters: &crate::value::ValueMap,
|
|
808
818
|
set: bool,
|
|
@@ -810,12 +820,12 @@ pub(crate) fn eval_update_property<TStore: store::Store>(
|
|
|
810
820
|
{
|
|
811
821
|
let var = row.get(target)?;
|
|
812
822
|
let mut stack = Stack::default();
|
|
813
|
-
eval_instructions(&mut stack, row,
|
|
823
|
+
eval_instructions(&mut stack, row, instructions, parameters)?;
|
|
814
824
|
let value: value::Value = stack.try_pop_into()?;
|
|
815
825
|
let value = match value
|
|
816
826
|
{
|
|
817
|
-
value::Value::Node(n) => n.
|
|
818
|
-
value::Value::Edge(e) => e.
|
|
827
|
+
value::Value::Node(n) => n.take_properties().into(),
|
|
828
|
+
value::Value::Edge(e) => e.take_properties().into(),
|
|
819
829
|
_ => value,
|
|
820
830
|
};
|
|
821
831
|
let mut piter = path.iter();
|
|
@@ -826,15 +836,15 @@ pub(crate) fn eval_update_property<TStore: store::Store>(
|
|
|
826
836
|
let mut n = n.to_owned();
|
|
827
837
|
if set
|
|
828
838
|
{
|
|
829
|
-
n.
|
|
839
|
+
n.properties_mut()
|
|
830
840
|
.set_value(piter.next(), piter, value.remove_null())?;
|
|
831
841
|
}
|
|
832
842
|
else
|
|
833
843
|
{
|
|
834
|
-
n.
|
|
844
|
+
n.properties_mut()
|
|
835
845
|
.add_values(piter.next(), piter, value.try_into()?)?;
|
|
836
846
|
}
|
|
837
|
-
store.update_node(
|
|
847
|
+
store.update_node(tx, graph_name, &n)?;
|
|
838
848
|
row.set(target, n.into())?;
|
|
839
849
|
}
|
|
840
850
|
value::Value::Edge(e) =>
|
|
@@ -842,15 +852,15 @@ pub(crate) fn eval_update_property<TStore: store::Store>(
|
|
|
842
852
|
let mut e = e.to_owned();
|
|
843
853
|
if set
|
|
844
854
|
{
|
|
845
|
-
e.
|
|
855
|
+
e.properties_mut()
|
|
846
856
|
.set_value(piter.next(), piter, value.remove_null())?;
|
|
847
857
|
}
|
|
848
858
|
else
|
|
849
859
|
{
|
|
850
|
-
e.
|
|
860
|
+
e.properties_mut()
|
|
851
861
|
.add_values(piter.next(), piter, value.try_into()?)?;
|
|
852
862
|
}
|
|
853
|
-
store.update_edge(
|
|
863
|
+
store.update_edge(tx, graph_name, &e)?;
|
|
854
864
|
row.set(target, e.into())?;
|
|
855
865
|
}
|
|
856
866
|
value::Value::Null =>
|
|
@@ -906,7 +916,7 @@ fn create_aggregations_states(
|
|
|
906
916
|
)?;
|
|
907
917
|
let state = agg.aggregator.create(
|
|
908
918
|
stack
|
|
909
|
-
.
|
|
919
|
+
.into_vec()
|
|
910
920
|
.into_iter()
|
|
911
921
|
.map(|v| v.try_into())
|
|
912
922
|
.collect::<Result<_>>()?,
|
|
@@ -930,7 +940,7 @@ fn compute_return_with_table(
|
|
|
930
940
|
{
|
|
931
941
|
let mut output_table = value_table::ValueTable::new(variables_sizes.total_size());
|
|
932
942
|
// Compute table
|
|
933
|
-
if variables.iter().any(|v| v.aggregations.
|
|
943
|
+
if variables.iter().any(|v| !v.aggregations.is_empty())
|
|
934
944
|
{
|
|
935
945
|
// 1) For each row, compute non-aggregated columns, based on those columns, select a vector of aggregator states. and update them
|
|
936
946
|
|
|
@@ -944,19 +954,19 @@ fn compute_return_with_table(
|
|
|
944
954
|
let out_row = variables
|
|
945
955
|
.iter()
|
|
946
956
|
.map(|rw_expr| {
|
|
947
|
-
if rw_expr.aggregations.
|
|
948
|
-
{
|
|
949
|
-
Ok(value::Value::Null)
|
|
950
|
-
}
|
|
951
|
-
else
|
|
957
|
+
if rw_expr.aggregations.is_empty()
|
|
952
958
|
{
|
|
953
959
|
assert_eq!(rw_expr.aggregations.len(), 0);
|
|
954
960
|
let mut stack = Stack::default();
|
|
955
|
-
eval_instructions(&mut stack, &row, &rw_expr.instructions,
|
|
961
|
+
eval_instructions(&mut stack, &row, &rw_expr.instructions, parameters)?;
|
|
956
962
|
let value: value::Value = stack.try_pop_into()?;
|
|
957
963
|
row.set(rw_expr.col_id, value.to_owned())?;
|
|
958
964
|
Ok(value)
|
|
959
965
|
}
|
|
966
|
+
else
|
|
967
|
+
{
|
|
968
|
+
Ok(value::Value::Null)
|
|
969
|
+
}
|
|
960
970
|
})
|
|
961
971
|
.collect::<Result<Row>>()?;
|
|
962
972
|
// b) initialise aggregations
|
|
@@ -987,7 +997,7 @@ fn compute_return_with_table(
|
|
|
987
997
|
}
|
|
988
998
|
|
|
989
999
|
// Aggregation always return at least once, unless there is a non-aggregated value
|
|
990
|
-
if aggregation_table.is_empty() && variables.iter().all(|v| v.aggregations.
|
|
1000
|
+
if aggregation_table.is_empty() && variables.iter().all(|v| !v.aggregations.is_empty())
|
|
991
1001
|
{
|
|
992
1002
|
let row = Row::new(Default::default(), variables_sizes.total_size());
|
|
993
1003
|
let aggregations_states = create_aggregations_states(&variables, parameters)?;
|
|
@@ -998,14 +1008,13 @@ fn compute_return_with_table(
|
|
|
998
1008
|
|
|
999
1009
|
for (row, aggregations_states) in aggregation_table
|
|
1000
1010
|
{
|
|
1001
|
-
let mut non_null_aggregation = false;
|
|
1002
1011
|
let mut out_row = value_table::Row::new(Default::default(), variables_sizes.total_size());
|
|
1003
1012
|
for (idx, (rw_expr, aggregation_states)) in variables
|
|
1004
1013
|
.iter()
|
|
1005
1014
|
.zip(aggregations_states.into_iter())
|
|
1006
1015
|
.enumerate()
|
|
1007
1016
|
{
|
|
1008
|
-
if rw_expr.aggregations.
|
|
1017
|
+
if rw_expr.aggregations.is_empty()
|
|
1009
1018
|
{
|
|
1010
1019
|
out_row.set(rw_expr.col_id, row.0.get(idx)?.to_owned())?;
|
|
1011
1020
|
}
|
|
@@ -1014,11 +1023,10 @@ fn compute_return_with_table(
|
|
|
1014
1023
|
for (name, s) in aggregation_states.into_iter()
|
|
1015
1024
|
{
|
|
1016
1025
|
let value = s.finalise()?;
|
|
1017
|
-
non_null_aggregation = non_null_aggregation | !value.is_null();
|
|
1018
1026
|
out_row.set(name, value)?;
|
|
1019
1027
|
}
|
|
1020
1028
|
let mut stack = Stack::default();
|
|
1021
|
-
eval_instructions(&mut stack, &out_row, &rw_expr.instructions,
|
|
1029
|
+
eval_instructions(&mut stack, &out_row, &rw_expr.instructions, parameters)?;
|
|
1022
1030
|
let value: value::Value = stack.try_pop_into()?;
|
|
1023
1031
|
out_row.set(rw_expr.col_id, value.to_owned())?;
|
|
1024
1032
|
}
|
|
@@ -1036,7 +1044,7 @@ fn compute_return_with_table(
|
|
|
1036
1044
|
{
|
|
1037
1045
|
assert_eq!(rw_expr.aggregations.len(), 0);
|
|
1038
1046
|
let mut stack = Stack::default();
|
|
1039
|
-
eval_instructions(&mut stack, &out_row, &rw_expr.instructions,
|
|
1047
|
+
eval_instructions(&mut stack, &out_row, &rw_expr.instructions, parameters)?;
|
|
1040
1048
|
let value: value::Value = stack.try_pop_into()?;
|
|
1041
1049
|
out_row.set(rw_expr.col_id, value.to_owned())?;
|
|
1042
1050
|
}
|
|
@@ -1047,7 +1055,7 @@ fn compute_return_with_table(
|
|
|
1047
1055
|
// Apply filter
|
|
1048
1056
|
if !filter.is_empty()
|
|
1049
1057
|
{
|
|
1050
|
-
output_table = filter_rows(output_table.into_row_iter(),
|
|
1058
|
+
output_table = filter_rows(output_table.into_row_iter(), filter, parameters)?.try_into()?;
|
|
1051
1059
|
}
|
|
1052
1060
|
// Apply modifiers
|
|
1053
1061
|
// Sort the table according to order_by
|
|
@@ -1060,7 +1068,7 @@ fn compute_return_with_table(
|
|
|
1060
1068
|
for info in modifiers.order_by.iter()
|
|
1061
1069
|
{
|
|
1062
1070
|
let mut stack = Stack::default();
|
|
1063
|
-
eval_instructions(&mut stack, &x, &info.instructions,
|
|
1071
|
+
eval_instructions(&mut stack, &x, &info.instructions, parameters)?;
|
|
1064
1072
|
v.push((stack.try_pop_into()?, info.asc));
|
|
1065
1073
|
}
|
|
1066
1074
|
Ok((x, v))
|
|
@@ -1083,7 +1091,7 @@ fn compute_return_with_table(
|
|
|
1083
1091
|
if let Some(skip) = &modifiers.skip
|
|
1084
1092
|
{
|
|
1085
1093
|
let mut stack = Stack::default();
|
|
1086
|
-
eval_instructions(&mut stack, &value_table::Row::default(),
|
|
1094
|
+
eval_instructions(&mut stack, &value_table::Row::default(), skip, parameters)?;
|
|
1087
1095
|
let q: i64 = stack
|
|
1088
1096
|
.try_pop_into()
|
|
1089
1097
|
.map_err(|_| RunTimeError::InvalidArgumentType)?;
|
|
@@ -1101,12 +1109,7 @@ fn compute_return_with_table(
|
|
|
1101
1109
|
if let Some(limit) = &modifiers.limit
|
|
1102
1110
|
{
|
|
1103
1111
|
let mut stack = Stack::default();
|
|
1104
|
-
eval_instructions(
|
|
1105
|
-
&mut stack,
|
|
1106
|
-
&value_table::Row::default(),
|
|
1107
|
-
&limit,
|
|
1108
|
-
¶meters,
|
|
1109
|
-
)?;
|
|
1112
|
+
eval_instructions(&mut stack, &value_table::Row::default(), limit, parameters)?;
|
|
1110
1113
|
let q: i64 = stack
|
|
1111
1114
|
.try_pop_into()
|
|
1112
1115
|
.map_err(|_| RunTimeError::InvalidArgumentType)?;
|
|
@@ -1131,7 +1134,7 @@ fn compute_return_with_table(
|
|
|
1131
1134
|
0,
|
|
1132
1135
|
))
|
|
1133
1136
|
})
|
|
1134
|
-
.map(
|
|
1137
|
+
.map(value_table::RowResult)
|
|
1135
1138
|
.collect()
|
|
1136
1139
|
}
|
|
1137
1140
|
|
|
@@ -1145,7 +1148,7 @@ fn filter_rows(
|
|
|
1145
1148
|
.filter_map(|row| {
|
|
1146
1149
|
let res: Result<bool> = (|| {
|
|
1147
1150
|
let mut stack = Stack::default();
|
|
1148
|
-
eval_instructions(&mut stack, &row,
|
|
1151
|
+
eval_instructions(&mut stack, &row, filter, parameters)?;
|
|
1149
1152
|
stack.try_pop_as_boolean()
|
|
1150
1153
|
})();
|
|
1151
1154
|
match res
|
|
@@ -1172,7 +1175,7 @@ fn is_write_program(program: &super::Program) -> bool
|
|
|
1172
1175
|
program.iter().any(|b| match b
|
|
1173
1176
|
{
|
|
1174
1177
|
Block::UseGraph { .. }
|
|
1175
|
-
| Block::
|
|
1178
|
+
| Block::Match { .. }
|
|
1176
1179
|
| Block::Return { .. }
|
|
1177
1180
|
| Block::Unwind { .. }
|
|
1178
1181
|
| Block::Call { .. }
|
|
@@ -1185,12 +1188,11 @@ fn is_write_program(program: &super::Program) -> bool
|
|
|
1185
1188
|
})
|
|
1186
1189
|
}
|
|
1187
1190
|
|
|
1188
|
-
///
|
|
1189
1191
|
pub(crate) fn eval_program<TStore: store::Store>(
|
|
1190
1192
|
store: &TStore,
|
|
1191
1193
|
program: &super::Program,
|
|
1192
1194
|
parameters: &crate::value::ValueMap,
|
|
1193
|
-
) -> crate::Result<
|
|
1195
|
+
) -> crate::Result<query_result::QueryResult>
|
|
1194
1196
|
{
|
|
1195
1197
|
let mut graph_name: String = "default".into();
|
|
1196
1198
|
let mut input_table = value_table::ValueTable::new(0);
|
|
@@ -1254,7 +1256,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1254
1256
|
let mut new_row = row.extended(variables_size.total_size())?;
|
|
1255
1257
|
for action in actions.iter()
|
|
1256
1258
|
{
|
|
1257
|
-
eval_instructions(&mut stack, &new_row, &action.instructions,
|
|
1259
|
+
eval_instructions(&mut stack, &new_row, &action.instructions, parameters)?;
|
|
1258
1260
|
for (v, var) in stack
|
|
1259
1261
|
.try_drain_into(action.variables.len())?
|
|
1260
1262
|
.into_iter()
|
|
@@ -1264,18 +1266,18 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1264
1266
|
{
|
|
1265
1267
|
crate::value::Value::Node(n) =>
|
|
1266
1268
|
{
|
|
1267
|
-
store.create_nodes(&mut tx, &graph_name, vec![n
|
|
1269
|
+
store.create_nodes(&mut tx, &graph_name, vec![&n])?;
|
|
1268
1270
|
if let Some(var) = var
|
|
1269
1271
|
{
|
|
1270
1272
|
new_row.set_if_unset(*var, crate::value::Value::Node(n))?;
|
|
1271
1273
|
}
|
|
1272
1274
|
}
|
|
1273
|
-
crate::value::Value::
|
|
1275
|
+
crate::value::Value::Path(p) =>
|
|
1274
1276
|
{
|
|
1275
|
-
store.create_edges(&mut tx, &graph_name, vec![
|
|
1277
|
+
store.create_edges(&mut tx, &graph_name, vec![&p])?;
|
|
1276
1278
|
if let Some(var) = var
|
|
1277
1279
|
{
|
|
1278
|
-
new_row.set(*var, crate::value::Value::Edge(
|
|
1280
|
+
new_row.set(*var, crate::value::Value::Edge(p.into()))?;
|
|
1279
1281
|
}
|
|
1280
1282
|
}
|
|
1281
1283
|
_ =>
|
|
@@ -1289,7 +1291,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1289
1291
|
}
|
|
1290
1292
|
input_table = output_table;
|
|
1291
1293
|
}
|
|
1292
|
-
instructions::Block::
|
|
1294
|
+
instructions::Block::Match {
|
|
1293
1295
|
blocks,
|
|
1294
1296
|
filter,
|
|
1295
1297
|
optional,
|
|
@@ -1313,21 +1315,16 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1313
1315
|
filter,
|
|
1314
1316
|
} =>
|
|
1315
1317
|
{
|
|
1316
|
-
eval_instructions(&mut stack, &row,
|
|
1318
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1317
1319
|
let query: store::SelectNodeQuery = stack.try_pop_into()?;
|
|
1318
1320
|
let nodes = store.select_nodes(&mut tx, &graph_name, query)?;
|
|
1319
1321
|
|
|
1320
|
-
for node in nodes.
|
|
1322
|
+
for node in nodes.into_iter()
|
|
1321
1323
|
{
|
|
1322
1324
|
let mut new_row = row.clone();
|
|
1323
|
-
|
|
1325
|
+
if let Some(variable) = variable
|
|
1324
1326
|
{
|
|
1325
|
-
|
|
1326
|
-
{
|
|
1327
|
-
new_row.set_if_unset(*variable, node.to_owned().into())?;
|
|
1328
|
-
}
|
|
1329
|
-
None =>
|
|
1330
|
-
{}
|
|
1327
|
+
new_row.set_if_unset(*variable, node.to_owned().into())?;
|
|
1331
1328
|
}
|
|
1332
1329
|
let should_add_row = if filter.is_empty()
|
|
1333
1330
|
{
|
|
@@ -1337,8 +1334,8 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1337
1334
|
{
|
|
1338
1335
|
let mut stack = Stack::default();
|
|
1339
1336
|
stack.push(true);
|
|
1340
|
-
stack.push(node
|
|
1341
|
-
eval_instructions(&mut stack, &new_row,
|
|
1337
|
+
stack.push(node);
|
|
1338
|
+
eval_instructions(&mut stack, &new_row, filter, parameters)?;
|
|
1342
1339
|
stack.try_pop()?; // Get rid of the edge
|
|
1343
1340
|
stack.try_pop_into()?
|
|
1344
1341
|
};
|
|
@@ -1358,54 +1355,37 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1358
1355
|
directivity,
|
|
1359
1356
|
} =>
|
|
1360
1357
|
{
|
|
1361
|
-
eval_instructions(&mut stack, &row,
|
|
1358
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1362
1359
|
let query = stack.try_pop_into()?;
|
|
1363
1360
|
|
|
1364
1361
|
let edges = store.select_edges(&mut tx, &graph_name, query, *directivity)?;
|
|
1365
1362
|
|
|
1366
|
-
for edge in edges.
|
|
1363
|
+
for edge in edges.into_iter()
|
|
1367
1364
|
{
|
|
1368
1365
|
let mut new_row = row.clone();
|
|
1366
|
+
let (left, right) = if edge.reversed
|
|
1367
|
+
{
|
|
1368
|
+
(edge.path.destination(), edge.path.source())
|
|
1369
|
+
}
|
|
1370
|
+
else
|
|
1371
|
+
{
|
|
1372
|
+
(edge.path.source(), edge.path.destination())
|
|
1373
|
+
};
|
|
1369
1374
|
if let Some(left_variable) = left_variable.to_owned()
|
|
1370
1375
|
{
|
|
1371
|
-
new_row.set(
|
|
1372
|
-
left_variable,
|
|
1373
|
-
if edge.reversed
|
|
1374
|
-
{
|
|
1375
|
-
edge.edge.destination.to_owned()
|
|
1376
|
-
}
|
|
1377
|
-
else
|
|
1378
|
-
{
|
|
1379
|
-
edge.edge.source.to_owned()
|
|
1380
|
-
}
|
|
1381
|
-
.into(),
|
|
1382
|
-
)?;
|
|
1376
|
+
new_row.set(left_variable, left.to_owned().into())?;
|
|
1383
1377
|
}
|
|
1384
1378
|
if let Some(right_variable) = right_variable.to_owned()
|
|
1385
1379
|
{
|
|
1386
|
-
new_row.set(
|
|
1387
|
-
right_variable,
|
|
1388
|
-
if edge.reversed
|
|
1389
|
-
{
|
|
1390
|
-
edge.edge.source.to_owned()
|
|
1391
|
-
}
|
|
1392
|
-
else
|
|
1393
|
-
{
|
|
1394
|
-
edge.edge.destination.to_owned()
|
|
1395
|
-
}
|
|
1396
|
-
.into(),
|
|
1397
|
-
)?;
|
|
1380
|
+
new_row.set(right_variable, right.to_owned().into())?;
|
|
1398
1381
|
}
|
|
1399
1382
|
if let Some(edge_variable) = edge_variable.to_owned()
|
|
1400
1383
|
{
|
|
1401
|
-
new_row.set(edge_variable, edge.
|
|
1384
|
+
new_row.set(edge_variable, edge.path.to_edge().into())?;
|
|
1402
1385
|
}
|
|
1403
1386
|
if let Some(path_variable) = path_variable.to_owned()
|
|
1404
1387
|
{
|
|
1405
|
-
new_row.set(
|
|
1406
|
-
path_variable,
|
|
1407
|
-
crate::value::Value::Path(edge.edge.to_owned().into()),
|
|
1408
|
-
)?;
|
|
1388
|
+
new_row.set(path_variable, edge.path.to_owned().into())?;
|
|
1409
1389
|
}
|
|
1410
1390
|
let should_add_row = if filter.is_empty()
|
|
1411
1391
|
{
|
|
@@ -1415,8 +1395,8 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1415
1395
|
{
|
|
1416
1396
|
let mut stack = Stack::default();
|
|
1417
1397
|
stack.push(true);
|
|
1418
|
-
stack.push(edge.
|
|
1419
|
-
eval_instructions(&mut stack, &new_row,
|
|
1398
|
+
stack.push(edge.path.into_edge());
|
|
1399
|
+
eval_instructions(&mut stack, &new_row, filter, parameters)?;
|
|
1420
1400
|
stack.try_pop()?; // Get rid of the edge
|
|
1421
1401
|
stack.try_pop_into()?
|
|
1422
1402
|
};
|
|
@@ -1432,7 +1412,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1432
1412
|
}
|
|
1433
1413
|
if !filter.is_empty()
|
|
1434
1414
|
{
|
|
1435
|
-
current_rows = filter_rows(current_rows.into_iter(),
|
|
1415
|
+
current_rows = filter_rows(current_rows.into_iter(), filter, parameters)?;
|
|
1436
1416
|
}
|
|
1437
1417
|
if current_rows.is_empty() && *optional
|
|
1438
1418
|
{
|
|
@@ -1452,29 +1432,23 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1452
1432
|
variables_size,
|
|
1453
1433
|
} =>
|
|
1454
1434
|
{
|
|
1455
|
-
let (names, variables): (Vec<_>, Vec<_>) =
|
|
1456
|
-
variables.into_iter().map(|(s, e)| (s, e)).unzip();
|
|
1435
|
+
let (names, variables): (Vec<_>, Vec<_>) = variables.iter().map(|(s, e)| (s, e)).unzip();
|
|
1457
1436
|
let output_table = compute_return_with_table(
|
|
1458
1437
|
variables,
|
|
1459
|
-
|
|
1460
|
-
|
|
1438
|
+
filter,
|
|
1439
|
+
modifiers,
|
|
1461
1440
|
input_table,
|
|
1462
|
-
|
|
1463
|
-
|
|
1441
|
+
parameters,
|
|
1442
|
+
variables_size,
|
|
1464
1443
|
)?;
|
|
1465
|
-
let
|
|
1466
|
-
|
|
1467
|
-
names
|
|
1468
|
-
.into_iter()
|
|
1469
|
-
.map(|name| crate::value::Value::String(name.to_owned()))
|
|
1470
|
-
.collect(),
|
|
1471
|
-
));
|
|
1444
|
+
let headers = names.into_iter().map(|name| name.to_owned()).collect();
|
|
1445
|
+
let mut data = Vec::<crate::value::Value>::new();
|
|
1472
1446
|
for row in output_table.into_row_iter()
|
|
1473
1447
|
{
|
|
1474
|
-
|
|
1448
|
+
data.extend(row.into_iter());
|
|
1475
1449
|
}
|
|
1476
1450
|
tx.close()?;
|
|
1477
|
-
return Ok(
|
|
1451
|
+
return Ok(graphcore::Table::new(headers, data)?.into());
|
|
1478
1452
|
}
|
|
1479
1453
|
instructions::Block::With {
|
|
1480
1454
|
variables,
|
|
@@ -1485,11 +1459,11 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1485
1459
|
{
|
|
1486
1460
|
input_table = compute_return_with_table(
|
|
1487
1461
|
variables.iter().collect(),
|
|
1488
|
-
|
|
1489
|
-
|
|
1462
|
+
filter,
|
|
1463
|
+
modifiers,
|
|
1490
1464
|
input_table,
|
|
1491
|
-
|
|
1492
|
-
|
|
1465
|
+
parameters,
|
|
1466
|
+
variables_size,
|
|
1493
1467
|
)?;
|
|
1494
1468
|
}
|
|
1495
1469
|
instructions::Block::Unwind {
|
|
@@ -1502,7 +1476,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1502
1476
|
for row in input_table.into_row_iter()
|
|
1503
1477
|
{
|
|
1504
1478
|
let mut stack = Stack::default();
|
|
1505
|
-
eval_instructions(&mut stack, &row,
|
|
1479
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1506
1480
|
let value = stack.try_pop_into()?;
|
|
1507
1481
|
match value
|
|
1508
1482
|
{
|
|
@@ -1539,12 +1513,12 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1539
1513
|
for instructions in instructions.iter()
|
|
1540
1514
|
{
|
|
1541
1515
|
let mut stack = Stack::default();
|
|
1542
|
-
eval_instructions(&mut stack, &row,
|
|
1516
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1543
1517
|
let value: value::Value = stack.try_pop_into()?;
|
|
1544
1518
|
match value
|
|
1545
1519
|
{
|
|
1546
|
-
value::Value::Node(node) => nodes_keys.push(node.
|
|
1547
|
-
value::Value::Edge(edge) => edges_keys.push(edge.
|
|
1520
|
+
value::Value::Node(node) => nodes_keys.push(node.unpack().0),
|
|
1521
|
+
value::Value::Edge(edge) => edges_keys.push(edge.unpack().0),
|
|
1548
1522
|
value::Value::Null =>
|
|
1549
1523
|
{}
|
|
1550
1524
|
_ => return Err(RunTimeError::InvalidDelete.into()),
|
|
@@ -1592,7 +1566,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1592
1566
|
*target,
|
|
1593
1567
|
path,
|
|
1594
1568
|
instructions,
|
|
1595
|
-
|
|
1569
|
+
parameters,
|
|
1596
1570
|
true,
|
|
1597
1571
|
)?;
|
|
1598
1572
|
}
|
|
@@ -1610,7 +1584,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1610
1584
|
*target,
|
|
1611
1585
|
path,
|
|
1612
1586
|
instructions,
|
|
1613
|
-
|
|
1587
|
+
parameters,
|
|
1614
1588
|
false,
|
|
1615
1589
|
)?;
|
|
1616
1590
|
}
|
|
@@ -1623,14 +1597,14 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1623
1597
|
value::Value::Node(n) =>
|
|
1624
1598
|
{
|
|
1625
1599
|
let mut n = n.to_owned();
|
|
1626
|
-
n.
|
|
1600
|
+
n.properties_mut().remove_value(piter.next(), piter)?;
|
|
1627
1601
|
store.update_node(&mut tx, &graph_name, &n)?;
|
|
1628
1602
|
out_row.set(*target, n.into())?;
|
|
1629
1603
|
}
|
|
1630
1604
|
value::Value::Edge(e) =>
|
|
1631
1605
|
{
|
|
1632
1606
|
let mut e = e.to_owned();
|
|
1633
|
-
e.
|
|
1607
|
+
e.properties_mut().remove_value(piter.next(), piter)?;
|
|
1634
1608
|
store.update_edge(&mut tx, &graph_name, &e)?;
|
|
1635
1609
|
out_row.set(*target, e.into())?;
|
|
1636
1610
|
}
|
|
@@ -1661,15 +1635,11 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1661
1635
|
let mut n = n.to_owned();
|
|
1662
1636
|
if add_labels
|
|
1663
1637
|
{
|
|
1664
|
-
n.
|
|
1638
|
+
n.labels_mut().append(&mut labels.clone());
|
|
1665
1639
|
}
|
|
1666
1640
|
else
|
|
1667
1641
|
{
|
|
1668
|
-
n.
|
|
1669
|
-
.labels
|
|
1670
|
-
.into_iter()
|
|
1671
|
-
.filter(|x| !labels.contains(x))
|
|
1672
|
-
.collect();
|
|
1642
|
+
n.labels_edit(|l| l.into_iter().filter(|x| !labels.contains(x)).collect());
|
|
1673
1643
|
}
|
|
1674
1644
|
store.update_node(&mut tx, &graph_name, &n)?;
|
|
1675
1645
|
out_row.set(*target, n.into())?;
|
|
@@ -1679,15 +1649,11 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1679
1649
|
let mut e = e.to_owned();
|
|
1680
1650
|
if add_labels
|
|
1681
1651
|
{
|
|
1682
|
-
e.
|
|
1652
|
+
e.labels_mut().append(&mut labels.clone());
|
|
1683
1653
|
}
|
|
1684
1654
|
else
|
|
1685
1655
|
{
|
|
1686
|
-
e.
|
|
1687
|
-
.labels
|
|
1688
|
-
.into_iter()
|
|
1689
|
-
.filter(|x| !labels.contains(x))
|
|
1690
|
-
.collect();
|
|
1656
|
+
e.labels_edit(|l| l.into_iter().filter(|x| !labels.contains(x)).collect());
|
|
1691
1657
|
}
|
|
1692
1658
|
store.update_edge(&mut tx, &graph_name, &e)?;
|
|
1693
1659
|
out_row.set(*target, e.into())?;
|
|
@@ -1721,7 +1687,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1721
1687
|
"properties_count".into(),
|
|
1722
1688
|
(stats.properties_count as i64).into(),
|
|
1723
1689
|
);
|
|
1724
|
-
return Ok(crate::value::Value::Map(res));
|
|
1690
|
+
return Ok(crate::value::Value::Map(res).into());
|
|
1725
1691
|
}
|
|
1726
1692
|
else
|
|
1727
1693
|
{
|
|
@@ -1731,7 +1697,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1731
1697
|
}
|
|
1732
1698
|
}
|
|
1733
1699
|
tx.close()?;
|
|
1734
|
-
Ok(crate::
|
|
1700
|
+
Ok(crate::QueryResult::Empty)
|
|
1735
1701
|
}
|
|
1736
1702
|
|
|
1737
1703
|
#[cfg(test)]
|