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
|
@@ -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
|
|
|
@@ -940,22 +950,19 @@ fn compute_return_with_table(
|
|
|
940
950
|
for row in input_table.into_row_iter()
|
|
941
951
|
{
|
|
942
952
|
// a) compute non-aggregated columns
|
|
943
|
-
let mut row = row.extended(variables_sizes.total_size())?;
|
|
944
953
|
let out_row = variables
|
|
945
954
|
.iter()
|
|
946
955
|
.map(|rw_expr| {
|
|
947
|
-
if rw_expr.aggregations.
|
|
956
|
+
if rw_expr.aggregations.is_empty()
|
|
948
957
|
{
|
|
949
|
-
|
|
958
|
+
assert_eq!(rw_expr.aggregations.len(), 0);
|
|
959
|
+
let mut stack = Stack::default();
|
|
960
|
+
eval_instructions(&mut stack, &row, &rw_expr.instructions, parameters)?;
|
|
961
|
+
stack.try_pop_into()
|
|
950
962
|
}
|
|
951
963
|
else
|
|
952
964
|
{
|
|
953
|
-
|
|
954
|
-
let mut stack = Stack::default();
|
|
955
|
-
eval_instructions(&mut stack, &row, &rw_expr.instructions, ¶meters)?;
|
|
956
|
-
let value: value::Value = stack.try_pop_into()?;
|
|
957
|
-
row.set(rw_expr.col_id, value.to_owned())?;
|
|
958
|
-
Ok(value)
|
|
965
|
+
Ok(value::Value::Null)
|
|
959
966
|
}
|
|
960
967
|
})
|
|
961
968
|
.collect::<Result<Row>>()?;
|
|
@@ -987,7 +994,7 @@ fn compute_return_with_table(
|
|
|
987
994
|
}
|
|
988
995
|
|
|
989
996
|
// 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.
|
|
997
|
+
if aggregation_table.is_empty() && variables.iter().all(|v| !v.aggregations.is_empty())
|
|
991
998
|
{
|
|
992
999
|
let row = Row::new(Default::default(), variables_sizes.total_size());
|
|
993
1000
|
let aggregations_states = create_aggregations_states(&variables, parameters)?;
|
|
@@ -998,14 +1005,13 @@ fn compute_return_with_table(
|
|
|
998
1005
|
|
|
999
1006
|
for (row, aggregations_states) in aggregation_table
|
|
1000
1007
|
{
|
|
1001
|
-
let mut non_null_aggregation = false;
|
|
1002
1008
|
let mut out_row = value_table::Row::new(Default::default(), variables_sizes.total_size());
|
|
1003
1009
|
for (idx, (rw_expr, aggregation_states)) in variables
|
|
1004
1010
|
.iter()
|
|
1005
1011
|
.zip(aggregations_states.into_iter())
|
|
1006
1012
|
.enumerate()
|
|
1007
1013
|
{
|
|
1008
|
-
if rw_expr.aggregations.
|
|
1014
|
+
if rw_expr.aggregations.is_empty()
|
|
1009
1015
|
{
|
|
1010
1016
|
out_row.set(rw_expr.col_id, row.0.get(idx)?.to_owned())?;
|
|
1011
1017
|
}
|
|
@@ -1014,11 +1020,10 @@ fn compute_return_with_table(
|
|
|
1014
1020
|
for (name, s) in aggregation_states.into_iter()
|
|
1015
1021
|
{
|
|
1016
1022
|
let value = s.finalise()?;
|
|
1017
|
-
non_null_aggregation = non_null_aggregation | !value.is_null();
|
|
1018
1023
|
out_row.set(name, value)?;
|
|
1019
1024
|
}
|
|
1020
1025
|
let mut stack = Stack::default();
|
|
1021
|
-
eval_instructions(&mut stack, &out_row, &rw_expr.instructions,
|
|
1026
|
+
eval_instructions(&mut stack, &out_row, &rw_expr.instructions, parameters)?;
|
|
1022
1027
|
let value: value::Value = stack.try_pop_into()?;
|
|
1023
1028
|
out_row.set(rw_expr.col_id, value.to_owned())?;
|
|
1024
1029
|
}
|
|
@@ -1031,12 +1036,12 @@ fn compute_return_with_table(
|
|
|
1031
1036
|
output_table = input_table
|
|
1032
1037
|
.into_row_iter()
|
|
1033
1038
|
.map(|row| {
|
|
1034
|
-
let mut out_row = row.extended(variables_sizes.total_size())?;
|
|
1039
|
+
let mut out_row = row.clone().extended(variables_sizes.total_size())?;
|
|
1035
1040
|
for rw_expr in variables.iter()
|
|
1036
1041
|
{
|
|
1037
1042
|
assert_eq!(rw_expr.aggregations.len(), 0);
|
|
1038
1043
|
let mut stack = Stack::default();
|
|
1039
|
-
eval_instructions(&mut stack, &
|
|
1044
|
+
eval_instructions(&mut stack, &row, &rw_expr.instructions, parameters)?;
|
|
1040
1045
|
let value: value::Value = stack.try_pop_into()?;
|
|
1041
1046
|
out_row.set(rw_expr.col_id, value.to_owned())?;
|
|
1042
1047
|
}
|
|
@@ -1047,7 +1052,7 @@ fn compute_return_with_table(
|
|
|
1047
1052
|
// Apply filter
|
|
1048
1053
|
if !filter.is_empty()
|
|
1049
1054
|
{
|
|
1050
|
-
output_table = filter_rows(output_table.into_row_iter(),
|
|
1055
|
+
output_table = filter_rows(output_table.into_row_iter(), filter, parameters)?.try_into()?;
|
|
1051
1056
|
}
|
|
1052
1057
|
// Apply modifiers
|
|
1053
1058
|
// Sort the table according to order_by
|
|
@@ -1060,7 +1065,7 @@ fn compute_return_with_table(
|
|
|
1060
1065
|
for info in modifiers.order_by.iter()
|
|
1061
1066
|
{
|
|
1062
1067
|
let mut stack = Stack::default();
|
|
1063
|
-
eval_instructions(&mut stack, &x, &info.instructions,
|
|
1068
|
+
eval_instructions(&mut stack, &x, &info.instructions, parameters)?;
|
|
1064
1069
|
v.push((stack.try_pop_into()?, info.asc));
|
|
1065
1070
|
}
|
|
1066
1071
|
Ok((x, v))
|
|
@@ -1083,7 +1088,7 @@ fn compute_return_with_table(
|
|
|
1083
1088
|
if let Some(skip) = &modifiers.skip
|
|
1084
1089
|
{
|
|
1085
1090
|
let mut stack = Stack::default();
|
|
1086
|
-
eval_instructions(&mut stack, &value_table::Row::default(),
|
|
1091
|
+
eval_instructions(&mut stack, &value_table::Row::default(), skip, parameters)?;
|
|
1087
1092
|
let q: i64 = stack
|
|
1088
1093
|
.try_pop_into()
|
|
1089
1094
|
.map_err(|_| RunTimeError::InvalidArgumentType)?;
|
|
@@ -1101,12 +1106,7 @@ fn compute_return_with_table(
|
|
|
1101
1106
|
if let Some(limit) = &modifiers.limit
|
|
1102
1107
|
{
|
|
1103
1108
|
let mut stack = Stack::default();
|
|
1104
|
-
eval_instructions(
|
|
1105
|
-
&mut stack,
|
|
1106
|
-
&value_table::Row::default(),
|
|
1107
|
-
&limit,
|
|
1108
|
-
¶meters,
|
|
1109
|
-
)?;
|
|
1109
|
+
eval_instructions(&mut stack, &value_table::Row::default(), limit, parameters)?;
|
|
1110
1110
|
let q: i64 = stack
|
|
1111
1111
|
.try_pop_into()
|
|
1112
1112
|
.map_err(|_| RunTimeError::InvalidArgumentType)?;
|
|
@@ -1131,7 +1131,7 @@ fn compute_return_with_table(
|
|
|
1131
1131
|
0,
|
|
1132
1132
|
))
|
|
1133
1133
|
})
|
|
1134
|
-
.map(
|
|
1134
|
+
.map(value_table::RowResult)
|
|
1135
1135
|
.collect()
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
@@ -1145,7 +1145,7 @@ fn filter_rows(
|
|
|
1145
1145
|
.filter_map(|row| {
|
|
1146
1146
|
let res: Result<bool> = (|| {
|
|
1147
1147
|
let mut stack = Stack::default();
|
|
1148
|
-
eval_instructions(&mut stack, &row,
|
|
1148
|
+
eval_instructions(&mut stack, &row, filter, parameters)?;
|
|
1149
1149
|
stack.try_pop_as_boolean()
|
|
1150
1150
|
})();
|
|
1151
1151
|
match res
|
|
@@ -1172,7 +1172,7 @@ fn is_write_program(program: &super::Program) -> bool
|
|
|
1172
1172
|
program.iter().any(|b| match b
|
|
1173
1173
|
{
|
|
1174
1174
|
Block::UseGraph { .. }
|
|
1175
|
-
| Block::
|
|
1175
|
+
| Block::Match { .. }
|
|
1176
1176
|
| Block::Return { .. }
|
|
1177
1177
|
| Block::Unwind { .. }
|
|
1178
1178
|
| Block::Call { .. }
|
|
@@ -1185,12 +1185,11 @@ fn is_write_program(program: &super::Program) -> bool
|
|
|
1185
1185
|
})
|
|
1186
1186
|
}
|
|
1187
1187
|
|
|
1188
|
-
///
|
|
1189
1188
|
pub(crate) fn eval_program<TStore: store::Store>(
|
|
1190
1189
|
store: &TStore,
|
|
1191
1190
|
program: &super::Program,
|
|
1192
1191
|
parameters: &crate::value::ValueMap,
|
|
1193
|
-
) -> crate::Result<
|
|
1192
|
+
) -> crate::Result<query_result::QueryResult>
|
|
1194
1193
|
{
|
|
1195
1194
|
let mut graph_name: String = "default".into();
|
|
1196
1195
|
let mut input_table = value_table::ValueTable::new(0);
|
|
@@ -1254,7 +1253,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1254
1253
|
let mut new_row = row.extended(variables_size.total_size())?;
|
|
1255
1254
|
for action in actions.iter()
|
|
1256
1255
|
{
|
|
1257
|
-
eval_instructions(&mut stack, &new_row, &action.instructions,
|
|
1256
|
+
eval_instructions(&mut stack, &new_row, &action.instructions, parameters)?;
|
|
1258
1257
|
for (v, var) in stack
|
|
1259
1258
|
.try_drain_into(action.variables.len())?
|
|
1260
1259
|
.into_iter()
|
|
@@ -1264,18 +1263,18 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1264
1263
|
{
|
|
1265
1264
|
crate::value::Value::Node(n) =>
|
|
1266
1265
|
{
|
|
1267
|
-
store.create_nodes(&mut tx, &graph_name, vec![n
|
|
1266
|
+
store.create_nodes(&mut tx, &graph_name, vec![&n])?;
|
|
1268
1267
|
if let Some(var) = var
|
|
1269
1268
|
{
|
|
1270
1269
|
new_row.set_if_unset(*var, crate::value::Value::Node(n))?;
|
|
1271
1270
|
}
|
|
1272
1271
|
}
|
|
1273
|
-
crate::value::Value::
|
|
1272
|
+
crate::value::Value::Path(p) =>
|
|
1274
1273
|
{
|
|
1275
|
-
store.create_edges(&mut tx, &graph_name, vec![
|
|
1274
|
+
store.create_edges(&mut tx, &graph_name, vec![&p])?;
|
|
1276
1275
|
if let Some(var) = var
|
|
1277
1276
|
{
|
|
1278
|
-
new_row.set(*var, crate::value::Value::Edge(
|
|
1277
|
+
new_row.set(*var, crate::value::Value::Edge(p.into()))?;
|
|
1279
1278
|
}
|
|
1280
1279
|
}
|
|
1281
1280
|
_ =>
|
|
@@ -1289,7 +1288,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1289
1288
|
}
|
|
1290
1289
|
input_table = output_table;
|
|
1291
1290
|
}
|
|
1292
|
-
instructions::Block::
|
|
1291
|
+
instructions::Block::Match {
|
|
1293
1292
|
blocks,
|
|
1294
1293
|
filter,
|
|
1295
1294
|
optional,
|
|
@@ -1313,21 +1312,16 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1313
1312
|
filter,
|
|
1314
1313
|
} =>
|
|
1315
1314
|
{
|
|
1316
|
-
eval_instructions(&mut stack, &row,
|
|
1315
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1317
1316
|
let query: store::SelectNodeQuery = stack.try_pop_into()?;
|
|
1318
1317
|
let nodes = store.select_nodes(&mut tx, &graph_name, query)?;
|
|
1319
1318
|
|
|
1320
|
-
for node in nodes.
|
|
1319
|
+
for node in nodes.into_iter()
|
|
1321
1320
|
{
|
|
1322
1321
|
let mut new_row = row.clone();
|
|
1323
|
-
|
|
1322
|
+
if let Some(variable) = variable
|
|
1324
1323
|
{
|
|
1325
|
-
|
|
1326
|
-
{
|
|
1327
|
-
new_row.set_if_unset(*variable, node.to_owned().into())?;
|
|
1328
|
-
}
|
|
1329
|
-
None =>
|
|
1330
|
-
{}
|
|
1324
|
+
new_row.set_if_unset(*variable, node.to_owned().into())?;
|
|
1331
1325
|
}
|
|
1332
1326
|
let should_add_row = if filter.is_empty()
|
|
1333
1327
|
{
|
|
@@ -1337,8 +1331,8 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1337
1331
|
{
|
|
1338
1332
|
let mut stack = Stack::default();
|
|
1339
1333
|
stack.push(true);
|
|
1340
|
-
stack.push(node
|
|
1341
|
-
eval_instructions(&mut stack, &new_row,
|
|
1334
|
+
stack.push(node);
|
|
1335
|
+
eval_instructions(&mut stack, &new_row, filter, parameters)?;
|
|
1342
1336
|
stack.try_pop()?; // Get rid of the edge
|
|
1343
1337
|
stack.try_pop_into()?
|
|
1344
1338
|
};
|
|
@@ -1358,54 +1352,37 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1358
1352
|
directivity,
|
|
1359
1353
|
} =>
|
|
1360
1354
|
{
|
|
1361
|
-
eval_instructions(&mut stack, &row,
|
|
1355
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1362
1356
|
let query = stack.try_pop_into()?;
|
|
1363
1357
|
|
|
1364
1358
|
let edges = store.select_edges(&mut tx, &graph_name, query, *directivity)?;
|
|
1365
1359
|
|
|
1366
|
-
for edge in edges.
|
|
1360
|
+
for edge in edges.into_iter()
|
|
1367
1361
|
{
|
|
1368
1362
|
let mut new_row = row.clone();
|
|
1363
|
+
let (left, right) = if edge.reversed
|
|
1364
|
+
{
|
|
1365
|
+
(edge.path.destination(), edge.path.source())
|
|
1366
|
+
}
|
|
1367
|
+
else
|
|
1368
|
+
{
|
|
1369
|
+
(edge.path.source(), edge.path.destination())
|
|
1370
|
+
};
|
|
1369
1371
|
if let Some(left_variable) = left_variable.to_owned()
|
|
1370
1372
|
{
|
|
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
|
-
)?;
|
|
1373
|
+
new_row.set(left_variable, left.to_owned().into())?;
|
|
1383
1374
|
}
|
|
1384
1375
|
if let Some(right_variable) = right_variable.to_owned()
|
|
1385
1376
|
{
|
|
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
|
-
)?;
|
|
1377
|
+
new_row.set(right_variable, right.to_owned().into())?;
|
|
1398
1378
|
}
|
|
1399
1379
|
if let Some(edge_variable) = edge_variable.to_owned()
|
|
1400
1380
|
{
|
|
1401
|
-
new_row.set(edge_variable, edge.
|
|
1381
|
+
new_row.set(edge_variable, edge.path.to_edge().into())?;
|
|
1402
1382
|
}
|
|
1403
1383
|
if let Some(path_variable) = path_variable.to_owned()
|
|
1404
1384
|
{
|
|
1405
|
-
new_row.set(
|
|
1406
|
-
path_variable,
|
|
1407
|
-
crate::value::Value::Path(edge.edge.to_owned().into()),
|
|
1408
|
-
)?;
|
|
1385
|
+
new_row.set(path_variable, edge.path.to_owned().into())?;
|
|
1409
1386
|
}
|
|
1410
1387
|
let should_add_row = if filter.is_empty()
|
|
1411
1388
|
{
|
|
@@ -1415,8 +1392,8 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1415
1392
|
{
|
|
1416
1393
|
let mut stack = Stack::default();
|
|
1417
1394
|
stack.push(true);
|
|
1418
|
-
stack.push(edge.
|
|
1419
|
-
eval_instructions(&mut stack, &new_row,
|
|
1395
|
+
stack.push(edge.path.into_edge());
|
|
1396
|
+
eval_instructions(&mut stack, &new_row, filter, parameters)?;
|
|
1420
1397
|
stack.try_pop()?; // Get rid of the edge
|
|
1421
1398
|
stack.try_pop_into()?
|
|
1422
1399
|
};
|
|
@@ -1432,7 +1409,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1432
1409
|
}
|
|
1433
1410
|
if !filter.is_empty()
|
|
1434
1411
|
{
|
|
1435
|
-
current_rows = filter_rows(current_rows.into_iter(),
|
|
1412
|
+
current_rows = filter_rows(current_rows.into_iter(), filter, parameters)?;
|
|
1436
1413
|
}
|
|
1437
1414
|
if current_rows.is_empty() && *optional
|
|
1438
1415
|
{
|
|
@@ -1449,47 +1426,41 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1449
1426
|
variables,
|
|
1450
1427
|
filter,
|
|
1451
1428
|
modifiers,
|
|
1452
|
-
variables_size,
|
|
1429
|
+
variables_sizes: variables_size,
|
|
1453
1430
|
} =>
|
|
1454
1431
|
{
|
|
1455
|
-
let (names, variables): (Vec<_>, Vec<_>) =
|
|
1456
|
-
variables.into_iter().map(|(s, e)| (s, e)).unzip();
|
|
1432
|
+
let (names, variables): (Vec<_>, Vec<_>) = variables.iter().map(|(s, e)| (s, e)).unzip();
|
|
1457
1433
|
let output_table = compute_return_with_table(
|
|
1458
1434
|
variables,
|
|
1459
|
-
|
|
1460
|
-
|
|
1435
|
+
filter,
|
|
1436
|
+
modifiers,
|
|
1461
1437
|
input_table,
|
|
1462
|
-
|
|
1463
|
-
|
|
1438
|
+
parameters,
|
|
1439
|
+
variables_size,
|
|
1464
1440
|
)?;
|
|
1465
|
-
let
|
|
1466
|
-
|
|
1467
|
-
names
|
|
1468
|
-
.into_iter()
|
|
1469
|
-
.map(|name| crate::value::Value::String(name.to_owned()))
|
|
1470
|
-
.collect(),
|
|
1471
|
-
));
|
|
1441
|
+
let headers = names.into_iter().map(|name| name.to_owned()).collect();
|
|
1442
|
+
let mut data = Vec::<crate::value::Value>::new();
|
|
1472
1443
|
for row in output_table.into_row_iter()
|
|
1473
1444
|
{
|
|
1474
|
-
|
|
1445
|
+
data.extend(row.into_iter());
|
|
1475
1446
|
}
|
|
1476
1447
|
tx.close()?;
|
|
1477
|
-
return Ok(
|
|
1448
|
+
return Ok(graphcore::Table::new(headers, data)?.into());
|
|
1478
1449
|
}
|
|
1479
1450
|
instructions::Block::With {
|
|
1480
1451
|
variables,
|
|
1481
1452
|
filter,
|
|
1482
1453
|
modifiers,
|
|
1483
|
-
variables_size,
|
|
1454
|
+
variables_sizes: variables_size,
|
|
1484
1455
|
} =>
|
|
1485
1456
|
{
|
|
1486
1457
|
input_table = compute_return_with_table(
|
|
1487
1458
|
variables.iter().collect(),
|
|
1488
|
-
|
|
1489
|
-
|
|
1459
|
+
filter,
|
|
1460
|
+
modifiers,
|
|
1490
1461
|
input_table,
|
|
1491
|
-
|
|
1492
|
-
|
|
1462
|
+
parameters,
|
|
1463
|
+
variables_size,
|
|
1493
1464
|
)?;
|
|
1494
1465
|
}
|
|
1495
1466
|
instructions::Block::Unwind {
|
|
@@ -1502,7 +1473,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1502
1473
|
for row in input_table.into_row_iter()
|
|
1503
1474
|
{
|
|
1504
1475
|
let mut stack = Stack::default();
|
|
1505
|
-
eval_instructions(&mut stack, &row,
|
|
1476
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1506
1477
|
let value = stack.try_pop_into()?;
|
|
1507
1478
|
match value
|
|
1508
1479
|
{
|
|
@@ -1539,12 +1510,12 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1539
1510
|
for instructions in instructions.iter()
|
|
1540
1511
|
{
|
|
1541
1512
|
let mut stack = Stack::default();
|
|
1542
|
-
eval_instructions(&mut stack, &row,
|
|
1513
|
+
eval_instructions(&mut stack, &row, instructions, parameters)?;
|
|
1543
1514
|
let value: value::Value = stack.try_pop_into()?;
|
|
1544
1515
|
match value
|
|
1545
1516
|
{
|
|
1546
|
-
value::Value::Node(node) => nodes_keys.push(node.
|
|
1547
|
-
value::Value::Edge(edge) => edges_keys.push(edge.
|
|
1517
|
+
value::Value::Node(node) => nodes_keys.push(node.unpack().0),
|
|
1518
|
+
value::Value::Edge(edge) => edges_keys.push(edge.unpack().0),
|
|
1548
1519
|
value::Value::Null =>
|
|
1549
1520
|
{}
|
|
1550
1521
|
_ => return Err(RunTimeError::InvalidDelete.into()),
|
|
@@ -1592,7 +1563,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1592
1563
|
*target,
|
|
1593
1564
|
path,
|
|
1594
1565
|
instructions,
|
|
1595
|
-
|
|
1566
|
+
parameters,
|
|
1596
1567
|
true,
|
|
1597
1568
|
)?;
|
|
1598
1569
|
}
|
|
@@ -1610,7 +1581,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1610
1581
|
*target,
|
|
1611
1582
|
path,
|
|
1612
1583
|
instructions,
|
|
1613
|
-
|
|
1584
|
+
parameters,
|
|
1614
1585
|
false,
|
|
1615
1586
|
)?;
|
|
1616
1587
|
}
|
|
@@ -1623,14 +1594,14 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1623
1594
|
value::Value::Node(n) =>
|
|
1624
1595
|
{
|
|
1625
1596
|
let mut n = n.to_owned();
|
|
1626
|
-
n.
|
|
1597
|
+
n.properties_mut().remove_value(piter.next(), piter)?;
|
|
1627
1598
|
store.update_node(&mut tx, &graph_name, &n)?;
|
|
1628
1599
|
out_row.set(*target, n.into())?;
|
|
1629
1600
|
}
|
|
1630
1601
|
value::Value::Edge(e) =>
|
|
1631
1602
|
{
|
|
1632
1603
|
let mut e = e.to_owned();
|
|
1633
|
-
e.
|
|
1604
|
+
e.properties_mut().remove_value(piter.next(), piter)?;
|
|
1634
1605
|
store.update_edge(&mut tx, &graph_name, &e)?;
|
|
1635
1606
|
out_row.set(*target, e.into())?;
|
|
1636
1607
|
}
|
|
@@ -1661,15 +1632,11 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1661
1632
|
let mut n = n.to_owned();
|
|
1662
1633
|
if add_labels
|
|
1663
1634
|
{
|
|
1664
|
-
n.
|
|
1635
|
+
n.labels_mut().append(&mut labels.clone());
|
|
1665
1636
|
}
|
|
1666
1637
|
else
|
|
1667
1638
|
{
|
|
1668
|
-
n.
|
|
1669
|
-
.labels
|
|
1670
|
-
.into_iter()
|
|
1671
|
-
.filter(|x| !labels.contains(x))
|
|
1672
|
-
.collect();
|
|
1639
|
+
n.labels_edit(|l| l.into_iter().filter(|x| !labels.contains(x)).collect());
|
|
1673
1640
|
}
|
|
1674
1641
|
store.update_node(&mut tx, &graph_name, &n)?;
|
|
1675
1642
|
out_row.set(*target, n.into())?;
|
|
@@ -1679,15 +1646,11 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1679
1646
|
let mut e = e.to_owned();
|
|
1680
1647
|
if add_labels
|
|
1681
1648
|
{
|
|
1682
|
-
e.
|
|
1649
|
+
e.labels_mut().append(&mut labels.clone());
|
|
1683
1650
|
}
|
|
1684
1651
|
else
|
|
1685
1652
|
{
|
|
1686
|
-
e.
|
|
1687
|
-
.labels
|
|
1688
|
-
.into_iter()
|
|
1689
|
-
.filter(|x| !labels.contains(x))
|
|
1690
|
-
.collect();
|
|
1653
|
+
e.labels_edit(|l| l.into_iter().filter(|x| !labels.contains(x)).collect());
|
|
1691
1654
|
}
|
|
1692
1655
|
store.update_edge(&mut tx, &graph_name, &e)?;
|
|
1693
1656
|
out_row.set(*target, e.into())?;
|
|
@@ -1721,7 +1684,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1721
1684
|
"properties_count".into(),
|
|
1722
1685
|
(stats.properties_count as i64).into(),
|
|
1723
1686
|
);
|
|
1724
|
-
return Ok(crate::value::Value::Map(res));
|
|
1687
|
+
return Ok(crate::value::Value::Map(res).into());
|
|
1725
1688
|
}
|
|
1726
1689
|
else
|
|
1727
1690
|
{
|
|
@@ -1731,7 +1694,7 @@ pub(crate) fn eval_program<TStore: store::Store>(
|
|
|
1731
1694
|
}
|
|
1732
1695
|
}
|
|
1733
1696
|
tx.close()?;
|
|
1734
|
-
Ok(crate::
|
|
1697
|
+
Ok(crate::QueryResult::Empty)
|
|
1735
1698
|
}
|
|
1736
1699
|
|
|
1737
1700
|
#[cfg(test)]
|