gqlite 1.5.1 → 1.8.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 +10 -4
- data/ext/db-index/Cargo.toml +29 -0
- data/ext/db-index/src/hnsw/error.rs +66 -0
- data/ext/db-index/src/hnsw/graph_store.rs +272 -0
- data/ext/db-index/src/hnsw/id.rs +36 -0
- data/ext/db-index/src/hnsw/implementation.rs +1517 -0
- data/ext/db-index/src/hnsw/kernels.rs +1228 -0
- data/ext/db-index/src/hnsw/metric.rs +244 -0
- data/ext/db-index/src/hnsw/scalar.rs +72 -0
- data/ext/db-index/src/hnsw/simple_store.rs +140 -0
- data/ext/db-index/src/hnsw/store.rs +472 -0
- data/ext/db-index/src/hnsw/vector.rs +105 -0
- data/ext/db-index/src/hnsw/vectors.rs +568 -0
- data/ext/db-index/src/hnsw.rs +42 -0
- data/ext/db-index/src/lib.rs +3 -0
- data/ext/gqlitedb/Cargo.toml +19 -9
- data/ext/gqlitedb/benches/common/pokec.rs +62 -2
- data/ext/gqlitedb/benches/pokec_divan.rs +66 -2
- data/ext/gqlitedb/benches/pokec_iai.rs +60 -3
- data/ext/gqlitedb/release.toml +2 -2
- data/ext/gqlitedb/src/aggregators/arithmetic.rs +3 -1
- data/ext/gqlitedb/src/aggregators/containers.rs +1 -1
- data/ext/gqlitedb/src/aggregators/stats.rs +21 -12
- data/ext/gqlitedb/src/capi.rs +1 -1
- data/ext/gqlitedb/src/compiler/expression_analyser.rs +28 -20
- data/ext/gqlitedb/src/compiler/variables_manager.rs +97 -29
- data/ext/gqlitedb/src/compiler.rs +505 -225
- data/ext/gqlitedb/src/connection.rs +149 -11
- data/ext/gqlitedb/src/consts.rs +1 -2
- data/ext/gqlitedb/src/error.rs +123 -61
- data/ext/gqlitedb/src/functions/common.rs +39 -2
- data/ext/gqlitedb/src/functions/math.rs +8 -3
- data/ext/gqlitedb/src/functions/path.rs +48 -11
- data/ext/gqlitedb/src/functions/value.rs +1 -1
- data/ext/gqlitedb/src/functions.rs +23 -7
- data/ext/gqlitedb/src/graph.rs +1 -9
- data/ext/gqlitedb/src/interpreter/evaluators.rs +968 -130
- data/ext/gqlitedb/src/interpreter/instructions.rs +39 -2
- data/ext/gqlitedb/src/lib.rs +5 -4
- data/ext/gqlitedb/src/planner.rs +329 -0
- data/ext/gqlitedb/src/prelude.rs +3 -3
- data/ext/gqlitedb/src/store/pgrx.rs +1 -1
- data/ext/gqlitedb/src/store/postgres.rs +735 -7
- data/ext/gqlitedb/src/store/redb/hnsw_store.rs +702 -0
- data/ext/gqlitedb/src/store/redb/index.rs +274 -0
- data/ext/gqlitedb/src/store/redb.rs +1268 -113
- data/ext/gqlitedb/src/store/sqlbase/sqlmetadata.rs +28 -0
- data/ext/gqlitedb/src/store/sqlbase/sqlstore.rs +103 -0
- data/ext/gqlitedb/src/store/sqlbase.rs +146 -16
- data/ext/gqlitedb/src/store/sqlite.rs +569 -5
- data/ext/gqlitedb/src/store/vector_extract.rs +56 -0
- data/ext/gqlitedb/src/store.rs +123 -3
- data/ext/gqlitedb/src/tests/compiler.rs +207 -10
- data/ext/gqlitedb/src/tests/connection/postgres.rs +38 -3
- data/ext/gqlitedb/src/tests/connection/redb.rs +23 -0
- data/ext/gqlitedb/src/tests/connection/sqlite.rs +31 -0
- data/ext/gqlitedb/src/tests/connection.rs +61 -1
- data/ext/gqlitedb/src/tests/evaluators.rs +162 -7
- data/ext/gqlitedb/src/tests/parser.rs +54 -23
- data/ext/gqlitedb/src/tests/planner.rs +511 -0
- data/ext/gqlitedb/src/tests/store/postgres.rs +7 -0
- data/ext/gqlitedb/src/tests/store/redb.rs +8 -0
- data/ext/gqlitedb/src/tests/store/sqlite.rs +8 -0
- data/ext/gqlitedb/src/tests/store/vector_index/postgres.rs +182 -0
- data/ext/gqlitedb/src/tests/store/vector_index/redb.rs +386 -0
- data/ext/gqlitedb/src/tests/store/vector_index/sqlite.rs +166 -0
- data/ext/gqlitedb/src/tests/store/vector_index.rs +2313 -0
- data/ext/gqlitedb/src/tests/store.rs +78 -14
- data/ext/gqlitedb/src/tests/templates/ast.rs +92 -16
- data/ext/gqlitedb/src/tests/templates/programs.rs +14 -7
- data/ext/gqlitedb/src/tests.rs +15 -9
- data/ext/gqlitedb/src/utils.rs +6 -1
- data/ext/gqlitedb/src/value/compare.rs +61 -3
- data/ext/gqlitedb/src/value.rs +136 -7
- data/ext/gqlitedb/templates/sql/postgres/metadata_delete.sql +1 -0
- data/ext/gqlitedb/templates/sql/postgres/node_select.sql +1 -1
- data/ext/gqlitedb/templates/sql/sqlite/metadata_delete.sql +1 -0
- data/ext/gqliterb/src/lib.rs +53 -8
- data/ext/gqlparser/Cargo.toml +25 -0
- data/ext/gqlparser/README.MD +9 -0
- data/ext/gqlparser/benches/pokec_divan.rs +34 -0
- data/ext/gqlparser/src/common.rs +69 -0
- data/ext/gqlparser/src/gqls/ast.rs +69 -0
- data/ext/gqlparser/src/gqls/constraint.rs +79 -0
- data/ext/gqlparser/src/gqls/error.rs +22 -0
- data/ext/gqlparser/src/gqls/parser.rs +813 -0
- data/ext/gqlparser/src/gqls/prelude.rs +8 -0
- data/ext/gqlparser/src/gqls/properties.rs +115 -0
- data/ext/gqlparser/src/gqls/resolve.rs +207 -0
- data/ext/gqlparser/src/gqls.rs +265 -0
- data/ext/gqlparser/src/lib.rs +7 -0
- data/ext/gqlparser/src/oc/ast.rs +680 -0
- data/ext/gqlparser/src/oc/error.rs +172 -0
- data/ext/gqlparser/src/oc/lexer.rs +429 -0
- data/ext/gqlparser/src/oc/parser/tests.rs +2284 -0
- data/ext/gqlparser/src/oc/parser.rs +2005 -0
- data/ext/gqlparser/src/oc.rs +33 -0
- data/ext/gqlparser/src/prelude.rs +3 -0
- data/ext/graphcore/Cargo.toml +1 -0
- data/ext/graphcore/src/error.rs +26 -0
- data/ext/graphcore/src/graph.rs +177 -51
- data/ext/graphcore/src/lib.rs +4 -2
- data/ext/graphcore/src/open_cypher.rs +12 -0
- data/ext/graphcore/src/table.rs +50 -2
- data/ext/graphcore/src/timestamp.rs +127 -104
- data/ext/graphcore/src/value/tensor.rs +739 -0
- data/ext/graphcore/src/value/value_map.rs +1 -1
- data/ext/graphcore/src/value.rs +343 -19
- metadata +90 -22
- data/ext/gqlitedb/src/parser/ast.rs +0 -604
- data/ext/gqlitedb/src/parser/parser_impl.rs +0 -1213
- data/ext/gqlitedb/src/parser.rs +0 -4
|
@@ -20,7 +20,8 @@ impl super::FunctionTrait for Length
|
|
|
20
20
|
{
|
|
21
21
|
value::Value::Array(arr) => Ok((arr.len() as i64).into()),
|
|
22
22
|
value::Value::Map(obj) => Ok((obj.len() as i64).into()),
|
|
23
|
-
value::Value::
|
|
23
|
+
value::Value::SinglePath(_) => Ok((1_i64).into()),
|
|
24
|
+
value::Value::Path(path) => Ok((path.elements_count() as i64).into()),
|
|
24
25
|
_ => Err(
|
|
25
26
|
RunTimeError::InvalidArgument {
|
|
26
27
|
function_name: "length",
|
|
@@ -49,27 +50,63 @@ pub(super) struct Nodes {}
|
|
|
49
50
|
|
|
50
51
|
impl Nodes
|
|
51
52
|
{
|
|
52
|
-
fn call_impl(path:
|
|
53
|
+
fn call_impl(path: value::Value) -> FResult<Vec<graph::Node>>
|
|
53
54
|
{
|
|
54
|
-
|
|
55
|
+
match path
|
|
56
|
+
{
|
|
57
|
+
value::Value::SinglePath(p) =>
|
|
58
|
+
{
|
|
59
|
+
let (node, _, destination) = p.unpack();
|
|
60
|
+
Ok(vec![node, destination])
|
|
61
|
+
}
|
|
62
|
+
value::Value::Path(p) =>
|
|
63
|
+
{
|
|
64
|
+
let (source, elements) = p.unpack();
|
|
65
|
+
Ok(
|
|
66
|
+
std::iter::once(source)
|
|
67
|
+
.chain(elements.into_iter().map(|(_, node)| node))
|
|
68
|
+
.collect(),
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
o => Err(RunTimeError::InvalidArgument {
|
|
72
|
+
function_name: "nodes",
|
|
73
|
+
index: 0,
|
|
74
|
+
expected_type: "path",
|
|
75
|
+
value: format!("{:?}", o),
|
|
76
|
+
}),
|
|
77
|
+
}
|
|
55
78
|
}
|
|
56
79
|
}
|
|
57
80
|
|
|
58
|
-
super::declare_function!(nodes, Nodes, call_impl(
|
|
81
|
+
super::declare_function!(nodes, Nodes, call_impl(value::Value) -> Vec<graph::Node>);
|
|
59
82
|
|
|
60
83
|
#[derive(Debug, Default)]
|
|
61
84
|
pub(super) struct Edges {}
|
|
62
85
|
|
|
63
86
|
impl Edges
|
|
64
87
|
{
|
|
65
|
-
fn call_impl(path:
|
|
88
|
+
fn call_impl(path: value::Value) -> FResult<Vec<graph::Edge>>
|
|
66
89
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
match path
|
|
91
|
+
{
|
|
92
|
+
value::Value::SinglePath(p) =>
|
|
93
|
+
{
|
|
94
|
+
let (_, edge, _) = p.unpack();
|
|
95
|
+
Ok(vec![edge])
|
|
96
|
+
}
|
|
97
|
+
value::Value::Path(p) =>
|
|
98
|
+
{
|
|
99
|
+
let (_, elements) = p.unpack();
|
|
100
|
+
Ok(elements.into_iter().map(|(edge, _)| edge).collect())
|
|
101
|
+
}
|
|
102
|
+
o => Err(RunTimeError::InvalidArgument {
|
|
103
|
+
function_name: "edges",
|
|
104
|
+
index: 0,
|
|
105
|
+
expected_type: "path",
|
|
106
|
+
value: format!("{:?}", o),
|
|
107
|
+
}),
|
|
108
|
+
}
|
|
72
109
|
}
|
|
73
110
|
}
|
|
74
111
|
|
|
75
|
-
super::declare_function!(edges, Edges, call_impl(
|
|
112
|
+
super::declare_function!(edges, Edges, call_impl(value::Value) -> Vec<graph::Edge>);
|
|
@@ -219,6 +219,8 @@ impl Manager
|
|
|
219
219
|
.clone(),
|
|
220
220
|
)
|
|
221
221
|
}
|
|
222
|
+
// It has future use in the compiler to optimize constant expressions
|
|
223
|
+
#[allow(dead_code)]
|
|
222
224
|
pub(crate) fn is_deterministic(&self, name: impl Into<String>) -> Result<bool>
|
|
223
225
|
{
|
|
224
226
|
let name = name.into();
|
|
@@ -377,7 +379,7 @@ macro_rules! validate_args_ {
|
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
macro_rules! declare_function_ {
|
|
380
|
-
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, $null_handling: block, $validator: block , $default_args: block ) => {
|
|
382
|
+
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, $null_handling: block, $validator: block , $default_args: block, $deterministic: expr ) => {
|
|
381
383
|
impl $type_name
|
|
382
384
|
{
|
|
383
385
|
pub(super) fn create() -> (String, crate::functions::Function)
|
|
@@ -422,7 +424,7 @@ macro_rules! declare_function_ {
|
|
|
422
424
|
}
|
|
423
425
|
fn is_deterministic(&self) -> bool
|
|
424
426
|
{
|
|
425
|
-
|
|
427
|
+
$deterministic
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
430
|
};
|
|
@@ -490,7 +492,17 @@ macro_rules! declare_function {
|
|
|
490
492
|
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
491
493
|
{$crate::functions::no_null_handling_!()},
|
|
492
494
|
{$crate::functions::default_validate_!($function_name, $ret_type)},
|
|
493
|
-
{$crate::functions::no_default_args_!()}
|
|
495
|
+
{$crate::functions::no_default_args_!()},
|
|
496
|
+
true
|
|
497
|
+
);
|
|
498
|
+
};
|
|
499
|
+
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, non_deterministic ) => {
|
|
500
|
+
$crate::functions::declare_function_!($function_name, $type_name,
|
|
501
|
+
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
502
|
+
{$crate::functions::no_null_handling_!()},
|
|
503
|
+
{$crate::functions::default_validate_!($function_name, $ret_type)},
|
|
504
|
+
{$crate::functions::no_default_args_!()},
|
|
505
|
+
false
|
|
494
506
|
);
|
|
495
507
|
};
|
|
496
508
|
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, null_handling( $( $null_mode: ident ),+ ) ) => {
|
|
@@ -498,7 +510,8 @@ macro_rules! declare_function {
|
|
|
498
510
|
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
499
511
|
{$crate::functions::null_handling_!($($null_mode),+)},
|
|
500
512
|
{$crate::functions::default_validate_!($function_name, $ret_type)},
|
|
501
|
-
{$crate::functions::no_default_args_!()}
|
|
513
|
+
{$crate::functions::no_default_args_!()},
|
|
514
|
+
true
|
|
502
515
|
);
|
|
503
516
|
};
|
|
504
517
|
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, validate_args( $( $expression_types: pat ),+ ) ) => {
|
|
@@ -506,7 +519,8 @@ macro_rules! declare_function {
|
|
|
506
519
|
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
507
520
|
{$crate::functions::no_null_handling_!()},
|
|
508
521
|
{$crate::functions::validate_args_!($function_name, $ret_type, $( $expression_types ),+ )},
|
|
509
|
-
{$crate::functions::no_default_args_!()}
|
|
522
|
+
{$crate::functions::no_default_args_!()},
|
|
523
|
+
true
|
|
510
524
|
);
|
|
511
525
|
};
|
|
512
526
|
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, null_handling( $( $null_mode: ident ),+ ), validate_args( $( $expression_types: pat ),+ ) ) => {
|
|
@@ -514,7 +528,8 @@ macro_rules! declare_function {
|
|
|
514
528
|
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
515
529
|
{$crate::functions::null_handling_!($($null_mode),+)},
|
|
516
530
|
{$crate::functions::validate_args_!($function_name, $ret_type, $( $expression_types ),+ )},
|
|
517
|
-
{$crate::functions::no_default_args_!()}
|
|
531
|
+
{$crate::functions::no_default_args_!()},
|
|
532
|
+
true
|
|
518
533
|
);
|
|
519
534
|
};
|
|
520
535
|
($function_name: ident, $type_name: ty, $f_name: ident ( $( $arg_type: ty $(,)? )* ) -> $ret_type: ty, null_handling( $( $null_mode: ident ),+ ), validate_args( $( $expression_types: pat ),+ ), default_args( $required: expr, $( $default_args: expr ),+ ) ) => {
|
|
@@ -522,7 +537,8 @@ macro_rules! declare_function {
|
|
|
522
537
|
$f_name ( $( $arg_type, )* ) -> $ret_type,
|
|
523
538
|
{$crate::functions::null_handling_!($($null_mode),+)},
|
|
524
539
|
{$crate::functions::validate_args_!($function_name, $required, $ret_type, $( $expression_types ),+ )},
|
|
525
|
-
{$crate::functions::default_args_!( $required, $($default_args),+)}
|
|
540
|
+
{$crate::functions::default_args_!( $required, $($default_args),+)},
|
|
541
|
+
true
|
|
526
542
|
);
|
|
527
543
|
};
|
|
528
544
|
($function_name: ident, $type_name: ty, custom_trait ) => {
|
data/ext/gqlitedb/src/graph.rs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
pub
|
|
2
|
-
pub use graphcore::{Edge, Key, Node, SinglePath as Path};
|
|
1
|
+
pub use graphcore::{Edge, Key, Node, Path, SinglePath};
|
|
3
2
|
|
|
4
3
|
pub use graphcore::labels;
|
|
5
|
-
|
|
6
|
-
#[derive(Debug, Clone, Copy)]
|
|
7
|
-
pub(crate) enum EdgeDirectivity
|
|
8
|
-
{
|
|
9
|
-
Undirected,
|
|
10
|
-
Directed,
|
|
11
|
-
}
|