implica 1.2.1__tar.gz → 1.2.2__tar.gz
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.
- {implica-1.2.1 → implica-1.2.2}/Cargo.lock +1 -1
- {implica-1.2.1 → implica-1.2.2}/Cargo.toml +1 -1
- {implica-1.2.1 → implica-1.2.2}/PKG-INFO +1 -1
- {implica-1.2.1 → implica-1.2.2}/src/graph/base.rs +68 -17
- {implica-1.2.1 → implica-1.2.2}/src/graph/create.rs +4 -9
- {implica-1.2.1 → implica-1.2.2}/tests/test_create.py +3 -3
- {implica-1.2.1 → implica-1.2.2}/.githooks/README.md +0 -0
- {implica-1.2.1 → implica-1.2.2}/.githooks/pre-commit +0 -0
- {implica-1.2.1 → implica-1.2.2}/.github/workflows/CI.yml +0 -0
- {implica-1.2.1 → implica-1.2.2}/.github/workflows/test.yml +0 -0
- {implica-1.2.1 → implica-1.2.2}/.gitignore +0 -0
- {implica-1.2.1 → implica-1.2.2}/LICENSE +0 -0
- {implica-1.2.1 → implica-1.2.2}/README.md +0 -0
- {implica-1.2.1 → implica-1.2.2}/pyproject.toml +0 -0
- {implica-1.2.1 → implica-1.2.2}/python/implica/__init__.py +0 -0
- {implica-1.2.1 → implica-1.2.2}/python/implica/__init__.pyi +0 -0
- {implica-1.2.1 → implica-1.2.2}/python/implica/py.typed +0 -0
- {implica-1.2.1 → implica-1.2.2}/setup-hooks.sh +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/constants.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/errors.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/edge.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/node.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/path.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/properties.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/term_schema.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/matches/type_schema.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/graph/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/lib.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/macros/ctx.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/macros/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/matches.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/edge.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/node.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/parsing.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/path.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/term_schema.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/patterns/type_schema.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/properties.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/base.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/base.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/edge.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/node.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/term.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/query/references/type.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/typing/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/typing/term.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/typing/types.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/cmp.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/data_queue.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/eval.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/hex_to_uid.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/mod.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/src/utils/validation.rs +0 -0
- {implica-1.2.1 → implica-1.2.2}/tests/conftest.py +0 -0
- {implica-1.2.1 → implica-1.2.2}/tests/test_graph_set_properties.py +0 -0
- {implica-1.2.1 → implica-1.2.2}/tests/test_match.py +0 -0
- {implica-1.2.1 → implica-1.2.2}/tests/test_match_create.py +0 -0
- {implica-1.2.1 → implica-1.2.2}/tests/test_set.py +0 -0
|
@@ -122,33 +122,84 @@ impl Graph {
|
|
|
122
122
|
term: Option<Term>,
|
|
123
123
|
properties: PropertyMap,
|
|
124
124
|
) -> ImplicaResult<Uid> {
|
|
125
|
+
let mut expand = false;
|
|
125
126
|
let type_uid = self.insert_type(&r#type);
|
|
126
127
|
|
|
127
128
|
if let Some(term) = term {
|
|
128
|
-
|
|
129
|
+
if !self.term_index.contains_key(&type_uid) {
|
|
130
|
+
// TODO: term comparison?
|
|
131
|
+
let term_uid = self.insert_term(&term);
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
if type_uid != term_uid {
|
|
134
|
+
return Err(ImplicaError::InvalidTerm {
|
|
135
|
+
reason: "term provided is of a different type than the type provided"
|
|
136
|
+
.to_string(),
|
|
137
|
+
}
|
|
138
|
+
.into());
|
|
134
139
|
}
|
|
135
|
-
|
|
140
|
+
|
|
141
|
+
if let Some(arr) = term.r#type().as_arrow() {
|
|
142
|
+
let left_type = self.insert_type(&arr.left);
|
|
143
|
+
let right_type = self.insert_type(&arr.right);
|
|
144
|
+
|
|
145
|
+
if !self.nodes.contains_key(&left_type) {
|
|
146
|
+
let term = self.infer_term(&left_type)?;
|
|
147
|
+
self.add_node(arr.left.as_ref().clone(), term, PropertyMap::default())?;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if !self.nodes.contains_key(&right_type) {
|
|
151
|
+
let term = self.infer_term(&right_type)?;
|
|
152
|
+
self.add_node(arr.right.as_ref().clone(), term, PropertyMap::default())?;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
self.add_edge(term, PropertyMap::default())?;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
expand = true;
|
|
136
159
|
}
|
|
137
160
|
}
|
|
138
161
|
|
|
139
|
-
if self.nodes.contains_key(&type_uid) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
if !self.nodes.contains_key(&type_uid) {
|
|
163
|
+
self.nodes.insert(type_uid, properties);
|
|
164
|
+
self.start_to_edge_index
|
|
165
|
+
.insert(type_uid, Arc::new(DashSet::new()));
|
|
166
|
+
self.end_to_edge_index
|
|
167
|
+
.insert(type_uid, Arc::new(DashSet::new()));
|
|
145
168
|
}
|
|
146
169
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
if expand {
|
|
171
|
+
if let Some(entry) = self.start_to_edge_index.get(&type_uid) {
|
|
172
|
+
let right_edges = entry.value().clone();
|
|
173
|
+
|
|
174
|
+
right_edges.par_iter().try_for_each(|row| -> ImplicaResult<()> {
|
|
175
|
+
let edge = *row.key();
|
|
176
|
+
|
|
177
|
+
if !self.term_index.contains_key(&edge.1) {
|
|
178
|
+
let original_term = self.term_from_uid(&type_uid).attach(ctx!("graph - add node"))?;
|
|
179
|
+
let edge_term = {
|
|
180
|
+
let edge_type = match self.edge_to_type_index.get(&edge) {
|
|
181
|
+
Some(t) => *t,
|
|
182
|
+
None => return Err(ImplicaError::IndexCorruption { message: "edge exists in EdgeIndex without appearing in EdgeToTypeIndex".to_string(), context: Some("graph - add node".to_string()) }.into())
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
self.term_from_uid(&edge_type).attach(ctx!("graph - add node"))
|
|
186
|
+
}?;
|
|
187
|
+
|
|
188
|
+
let new_term = edge_term.apply(&original_term).attach(ctx!("graph - add node"))?;
|
|
189
|
+
|
|
190
|
+
self.add_node(new_term.r#type().as_ref().clone(), Some(new_term), PropertyMap::default()).attach(ctx!("graph - add node"))?;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
Ok(())
|
|
194
|
+
})?;
|
|
195
|
+
} else {
|
|
196
|
+
return Err(ImplicaError::IndexCorruption {
|
|
197
|
+
message: "node exists without row in the StartToEdgeIndex".to_string(),
|
|
198
|
+
context: Some("graph - add node".to_string()),
|
|
199
|
+
}
|
|
200
|
+
.into());
|
|
201
|
+
}
|
|
202
|
+
}
|
|
152
203
|
|
|
153
204
|
Ok(type_uid)
|
|
154
205
|
}
|
|
@@ -278,7 +278,7 @@ impl Graph {
|
|
|
278
278
|
|
|
279
279
|
if let Some(r#type) = node_data.r#type.as_ref().or(type_update.as_ref()) {
|
|
280
280
|
|
|
281
|
-
let type_uid = self.insert_type(r#type);
|
|
281
|
+
let type_uid = self.insert_type(r#type);
|
|
282
282
|
|
|
283
283
|
term_update = match self
|
|
284
284
|
.infer_term(&type_uid){
|
|
@@ -797,10 +797,8 @@ impl Graph {
|
|
|
797
797
|
|
|
798
798
|
prev_uid = match self.add_node(nd.r#type.unwrap(), nd.term, nd.properties) {
|
|
799
799
|
Ok(uid) => uid,
|
|
800
|
-
Err(e) =>
|
|
801
|
-
|
|
802
|
-
_ => return ControlFlow::Break(e.attach(ctx!("graph - create path")))
|
|
803
|
-
}}
|
|
800
|
+
Err(e) => return ControlFlow::Break(e.attach(ctx!("graph - create path")))
|
|
801
|
+
|
|
804
802
|
};
|
|
805
803
|
|
|
806
804
|
match new_match.insert(node_var, MatchElement::Node(prev_uid)) {
|
|
@@ -812,10 +810,7 @@ impl Graph {
|
|
|
812
810
|
match self.add_node(nd.r#type.unwrap(), nd.term, nd.properties) {
|
|
813
811
|
Ok(_) => (),
|
|
814
812
|
Err(e) => {
|
|
815
|
-
|
|
816
|
-
ImplicaError::NodeAlreadyExists { .. } => (),
|
|
817
|
-
_ => return ControlFlow::Break(e.attach(ctx!("graph - create path")))
|
|
818
|
-
}
|
|
813
|
+
return ControlFlow::Break(e.attach(ctx!("graph - create path")))
|
|
819
814
|
}
|
|
820
815
|
}
|
|
821
816
|
}
|
|
@@ -84,9 +84,9 @@ class TestCreateNodeQuery:
|
|
|
84
84
|
|
|
85
85
|
graph.query().create("(::@f(C, D))").execute()
|
|
86
86
|
nodes = graph.nodes()
|
|
87
|
-
assert len(nodes) ==
|
|
88
|
-
assert isinstance(
|
|
89
|
-
assert str(
|
|
87
|
+
assert len(nodes) == 3
|
|
88
|
+
assert all([isinstance(n, implica.Node) for n in nodes])
|
|
89
|
+
assert {str(n) for n in nodes} == {"Node((C -> D):f {})", "Node(C: {})", "Node(D: {})"}
|
|
90
90
|
|
|
91
91
|
def test_create_more_than_one_node_in_different_queries(self):
|
|
92
92
|
graph = implica.Graph()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|