gqlite 1.1.0 → 1.2.2
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/gqliterb/.cargo/config.toml +2 -0
- data/ext/gqliterb/Cargo.lock +1109 -0
- data/ext/gqliterb/Cargo.toml +43 -0
- data/ext/gqliterb/extconf.rb +4 -0
- data/ext/gqliterb/src/lib.rs +260 -0
- data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +2060 -0
- data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +132 -0
- data/ext/gqliterb/vendor/gqlitedb/askama.toml +3 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/common/mod.rs +25 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/common/pokec.rs +185 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/pokec_divan.rs +137 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/pokec_iai.rs +122 -0
- data/ext/gqliterb/vendor/gqlitedb/release.toml +7 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/arithmetic.rs +96 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/containers.rs +33 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/count.rs +35 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/stats.rs +168 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators.rs +74 -0
- data/ext/gqliterb/vendor/gqlitedb/src/capi.rs +236 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler/expression_analyser.rs +427 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler/variables_manager.rs +620 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler.rs +1106 -0
- data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +208 -0
- data/ext/gqliterb/vendor/gqlitedb/src/consts.rs +10 -0
- data/ext/gqliterb/vendor/gqlitedb/src/error.rs +621 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/containers.rs +115 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/edge.rs +20 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/math.rs +44 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/node.rs +16 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +48 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/scalar.rs +86 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/string.rs +28 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/value.rs +99 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions.rs +412 -0
- data/ext/gqliterb/vendor/gqlitedb/src/graph.rs +268 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/evaluators.rs +1788 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/instructions.rs +262 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/mod.rs +4 -0
- data/ext/gqliterb/vendor/gqlitedb/src/lib.rs +42 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/ast.rs +625 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/gql.pest +191 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/parser.rs +1153 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +4 -0
- data/ext/gqliterb/vendor/gqlitedb/src/prelude.rs +8 -0
- data/ext/gqliterb/vendor/gqlitedb/src/serialize_with.rs +94 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/pgql.rs +121 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/redb.rs +1250 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/sqlite.rs +994 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store.rs +432 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/compiler.rs +92 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/evaluators.rs +227 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/parser.rs +81 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store/redb.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store/sqlite.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store.rs +462 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/ast.rs +356 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/programs.rs +455 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates.rs +2 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/utils.rs +28 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/compare.rs +212 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/contains.rs +47 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/value_map.rs +298 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value.rs +559 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value_table.rs +616 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/call_stats.sql +22 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_count_for_node.sql +3 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_create.sql +6 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete_by_nodes.sql +2 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_select.sql +139 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_update.sql +4 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_create.sql +16 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_delete.sql +3 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_create_table.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_get.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_set.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_create.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_delete.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_select.sql +42 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_update.sql +4 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/table_exists.sql +5 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_from_1_01.sql +2 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_graph_from_1_01.sql +65 -0
- data/lib/gqlite.rb +1 -75
- metadata +118 -25
- data/ext/gqlite/extconf.rb +0 -21
- data/ext/gqlite/gqlite-amalgamate.cpp +0 -9599
- data/ext/gqlite/gqlite-c.h +0 -95
- data/ext/gqlite/gqlite.h +0 -141
@@ -0,0 +1,262 @@
|
|
1
|
+
use crate::{prelude::*, value_table::ColId};
|
2
|
+
|
3
|
+
#[derive(Debug)]
|
4
|
+
pub(crate) enum Instruction
|
5
|
+
{
|
6
|
+
CreateNodeLiteral
|
7
|
+
{
|
8
|
+
labels: Vec<String>,
|
9
|
+
},
|
10
|
+
CreateEdgeLiteral
|
11
|
+
{
|
12
|
+
labels: Vec<String>,
|
13
|
+
},
|
14
|
+
CreateNodeQuery
|
15
|
+
{
|
16
|
+
labels: Vec<String>,
|
17
|
+
},
|
18
|
+
CreateEdgeQuery
|
19
|
+
{
|
20
|
+
labels: Vec<String>,
|
21
|
+
},
|
22
|
+
FunctionCall
|
23
|
+
{
|
24
|
+
function: functions::Function,
|
25
|
+
arguments_count: usize,
|
26
|
+
},
|
27
|
+
Push
|
28
|
+
{
|
29
|
+
value: value::Value,
|
30
|
+
},
|
31
|
+
GetVariable
|
32
|
+
{
|
33
|
+
col_id: value_table::ColId,
|
34
|
+
},
|
35
|
+
GetParameter
|
36
|
+
{
|
37
|
+
name: String,
|
38
|
+
},
|
39
|
+
CreateArray
|
40
|
+
{
|
41
|
+
length: usize,
|
42
|
+
},
|
43
|
+
CreateMap
|
44
|
+
{
|
45
|
+
keys: Vec<String>,
|
46
|
+
},
|
47
|
+
IndexAccess,
|
48
|
+
RangeAccess
|
49
|
+
{
|
50
|
+
start: bool,
|
51
|
+
end: bool,
|
52
|
+
},
|
53
|
+
MemberAccess
|
54
|
+
{
|
55
|
+
path: Vec<String>,
|
56
|
+
},
|
57
|
+
Duplicate,
|
58
|
+
Rot3, // If a is the top of the stack, then a b c -> b c a
|
59
|
+
InverseRot3, // If a is the top of the stack, then a b c -> c a b
|
60
|
+
Swap,
|
61
|
+
Drop,
|
62
|
+
AndBinaryOperator,
|
63
|
+
OrBinaryOperator,
|
64
|
+
XorBinaryOperator,
|
65
|
+
NegationUnaryOperator,
|
66
|
+
NotUnaryOperator,
|
67
|
+
IsNullUnaryOperator,
|
68
|
+
EqualBinaryOperator,
|
69
|
+
NotEqualBinaryOperator,
|
70
|
+
InferiorBinaryOperator,
|
71
|
+
SuperiorBinaryOperator,
|
72
|
+
InferiorEqualBinaryOperator,
|
73
|
+
SuperiorEqualBinaryOperator,
|
74
|
+
InBinaryOperator,
|
75
|
+
NotInBinaryOperator,
|
76
|
+
AdditionBinaryOperator,
|
77
|
+
SubtractionBinaryOperator,
|
78
|
+
MultiplicationBinaryOperator,
|
79
|
+
DivisionBinaryOperator,
|
80
|
+
ModuloBinaryOperator,
|
81
|
+
}
|
82
|
+
|
83
|
+
pub(crate) type Instructions = Vec<Instruction>;
|
84
|
+
|
85
|
+
#[derive(Debug)]
|
86
|
+
pub(crate) struct CreateAction
|
87
|
+
{
|
88
|
+
pub(crate) instructions: Instructions,
|
89
|
+
pub(crate) variables: Vec<Option<ColId>>,
|
90
|
+
}
|
91
|
+
|
92
|
+
#[derive(Debug)]
|
93
|
+
pub(crate) enum BlockMatch
|
94
|
+
{
|
95
|
+
MatchNode
|
96
|
+
{
|
97
|
+
instructions: Instructions,
|
98
|
+
variable: Option<ColId>,
|
99
|
+
filter: Instructions,
|
100
|
+
},
|
101
|
+
MatchEdge
|
102
|
+
{
|
103
|
+
instructions: Instructions,
|
104
|
+
left_variable: Option<ColId>,
|
105
|
+
edge_variable: Option<ColId>,
|
106
|
+
right_variable: Option<ColId>,
|
107
|
+
path_variable: Option<ColId>,
|
108
|
+
filter: Instructions,
|
109
|
+
directivity: graph::EdgeDirectivity,
|
110
|
+
},
|
111
|
+
}
|
112
|
+
|
113
|
+
#[derive(Debug)]
|
114
|
+
pub(crate) struct RWAggregation
|
115
|
+
{
|
116
|
+
pub(crate) init_instructions: Instructions,
|
117
|
+
pub(crate) argument_instructions: Instructions,
|
118
|
+
pub(crate) aggregator: aggregators::Aggregator,
|
119
|
+
}
|
120
|
+
|
121
|
+
/// R(eturn)W(ith)Expression are expressions computed in Return or With blocks.
|
122
|
+
#[derive(Debug)]
|
123
|
+
pub(crate) struct RWExpression
|
124
|
+
{
|
125
|
+
/// Id of the column where to get the value from
|
126
|
+
pub(crate) col_id: ColId,
|
127
|
+
/// Instructions to compute this expression
|
128
|
+
pub(crate) instructions: Instructions,
|
129
|
+
/// Potential aggregations used by this expression
|
130
|
+
pub(crate) aggregations: Vec<(value_table::ColId, RWAggregation)>,
|
131
|
+
}
|
132
|
+
|
133
|
+
/// Update one node/edge.
|
134
|
+
#[derive(Debug)]
|
135
|
+
pub(crate) enum UpdateOne
|
136
|
+
{
|
137
|
+
SetProperty
|
138
|
+
{
|
139
|
+
/// Target is the column containing the node/edge to modify
|
140
|
+
target: ColId,
|
141
|
+
path: Vec<String>,
|
142
|
+
instructions: Instructions,
|
143
|
+
},
|
144
|
+
AddProperty
|
145
|
+
{
|
146
|
+
/// Target is the column containing the node/edge to modify
|
147
|
+
target: ColId,
|
148
|
+
path: Vec<String>,
|
149
|
+
instructions: Instructions,
|
150
|
+
},
|
151
|
+
RemoveProperty
|
152
|
+
{
|
153
|
+
/// Target is the column containing the node/edge to modify
|
154
|
+
target: ColId,
|
155
|
+
path: Vec<String>,
|
156
|
+
},
|
157
|
+
AddLabels
|
158
|
+
{
|
159
|
+
/// Target is the column containing the node/edge to modify
|
160
|
+
target: ColId,
|
161
|
+
labels: Vec<String>,
|
162
|
+
},
|
163
|
+
RemoveLabels
|
164
|
+
{
|
165
|
+
/// Target is the column containing the node/edge to modify
|
166
|
+
target: ColId,
|
167
|
+
labels: Vec<String>,
|
168
|
+
},
|
169
|
+
}
|
170
|
+
|
171
|
+
#[derive(Debug)]
|
172
|
+
pub(crate) struct OrderBy
|
173
|
+
{
|
174
|
+
pub asc: bool,
|
175
|
+
pub instructions: Instructions,
|
176
|
+
}
|
177
|
+
|
178
|
+
#[derive(Debug)]
|
179
|
+
pub(crate) struct Modifiers
|
180
|
+
{
|
181
|
+
pub limit: Option<Instructions>,
|
182
|
+
pub skip: Option<Instructions>,
|
183
|
+
pub order_by: Vec<OrderBy>,
|
184
|
+
}
|
185
|
+
|
186
|
+
#[derive(Debug)]
|
187
|
+
pub(crate) struct VariablesSizes
|
188
|
+
{
|
189
|
+
/// How many variables are persistent, after the block has been executed.
|
190
|
+
pub persistent_variables: usize,
|
191
|
+
/// How many temporary variables are used by the block.
|
192
|
+
pub temporary_variables: usize,
|
193
|
+
}
|
194
|
+
|
195
|
+
impl VariablesSizes
|
196
|
+
{
|
197
|
+
/// Return the total size, `persistent+temporary` variables
|
198
|
+
pub(crate) fn total_size(&self) -> usize
|
199
|
+
{
|
200
|
+
self.temporary_variables + self.persistent_variables
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
#[derive(Debug)]
|
205
|
+
pub(crate) enum Block
|
206
|
+
{
|
207
|
+
CreateGraph
|
208
|
+
{
|
209
|
+
name: String
|
210
|
+
},
|
211
|
+
UseGraph
|
212
|
+
{
|
213
|
+
name: String
|
214
|
+
},
|
215
|
+
Create
|
216
|
+
{
|
217
|
+
actions: Vec<CreateAction>,
|
218
|
+
variables_size: VariablesSizes,
|
219
|
+
},
|
220
|
+
BlockMatch
|
221
|
+
{
|
222
|
+
blocks: Vec<BlockMatch>,
|
223
|
+
filter: Instructions,
|
224
|
+
optional: bool,
|
225
|
+
variables_size: VariablesSizes,
|
226
|
+
},
|
227
|
+
Return
|
228
|
+
{
|
229
|
+
variables: Vec<(String, RWExpression)>,
|
230
|
+
filter: Instructions,
|
231
|
+
modifiers: Modifiers,
|
232
|
+
variables_size: VariablesSizes,
|
233
|
+
},
|
234
|
+
Call
|
235
|
+
{
|
236
|
+
arguments: Instructions,
|
237
|
+
name: String,
|
238
|
+
},
|
239
|
+
With
|
240
|
+
{
|
241
|
+
variables: Vec<RWExpression>,
|
242
|
+
filter: Instructions,
|
243
|
+
modifiers: Modifiers,
|
244
|
+
variables_size: VariablesSizes,
|
245
|
+
},
|
246
|
+
Unwind
|
247
|
+
{
|
248
|
+
col_id: ColId,
|
249
|
+
instructions: Instructions,
|
250
|
+
variables_size: VariablesSizes,
|
251
|
+
},
|
252
|
+
Delete
|
253
|
+
{
|
254
|
+
detach: bool,
|
255
|
+
instructions: Vec<Instructions>,
|
256
|
+
},
|
257
|
+
Update
|
258
|
+
{
|
259
|
+
updates: Vec<UpdateOne>,
|
260
|
+
variables_size: VariablesSizes,
|
261
|
+
},
|
262
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
//!  GQLite
|
2
|
+
//! ======================================================================
|
3
|
+
//!
|
4
|
+
//! Implementation of GQL (Graph Query Language), embeddable in applications.
|
5
|
+
//!
|
6
|
+
//! Add to your crate, using `cargo add gqlitedb`. Check-out [Connection]
|
7
|
+
//! for an example of use.
|
8
|
+
|
9
|
+
#![warn(missing_docs)]
|
10
|
+
#![allow(dead_code)]
|
11
|
+
#![deny(warnings)]
|
12
|
+
|
13
|
+
mod aggregators;
|
14
|
+
#[cfg(feature = "capi")]
|
15
|
+
mod capi;
|
16
|
+
mod compiler;
|
17
|
+
mod connection;
|
18
|
+
mod consts;
|
19
|
+
mod error;
|
20
|
+
mod functions;
|
21
|
+
mod graph;
|
22
|
+
mod interpreter;
|
23
|
+
mod parser;
|
24
|
+
mod prelude;
|
25
|
+
mod serialize_with;
|
26
|
+
mod store;
|
27
|
+
mod utils;
|
28
|
+
mod value;
|
29
|
+
mod value_table;
|
30
|
+
|
31
|
+
#[cfg(test)]
|
32
|
+
pub(crate) mod tests;
|
33
|
+
|
34
|
+
pub use {
|
35
|
+
connection::Connection,
|
36
|
+
error::{CompileTimeError, Error, RunTimeError, StoreError},
|
37
|
+
graph::{Edge, Node, Path},
|
38
|
+
value::{Value, ValueMap},
|
39
|
+
};
|
40
|
+
|
41
|
+
/// GQLite Result alias. Usable as a standard `Result<T, E>` or default to gqlite::Error with `Result<T>`
|
42
|
+
pub type Result<T, E = error::export::Error> = std::result::Result<T, E>;
|