gqlite 1.5.0 → 1.7.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 +12 -6
- 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 -8
- 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 +20 -24
- data/ext/gqlitedb/src/compiler/expression_analyser.rs +28 -20
- data/ext/gqlitedb/src/compiler/variables_manager.rs +104 -38
- data/ext/gqlitedb/src/compiler.rs +506 -227
- data/ext/gqlitedb/src/connection.rs +151 -11
- data/ext/gqlitedb/src/consts.rs +1 -2
- data/ext/gqlitedb/src/error.rs +123 -61
- data/ext/gqlitedb/src/functions/common.rs +64 -0
- data/ext/gqlitedb/src/functions/containers.rs +2 -46
- data/ext/gqlitedb/src/functions/edge.rs +1 -1
- data/ext/gqlitedb/src/functions/math.rs +87 -15
- data/ext/gqlitedb/src/functions/node.rs +1 -1
- data/ext/gqlitedb/src/functions/path.rs +48 -11
- data/ext/gqlitedb/src/functions/scalar.rs +47 -4
- data/ext/gqlitedb/src/functions/string.rs +123 -1
- data/ext/gqlitedb/src/functions/value.rs +1 -1
- data/ext/gqlitedb/src/functions.rs +165 -28
- 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/parser/gql.pest +1 -1
- 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 +742 -16
- 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 +576 -14
- data/ext/gqlitedb/src/store/vector_extract.rs +56 -0
- data/ext/gqlitedb/src/store.rs +140 -29
- 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 +93 -28
- 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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
use std::collections::HashMap;
|
|
2
2
|
|
|
3
|
-
use
|
|
3
|
+
use gqlparser::oc::ast;
|
|
4
|
+
|
|
5
|
+
use crate::{planner::LogicalPlan, prelude::*};
|
|
4
6
|
|
|
5
7
|
use compiler::expression_analyser::{self, ExpressionType};
|
|
6
|
-
use parser::ast;
|
|
7
8
|
|
|
8
9
|
fn unknown_variable_error(name: &ast::VariableIdentifier) -> ErrorType
|
|
9
10
|
{
|
|
10
|
-
|
|
11
|
+
CompileTimeError::UndefinedVariable {
|
|
11
12
|
name: name.name().clone(),
|
|
12
13
|
}
|
|
13
14
|
.into()
|
|
@@ -77,7 +78,8 @@ impl Variable
|
|
|
77
78
|
labels: ast::LabelExpression::None,
|
|
78
79
|
properties: None,
|
|
79
80
|
},
|
|
80
|
-
directivity:
|
|
81
|
+
directivity: graphcore::EdgeDirectivity::Directed,
|
|
82
|
+
recursive_range: None,
|
|
81
83
|
}),
|
|
82
84
|
variable_type: ExpressionType::Edge,
|
|
83
85
|
col_id,
|
|
@@ -253,7 +255,7 @@ impl VariablesManager
|
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
_ => Err(
|
|
256
|
-
|
|
258
|
+
CompileTimeError::ExpectedNode {
|
|
257
259
|
context: "validate_node",
|
|
258
260
|
}
|
|
259
261
|
.into(),
|
|
@@ -358,7 +360,7 @@ impl VariablesManager
|
|
|
358
360
|
}
|
|
359
361
|
}
|
|
360
362
|
_ => Err(
|
|
361
|
-
|
|
363
|
+
CompileTimeError::ExpectedNode {
|
|
362
364
|
context: "is_valid_existing_node",
|
|
363
365
|
}
|
|
364
366
|
.into(),
|
|
@@ -413,7 +415,7 @@ impl VariablesManager
|
|
|
413
415
|
}
|
|
414
416
|
}
|
|
415
417
|
_ => Err(
|
|
416
|
-
|
|
418
|
+
CompileTimeError::ExpectedEdge {
|
|
417
419
|
context: "is_valid_existing_edge",
|
|
418
420
|
}
|
|
419
421
|
.into(),
|
|
@@ -459,7 +461,7 @@ impl VariablesManager
|
|
|
459
461
|
fn analyse_edge_path(
|
|
460
462
|
&mut self,
|
|
461
463
|
path_variable: Option<ast::VariableIdentifier>,
|
|
462
|
-
edge: &
|
|
464
|
+
edge: &gqlparser::oc::ast::EdgePattern,
|
|
463
465
|
is_create: bool,
|
|
464
466
|
) -> Result<()>
|
|
465
467
|
{
|
|
@@ -538,7 +540,7 @@ impl VariablesManager
|
|
|
538
540
|
self.variables = new_variables;
|
|
539
541
|
Ok(())
|
|
540
542
|
}
|
|
541
|
-
pub(crate) fn analyse(&mut self,
|
|
543
|
+
pub(crate) fn analyse(&mut self, logical_plan: &LogicalPlan) -> Result<()>
|
|
542
544
|
{
|
|
543
545
|
if self.variables.iter().any(|(_, var)| !var.is_set)
|
|
544
546
|
{
|
|
@@ -559,58 +561,122 @@ impl VariablesManager
|
|
|
559
561
|
.into(),
|
|
560
562
|
);
|
|
561
563
|
}
|
|
562
|
-
match
|
|
564
|
+
match logical_plan
|
|
563
565
|
{
|
|
564
|
-
|
|
566
|
+
LogicalPlan::CreateGraph { .. } =>
|
|
565
567
|
{}
|
|
566
|
-
|
|
568
|
+
LogicalPlan::DropGraph { .. } =>
|
|
567
569
|
{}
|
|
568
|
-
|
|
570
|
+
LogicalPlan::UseGraph { .. } =>
|
|
569
571
|
{}
|
|
570
|
-
|
|
572
|
+
LogicalPlan::Create { patterns } =>
|
|
571
573
|
{
|
|
572
|
-
for pattern in
|
|
574
|
+
for pattern in patterns.iter()
|
|
573
575
|
{
|
|
574
576
|
if let ast::Pattern::Node(n) = &pattern
|
|
577
|
+
&& self.has_variable(&n.variable)
|
|
575
578
|
{
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
.into(),
|
|
583
|
-
);
|
|
584
|
-
}
|
|
579
|
+
return Err(
|
|
580
|
+
CompileTimeError::VariableAlreadyBound {
|
|
581
|
+
name: n.variable.clone().unwrap().name().clone(),
|
|
582
|
+
}
|
|
583
|
+
.into(),
|
|
584
|
+
);
|
|
585
585
|
}
|
|
586
586
|
self.analyse_pattern(pattern, true)?;
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
|
|
589
|
+
LogicalPlan::NodeScan { patterns, .. } =>
|
|
590
590
|
{
|
|
591
|
-
for pattern in
|
|
591
|
+
for pattern in patterns.iter()
|
|
592
592
|
{
|
|
593
593
|
self.analyse_pattern(pattern, false)?;
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
|
-
|
|
597
|
-
{}
|
|
598
|
-
|
|
596
|
+
LogicalPlan::Filter { source, .. }
|
|
597
|
+
| LogicalPlan::Sort { source, .. }
|
|
598
|
+
| LogicalPlan::Skip { source, .. }
|
|
599
|
+
| LogicalPlan::Limit { source, .. } => self.analyse(source.as_ref())?,
|
|
600
|
+
LogicalPlan::Projection { .. } =>
|
|
599
601
|
{}
|
|
600
|
-
|
|
602
|
+
LogicalPlan::Call { .. } =>
|
|
601
603
|
{}
|
|
602
|
-
|
|
604
|
+
LogicalPlan::Unwind { identifier, .. } =>
|
|
603
605
|
{
|
|
604
|
-
self.declare_variable(
|
|
605
|
-
|
|
606
|
-
expression_analyser::ExpressionType::Variant,
|
|
607
|
-
)?;
|
|
608
|
-
self.mark_variables_as_set(&unwind.identifier)?;
|
|
606
|
+
self.declare_variable(identifier, expression_analyser::ExpressionType::Variant)?;
|
|
607
|
+
self.mark_variables_as_set(identifier)?;
|
|
609
608
|
}
|
|
610
|
-
|
|
609
|
+
LogicalPlan::Delete { .. } =>
|
|
611
610
|
{}
|
|
612
|
-
|
|
611
|
+
LogicalPlan::Update { .. } =>
|
|
613
612
|
{}
|
|
613
|
+
LogicalPlan::Merge { patterns, .. } =>
|
|
614
|
+
{
|
|
615
|
+
for pattern in patterns.iter()
|
|
616
|
+
{
|
|
617
|
+
match pattern
|
|
618
|
+
{
|
|
619
|
+
ast::Pattern::Node(n) =>
|
|
620
|
+
{
|
|
621
|
+
if self.has_variable(&n.variable)
|
|
622
|
+
{
|
|
623
|
+
return Err(
|
|
624
|
+
CompileTimeError::VariableAlreadyBound {
|
|
625
|
+
name: n.variable.as_ref().unwrap().name().clone(),
|
|
626
|
+
}
|
|
627
|
+
.into(),
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
ast::Pattern::Edge(e) =>
|
|
632
|
+
{
|
|
633
|
+
if self.has_variable(&e.variable)
|
|
634
|
+
{
|
|
635
|
+
return Err(
|
|
636
|
+
CompileTimeError::VariableAlreadyBound {
|
|
637
|
+
name: e.variable.as_ref().unwrap().name().clone(),
|
|
638
|
+
}
|
|
639
|
+
.into(),
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
ast::Pattern::Path(p) =>
|
|
644
|
+
{
|
|
645
|
+
if self.has_variable(&Some(p.variable.clone()))
|
|
646
|
+
{
|
|
647
|
+
return Err(
|
|
648
|
+
CompileTimeError::VariableAlreadyBound {
|
|
649
|
+
name: p.variable.name().clone(),
|
|
650
|
+
}
|
|
651
|
+
.into(),
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
self.analyse_pattern(pattern, false)?;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
LogicalPlan::VectorSearch {
|
|
660
|
+
result_var,
|
|
661
|
+
score_var,
|
|
662
|
+
..
|
|
663
|
+
} =>
|
|
664
|
+
{
|
|
665
|
+
// Declare the result variable as a Node
|
|
666
|
+
self.declare_variable(result_var, expression_analyser::ExpressionType::Node)?;
|
|
667
|
+
self.mark_variables_as_set(result_var)?;
|
|
668
|
+
|
|
669
|
+
// Declare the score variable if present
|
|
670
|
+
if let Some(score_var_id) = score_var
|
|
671
|
+
{
|
|
672
|
+
self.declare_variable(score_var_id, expression_analyser::ExpressionType::Float)?;
|
|
673
|
+
self.mark_variables_as_set(score_var_id)?;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
LogicalPlan::CreateVectorIndex { .. } =>
|
|
677
|
+
{
|
|
678
|
+
// Schema operation - no variable analysis needed
|
|
679
|
+
}
|
|
614
680
|
}
|
|
615
681
|
Ok(())
|
|
616
682
|
}
|