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
|
@@ -7,6 +7,7 @@ pub(crate) trait SqlMetaDataQueries
|
|
|
7
7
|
{
|
|
8
8
|
fn metadata_get_query() -> Result<String>;
|
|
9
9
|
fn metadata_set_query() -> Result<String>;
|
|
10
|
+
fn metadata_delete_query() -> Result<String>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
pub(crate) trait SqlMetaDataStore: super::SqlStore
|
|
@@ -61,6 +62,15 @@ pub(crate) trait SqlMetaDataStore: super::SqlStore
|
|
|
61
62
|
let v = self.get_optional_metadata_value::<String>(transaction, key)?;
|
|
62
63
|
v.map_or_else(|| Ok(f()), |x| Ok(serde_json::from_str(&x)?))
|
|
63
64
|
}
|
|
65
|
+
fn get_metadata_value_json_or_default<T: for<'a> Deserialize<'a> + Default>(
|
|
66
|
+
&self,
|
|
67
|
+
transaction: &mut Self::TransactionBox,
|
|
68
|
+
key: impl Into<String>,
|
|
69
|
+
) -> Result<T>
|
|
70
|
+
{
|
|
71
|
+
let v = self.get_optional_metadata_value::<String>(transaction, key)?;
|
|
72
|
+
v.map_or(Ok(Default::default()), |x| Ok(serde_json::from_str(&x)?))
|
|
73
|
+
}
|
|
64
74
|
fn set_metadata_value<'a>(
|
|
65
75
|
&self,
|
|
66
76
|
transaction: &mut Self::TransactionBox,
|
|
@@ -77,6 +87,12 @@ pub(crate) trait SqlMetaDataStore: super::SqlStore
|
|
|
77
87
|
{
|
|
78
88
|
self.set_metadata_value(transaction, key, &serde_json::to_string(value)?)
|
|
79
89
|
}
|
|
90
|
+
/// Delete a metadata entry by key.
|
|
91
|
+
fn delete_metadata(
|
|
92
|
+
&self,
|
|
93
|
+
transaction: &mut Self::TransactionBox,
|
|
94
|
+
key: impl Into<String>,
|
|
95
|
+
) -> Result<()>;
|
|
80
96
|
}
|
|
81
97
|
|
|
82
98
|
impl<TStore> SqlMetaDataStore for TStore
|
|
@@ -114,4 +130,16 @@ where
|
|
|
114
130
|
(&key.into(), value.into()),
|
|
115
131
|
)
|
|
116
132
|
}
|
|
133
|
+
fn delete_metadata(
|
|
134
|
+
&self,
|
|
135
|
+
transaction: &mut Self::TransactionBox,
|
|
136
|
+
key: impl Into<String>,
|
|
137
|
+
) -> Result<()>
|
|
138
|
+
{
|
|
139
|
+
self
|
|
140
|
+
.execute(transaction, Self::metadata_delete_query()?, (&key.into(),))
|
|
141
|
+
.map_err(|e| {
|
|
142
|
+
InternalError::MigrationError(format!("Failed to delete metadata: {}", e)).into()
|
|
143
|
+
})
|
|
144
|
+
}
|
|
117
145
|
}
|
|
@@ -52,4 +52,107 @@ pub(crate) trait SqlStore
|
|
|
52
52
|
bindings: impl IntoBindings<'a>,
|
|
53
53
|
f: impl for<'b> FnMut(&Self::Row<'b>) -> Result<()>,
|
|
54
54
|
) -> Result<()>;
|
|
55
|
+
|
|
56
|
+
/// Helper for backend-specific vector index creation
|
|
57
|
+
fn create_vector_index_impl(
|
|
58
|
+
&self,
|
|
59
|
+
transaction: &mut Self::TransactionBox,
|
|
60
|
+
graph_name: &str,
|
|
61
|
+
spec: &crate::store::VectorIndexSpec,
|
|
62
|
+
) -> Result<()>
|
|
63
|
+
{
|
|
64
|
+
let _ = (transaction, graph_name, spec);
|
|
65
|
+
Err(InternalError::Unimplemented("Vector indexes are not supported in this backend").into())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// Helper for backend-specific vector-index listing
|
|
69
|
+
fn list_vector_indexes_impl(
|
|
70
|
+
&self,
|
|
71
|
+
transaction: &mut Self::TransactionBox,
|
|
72
|
+
graph_name: &str,
|
|
73
|
+
) -> Result<Vec<crate::store::VectorIndexSpec>>
|
|
74
|
+
{
|
|
75
|
+
let _ = (transaction, graph_name);
|
|
76
|
+
Err(InternalError::Unimplemented("Vector indexes are not supported in this backend").into())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// Helper for backend-specific vector upsert
|
|
80
|
+
fn upsert_vector_impl(
|
|
81
|
+
&self,
|
|
82
|
+
transaction: &mut Self::TransactionBox,
|
|
83
|
+
graph_name: &str,
|
|
84
|
+
index_name: &str,
|
|
85
|
+
node_id: crate::graph::Key,
|
|
86
|
+
tensor: &crate::value::Tensor,
|
|
87
|
+
) -> Result<()>
|
|
88
|
+
{
|
|
89
|
+
let _ = (transaction, graph_name, index_name, node_id, tensor);
|
|
90
|
+
Err(InternalError::Unimplemented("Vector operations are not supported in this backend").into())
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// Helper for backend-specific vector search
|
|
94
|
+
fn vector_search_impl(
|
|
95
|
+
&self,
|
|
96
|
+
transaction: &mut Self::TransactionBox,
|
|
97
|
+
graph_name: &str,
|
|
98
|
+
index_name: &str,
|
|
99
|
+
query: &crate::value::Tensor,
|
|
100
|
+
k: usize,
|
|
101
|
+
) -> Result<Vec<crate::store::VectorSearchResult>>
|
|
102
|
+
{
|
|
103
|
+
let _ = (transaction, graph_name, index_name, query, k);
|
|
104
|
+
Err(InternalError::Unimplemented("Vector search is not supported in this backend").into())
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// Helper for backend-specific vector index removal
|
|
108
|
+
fn drop_vector_index_impl(
|
|
109
|
+
&self,
|
|
110
|
+
transaction: &mut Self::TransactionBox,
|
|
111
|
+
graph_name: &str,
|
|
112
|
+
index_name: &str,
|
|
113
|
+
) -> Result<()>
|
|
114
|
+
{
|
|
115
|
+
let _ = (transaction, graph_name, index_name);
|
|
116
|
+
Err(InternalError::Unimplemented("Vector indexes are not supported in this backend").into())
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// Helper for backend-specific graph vector-index cleanup before graph deletion
|
|
120
|
+
fn drop_graph_vector_indices_impl(
|
|
121
|
+
&self,
|
|
122
|
+
transaction: &mut Self::TransactionBox,
|
|
123
|
+
graph_name: &str,
|
|
124
|
+
) -> Result<()>
|
|
125
|
+
{
|
|
126
|
+
let _ = (transaction, graph_name);
|
|
127
|
+
Ok(())
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Helper for getting vector indices that apply to a property
|
|
131
|
+
fn get_vector_indices_for_property_impl(
|
|
132
|
+
&self,
|
|
133
|
+
transaction: &mut Self::TransactionBox,
|
|
134
|
+
graph_name: &str,
|
|
135
|
+
label: &str,
|
|
136
|
+
property: &str,
|
|
137
|
+
) -> Result<Vec<(String, usize, crate::store::VectorMetric)>>
|
|
138
|
+
{
|
|
139
|
+
let _ = (transaction, graph_name, label, property);
|
|
140
|
+
Err(InternalError::Unimplemented("Vector metadata is not supported in this backend").into())
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// Helper for applying vector indices to a node
|
|
144
|
+
fn apply_vector_indices_for_node_impl(
|
|
145
|
+
&self,
|
|
146
|
+
transaction: &mut Self::TransactionBox,
|
|
147
|
+
graph_name: &str,
|
|
148
|
+
node: &crate::graph::Node,
|
|
149
|
+
) -> Result<()>;
|
|
150
|
+
|
|
151
|
+
/// Helper for deleting vectors for deleted nodes
|
|
152
|
+
fn delete_vectors_for_nodes_impl(
|
|
153
|
+
&self,
|
|
154
|
+
transaction: &mut Self::TransactionBox,
|
|
155
|
+
graph_name: &str,
|
|
156
|
+
node_ids: &[String],
|
|
157
|
+
) -> Result<()>;
|
|
55
158
|
}
|
|
@@ -75,6 +75,7 @@ where
|
|
|
75
75
|
let mut graphs_list = self.graphs_list(transaction)?;
|
|
76
76
|
if graphs_list.iter().any(|s| s == graph_name)
|
|
77
77
|
{
|
|
78
|
+
<Self as SqlStore>::drop_graph_vector_indices_impl(self, transaction, graph_name)?;
|
|
78
79
|
self.execute_batch(transaction, Self::graph_delete(graph_name)?)?;
|
|
79
80
|
graphs_list.retain(|x| x != graph_name);
|
|
80
81
|
self.set_metadata_value_json(transaction, "graphs", &graphs_list)?;
|
|
@@ -102,17 +103,25 @@ where
|
|
|
102
103
|
nodes_iter: T,
|
|
103
104
|
) -> Result<()>
|
|
104
105
|
{
|
|
105
|
-
|
|
106
|
+
let graph_name_str = graph_name.as_ref();
|
|
107
|
+
for node in nodes_iter
|
|
106
108
|
{
|
|
107
109
|
self.execute(
|
|
108
110
|
transaction,
|
|
109
|
-
Self::node_create_query(
|
|
111
|
+
Self::node_create_query(graph_name_str)?.as_str(),
|
|
110
112
|
(
|
|
111
|
-
&
|
|
112
|
-
LabelsRef(
|
|
113
|
-
PropertiesRef(
|
|
113
|
+
&node.key(),
|
|
114
|
+
LabelsRef(node.labels()),
|
|
115
|
+
PropertiesRef(node.properties()),
|
|
114
116
|
),
|
|
115
117
|
)?;
|
|
118
|
+
// Apply vector indices for this node
|
|
119
|
+
<Self as crate::store::sqlbase::SqlStore>::apply_vector_indices_for_node_impl(
|
|
120
|
+
self,
|
|
121
|
+
transaction,
|
|
122
|
+
graph_name_str,
|
|
123
|
+
node,
|
|
124
|
+
)?;
|
|
116
125
|
}
|
|
117
126
|
Ok(())
|
|
118
127
|
}
|
|
@@ -154,9 +163,13 @@ where
|
|
|
154
163
|
}
|
|
155
164
|
self.execute(
|
|
156
165
|
transaction,
|
|
157
|
-
Self::node_delete_query(graph_name, nodes_keys)?,
|
|
166
|
+
Self::node_delete_query(graph_name, nodes_keys.clone())?,
|
|
158
167
|
(),
|
|
159
168
|
)?;
|
|
169
|
+
|
|
170
|
+
// Clean up vector indices for deleted nodes
|
|
171
|
+
let _ = self.delete_vectors_for_nodes_impl(transaction, graph_name, &nodes_keys);
|
|
172
|
+
|
|
160
173
|
Ok(())
|
|
161
174
|
}
|
|
162
175
|
fn update_node(
|
|
@@ -166,15 +179,23 @@ where
|
|
|
166
179
|
node: &crate::graph::Node,
|
|
167
180
|
) -> Result<()>
|
|
168
181
|
{
|
|
182
|
+
let graph_name_str = graph_name.as_ref();
|
|
169
183
|
self.execute(
|
|
170
184
|
transaction,
|
|
171
|
-
Self::node_update_query(
|
|
185
|
+
Self::node_update_query(graph_name_str)?,
|
|
172
186
|
(
|
|
173
187
|
&node.key(),
|
|
174
188
|
LabelsRef(node.labels()),
|
|
175
189
|
PropertiesRef(node.properties()),
|
|
176
190
|
),
|
|
177
191
|
)?;
|
|
192
|
+
// Apply vector indices for this node (update case)
|
|
193
|
+
<Self as crate::store::sqlbase::SqlStore>::apply_vector_indices_for_node_impl(
|
|
194
|
+
self,
|
|
195
|
+
transaction,
|
|
196
|
+
graph_name_str,
|
|
197
|
+
node,
|
|
198
|
+
)?;
|
|
178
199
|
Ok(())
|
|
179
200
|
}
|
|
180
201
|
fn select_nodes(
|
|
@@ -184,6 +205,7 @@ where
|
|
|
184
205
|
query: store::SelectNodeQuery,
|
|
185
206
|
) -> Result<Vec<crate::graph::Node>>
|
|
186
207
|
{
|
|
208
|
+
let graph_name = graph_name.as_ref();
|
|
187
209
|
let mut query_bindings = Vec::<SqlBindingValue>::new();
|
|
188
210
|
let keys_var = query.keys.as_ref().map(|keys| {
|
|
189
211
|
query_bindings.push(keys.into());
|
|
@@ -206,7 +228,12 @@ where
|
|
|
206
228
|
let key: graph::Key = row.get::<graph::Key>(0)?;
|
|
207
229
|
let labels = row.get::<Labels>(1)?;
|
|
208
230
|
let properties = row.get::<Properties>(2)?;
|
|
209
|
-
nodes.push(graph::Node::new(
|
|
231
|
+
nodes.push(graph::Node::new(
|
|
232
|
+
Some(graph_name.to_string()),
|
|
233
|
+
key,
|
|
234
|
+
labels.0,
|
|
235
|
+
properties.0,
|
|
236
|
+
));
|
|
210
237
|
Ok(())
|
|
211
238
|
},
|
|
212
239
|
)?;
|
|
@@ -241,7 +268,7 @@ where
|
|
|
241
268
|
transaction: &mut Self::TransactionBox,
|
|
242
269
|
graph_name: impl AsRef<str>,
|
|
243
270
|
query: store::SelectEdgeQuery,
|
|
244
|
-
directivity:
|
|
271
|
+
directivity: graphcore::EdgeDirectivity,
|
|
245
272
|
) -> Result<()>
|
|
246
273
|
{
|
|
247
274
|
let graph_name = graph_name.as_ref();
|
|
@@ -280,17 +307,18 @@ where
|
|
|
280
307
|
transaction: &mut Self::TransactionBox,
|
|
281
308
|
graph_name: impl AsRef<str>,
|
|
282
309
|
query: store::SelectEdgeQuery,
|
|
283
|
-
directivity:
|
|
310
|
+
directivity: graphcore::EdgeDirectivity,
|
|
284
311
|
) -> Result<Vec<store::EdgeResult>>
|
|
285
312
|
{
|
|
313
|
+
let graph_name = graph_name.as_ref();
|
|
286
314
|
if query.source.is_select_none() || query.destination.is_select_none()
|
|
287
315
|
{
|
|
288
316
|
return Ok(Default::default());
|
|
289
317
|
}
|
|
290
318
|
let (is_undirected, table_suffix) = match directivity
|
|
291
319
|
{
|
|
292
|
-
|
|
293
|
-
|
|
320
|
+
graphcore::EdgeDirectivity::Directed => (false, ""),
|
|
321
|
+
graphcore::EdgeDirectivity::Undirected => (true, "_undirected"),
|
|
294
322
|
};
|
|
295
323
|
|
|
296
324
|
let mut query_bindings = Vec::<SqlBindingValue>::new();
|
|
@@ -378,8 +406,18 @@ where
|
|
|
378
406
|
let n_right_labels = row.get::<Labels>(8)?.0;
|
|
379
407
|
let n_right_properties = row.get::<Properties>(9)?.0;
|
|
380
408
|
|
|
381
|
-
let source = graph::Node::new(
|
|
382
|
-
|
|
409
|
+
let source = graph::Node::new(
|
|
410
|
+
Some(graph_name.to_string()),
|
|
411
|
+
n_left_key,
|
|
412
|
+
n_left_labels,
|
|
413
|
+
n_left_properties,
|
|
414
|
+
);
|
|
415
|
+
let destination = graph::Node::new(
|
|
416
|
+
Some(graph_name.to_string()),
|
|
417
|
+
n_right_key,
|
|
418
|
+
n_right_labels,
|
|
419
|
+
n_right_properties,
|
|
420
|
+
);
|
|
383
421
|
let reversed = row.get::<u32>(3)? == 1;
|
|
384
422
|
let (source, destination) = if reversed
|
|
385
423
|
{
|
|
@@ -391,7 +429,12 @@ where
|
|
|
391
429
|
};
|
|
392
430
|
|
|
393
431
|
edges.push(EdgeResult {
|
|
394
|
-
path: graph::
|
|
432
|
+
path: graph::SinglePath::new(
|
|
433
|
+
source,
|
|
434
|
+
graph::Edge::new(None, edge_key, edge_labels, edge_properties),
|
|
435
|
+
destination,
|
|
436
|
+
)
|
|
437
|
+
.with_graph_name(graph_name.to_string()),
|
|
395
438
|
reversed,
|
|
396
439
|
});
|
|
397
440
|
Ok(())
|
|
@@ -401,7 +444,7 @@ where
|
|
|
401
444
|
Ok(edges)
|
|
402
445
|
}
|
|
403
446
|
fn compute_statistics(&self, transaction: &mut Self::TransactionBox)
|
|
404
|
-
|
|
447
|
+
-> Result<store::Statistics>
|
|
405
448
|
{
|
|
406
449
|
let (nodes_count, edges_count, labels_nodes_count, properties_count) = self.query_row(
|
|
407
450
|
transaction,
|
|
@@ -416,4 +459,91 @@ where
|
|
|
416
459
|
properties_count,
|
|
417
460
|
})
|
|
418
461
|
}
|
|
462
|
+
|
|
463
|
+
fn create_vector_index(
|
|
464
|
+
&self,
|
|
465
|
+
transaction: &mut Self::TransactionBox,
|
|
466
|
+
graph_name: impl AsRef<str>,
|
|
467
|
+
spec: store::VectorIndexSpec,
|
|
468
|
+
) -> Result<()>
|
|
469
|
+
{
|
|
470
|
+
<Self as SqlStore>::create_vector_index_impl(self, transaction, graph_name.as_ref(), &spec)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
fn list_vector_indexes(
|
|
474
|
+
&self,
|
|
475
|
+
transaction: &mut Self::TransactionBox,
|
|
476
|
+
graph_name: impl AsRef<str>,
|
|
477
|
+
) -> Result<Vec<store::VectorIndexSpec>>
|
|
478
|
+
{
|
|
479
|
+
<Self as SqlStore>::list_vector_indexes_impl(self, transaction, graph_name.as_ref())
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
fn upsert_vector(
|
|
483
|
+
&self,
|
|
484
|
+
transaction: &mut Self::TransactionBox,
|
|
485
|
+
graph_name: impl AsRef<str>,
|
|
486
|
+
index_name: impl AsRef<str>,
|
|
487
|
+
node_id: graph::Key,
|
|
488
|
+
tensor: &value::Tensor,
|
|
489
|
+
) -> Result<()>
|
|
490
|
+
{
|
|
491
|
+
<Self as SqlStore>::upsert_vector_impl(
|
|
492
|
+
self,
|
|
493
|
+
transaction,
|
|
494
|
+
graph_name.as_ref(),
|
|
495
|
+
index_name.as_ref(),
|
|
496
|
+
node_id,
|
|
497
|
+
tensor,
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
fn vector_search(
|
|
502
|
+
&self,
|
|
503
|
+
transaction: &mut Self::TransactionBox,
|
|
504
|
+
graph_name: impl AsRef<str>,
|
|
505
|
+
index_name: impl AsRef<str>,
|
|
506
|
+
query: &value::Tensor,
|
|
507
|
+
k: usize,
|
|
508
|
+
) -> Result<Vec<store::VectorSearchResult>>
|
|
509
|
+
{
|
|
510
|
+
<Self as SqlStore>::vector_search_impl(
|
|
511
|
+
self,
|
|
512
|
+
transaction,
|
|
513
|
+
graph_name.as_ref(),
|
|
514
|
+
index_name.as_ref(),
|
|
515
|
+
query,
|
|
516
|
+
k,
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
fn drop_vector_index(
|
|
521
|
+
&self,
|
|
522
|
+
transaction: &mut Self::TransactionBox,
|
|
523
|
+
graph_name: impl AsRef<str>,
|
|
524
|
+
index_name: impl AsRef<str>,
|
|
525
|
+
) -> Result<()>
|
|
526
|
+
{
|
|
527
|
+
<Self as SqlStore>::drop_vector_index_impl(
|
|
528
|
+
self,
|
|
529
|
+
transaction,
|
|
530
|
+
graph_name.as_ref(),
|
|
531
|
+
index_name.as_ref(),
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
fn apply_vector_indices_for_node(
|
|
536
|
+
&self,
|
|
537
|
+
transaction: &mut Self::TransactionBox,
|
|
538
|
+
graph_name: impl AsRef<str>,
|
|
539
|
+
node: &crate::graph::Node,
|
|
540
|
+
) -> Result<()>
|
|
541
|
+
{
|
|
542
|
+
<Self as SqlStore>::apply_vector_indices_for_node_impl(
|
|
543
|
+
self,
|
|
544
|
+
transaction,
|
|
545
|
+
graph_name.as_ref(),
|
|
546
|
+
node,
|
|
547
|
+
)
|
|
548
|
+
}
|
|
419
549
|
}
|