drivine 0.1.0__py3-none-any.whl

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.
Files changed (283) hide show
  1. drivine/__init__.py +244 -0
  2. drivine/annotation/__init__.py +0 -0
  3. drivine/annotation/aggregate.py +25 -0
  4. drivine/annotation/aggregate_function.py +9 -0
  5. drivine/annotation/direction.py +7 -0
  6. drivine/annotation/empty_when_absent.py +8 -0
  7. drivine/annotation/full_text_index.py +11 -0
  8. drivine/annotation/graph_path.py +21 -0
  9. drivine/annotation/graph_property.py +11 -0
  10. drivine/annotation/hop.py +29 -0
  11. drivine/annotation/json_packed.py +9 -0
  12. drivine/annotation/node_id.py +9 -0
  13. drivine/annotation/node_labels.py +25 -0
  14. drivine/annotation/node_stamp.py +10 -0
  15. drivine/annotation/null_as_default.py +9 -0
  16. drivine/annotation/property_bag.py +16 -0
  17. drivine/annotation/range_index.py +14 -0
  18. drivine/annotation/read_only.py +9 -0
  19. drivine/annotation/relationship.py +21 -0
  20. drivine/annotation/root.py +8 -0
  21. drivine/annotation/sorted_by.py +12 -0
  22. drivine/annotation/target_node.py +9 -0
  23. drivine/annotation/transient.py +8 -0
  24. drivine/annotation/unique.py +11 -0
  25. drivine/annotation/vector_index.py +17 -0
  26. drivine/backend/__init__.py +0 -0
  27. drivine/backend/backends.py +16 -0
  28. drivine/backend/cascade_targets.py +64 -0
  29. drivine/backend/cypher.py +31 -0
  30. drivine/backend/cypher_backend.py +414 -0
  31. drivine/backend/cypher_grammar.py +211 -0
  32. drivine/backend/cypher_stamps.py +49 -0
  33. drivine/backend/edge_statements.py +130 -0
  34. drivine/backend/fragment_batch_statement.py +71 -0
  35. drivine/backend/fragment_group.py +14 -0
  36. drivine/backend/graph_backend.py +149 -0
  37. drivine/backend/graph_statement.py +20 -0
  38. drivine/backend/group_statement.py +171 -0
  39. drivine/backend/matched_node.py +16 -0
  40. drivine/backend/matching_search.py +21 -0
  41. drivine/backend/nearest_search.py +26 -0
  42. drivine/backend/oracle/__init__.py +0 -0
  43. drivine/backend/oracle/oracle_backend.py +389 -0
  44. drivine/backend/oracle/oracle_graph.py +187 -0
  45. drivine/backend/oracle/oracle_groups.py +137 -0
  46. drivine/backend/oracle/oracle_json.py +38 -0
  47. drivine/backend/oracle/oracle_nodes_of.py +11 -0
  48. drivine/backend/oracle/oracle_query_renderer.py +401 -0
  49. drivine/backend/oracle/oracle_save_builder.py +600 -0
  50. drivine/backend/oracle/oracle_schema_grammar.py +265 -0
  51. drivine/backend/oracle/oracle_search.py +132 -0
  52. drivine/backend/oracle/oracle_side_table.py +94 -0
  53. drivine/backend/oracle/oracle_step.py +16 -0
  54. drivine/backend/oracle/oracle_views.py +308 -0
  55. drivine/backend/oracle/oracle_writes.py +299 -0
  56. drivine/backend/oracle/text_query.py +252 -0
  57. drivine/backend/page.py +12 -0
  58. drivine/backend/patch_statements.py +78 -0
  59. drivine/backend/save_statement.py +37 -0
  60. drivine/backend/save_statement_builder.py +686 -0
  61. drivine/backend/vector_writes.py +45 -0
  62. drivine/backend/view_projection.py +13 -0
  63. drivine/backend/view_projector.py +312 -0
  64. drivine/concurrency.py +29 -0
  65. drivine/connection/__init__.py +0 -0
  66. drivine/connection/auto_commit_transactions.py +37 -0
  67. drivine/connection/connection.py +38 -0
  68. drivine/connection/connection_properties.py +95 -0
  69. drivine/connection/connection_provider.py +28 -0
  70. drivine/connection/connection_provider_builder.py +198 -0
  71. drivine/connection/database_registry.py +64 -0
  72. drivine/connection/database_type.py +10 -0
  73. drivine/connection/falkordb/__init__.py +0 -0
  74. drivine/connection/falkordb/falkordb_connection.py +61 -0
  75. drivine/connection/falkordb/falkordb_connection_provider.py +73 -0
  76. drivine/connection/falkordb/falkordb_cursor.py +38 -0
  77. drivine/connection/falkordb/falkordb_parameter_coercer.py +67 -0
  78. drivine/connection/falkordb/falkordb_result_mapper.py +31 -0
  79. drivine/connection/falkordb/falkordb_spec_compiler.py +37 -0
  80. drivine/connection/neo4j/__init__.py +0 -0
  81. drivine/connection/neo4j/neo4j_connection.py +74 -0
  82. drivine/connection/neo4j/neo4j_connection_provider.py +92 -0
  83. drivine/connection/neo4j/neo4j_cursor.py +32 -0
  84. drivine/connection/neo4j/neo4j_result_mapper.py +36 -0
  85. drivine/connection/neo4j/neo4j_spec_compiler.py +28 -0
  86. drivine/connection/oracle/__init__.py +0 -0
  87. drivine/connection/oracle/oracle_connection.py +114 -0
  88. drivine/connection/oracle/oracle_connection_provider.py +88 -0
  89. drivine/connection/oracle/oracle_cursor.py +30 -0
  90. drivine/connection/oracle/oracle_result_mapper.py +49 -0
  91. drivine/connection/oracle/oracle_spec_compiler.py +67 -0
  92. drivine/connection/transaction_mode.py +20 -0
  93. drivine/cursor/__init__.py +0 -0
  94. drivine/cursor/buffered_cursor.py +38 -0
  95. drivine/cursor/cursor.py +38 -0
  96. drivine/cursor/cursor_specification.py +24 -0
  97. drivine/drivine_assembly.py +118 -0
  98. drivine/drivine_error.py +27 -0
  99. drivine/dsl/__init__.py +0 -0
  100. drivine/dsl/any_label_test.py +10 -0
  101. drivine/dsl/bag_refs.py +9 -0
  102. drivine/dsl/case_branch.py +14 -0
  103. drivine/dsl/case_condition.py +32 -0
  104. drivine/dsl/collection_sort.py +17 -0
  105. drivine/dsl/collection_sorts.py +72 -0
  106. drivine/dsl/comparable_ref.py +20 -0
  107. drivine/dsl/compare_test.py +14 -0
  108. drivine/dsl/composite_condition.py +13 -0
  109. drivine/dsl/condition.py +53 -0
  110. drivine/dsl/condition_node.py +23 -0
  111. drivine/dsl/condition_writer.py +14 -0
  112. drivine/dsl/expression.py +19 -0
  113. drivine/dsl/expression_node.py +26 -0
  114. drivine/dsl/index_advice_policy.py +18 -0
  115. drivine/dsl/instance_of_test.py +10 -0
  116. drivine/dsl/list_ref.py +17 -0
  117. drivine/dsl/model_scope.py +81 -0
  118. drivine/dsl/node_tests.py +37 -0
  119. drivine/dsl/operator.py +22 -0
  120. drivine/dsl/order_expressions.py +132 -0
  121. drivine/dsl/order_term.py +29 -0
  122. drivine/dsl/path_condition.py +15 -0
  123. drivine/dsl/quantify_test.py +15 -0
  124. drivine/dsl/query.py +26 -0
  125. drivine/dsl/query_index_advisor.py +114 -0
  126. drivine/dsl/query_renderer.py +428 -0
  127. drivine/dsl/ref.py +189 -0
  128. drivine/dsl/rendered_query.py +33 -0
  129. drivine/dsl/root_key.py +13 -0
  130. drivine/dsl/scope.py +18 -0
  131. drivine/dsl/seek_value.py +12 -0
  132. drivine/dsl/step.py +23 -0
  133. drivine/dsl/string_ref.py +24 -0
  134. drivine/dsl/value_ref.py +37 -0
  135. drivine/logger.py +42 -0
  136. drivine/manager/__init__.py +0 -0
  137. drivine/manager/cascade_type.py +16 -0
  138. drivine/manager/contention.py +50 -0
  139. drivine/manager/delegating_persistence_manager.py +37 -0
  140. drivine/manager/edge_operations.py +77 -0
  141. drivine/manager/graph_object_manager_factory.py +33 -0
  142. drivine/manager/group_aggregate.py +13 -0
  143. drivine/manager/group_operations.py +102 -0
  144. drivine/manager/group_query.py +30 -0
  145. drivine/manager/groups.py +50 -0
  146. drivine/manager/node_ref.py +18 -0
  147. drivine/manager/non_atomic_batch_error.py +17 -0
  148. drivine/manager/non_transactional_persistence_manager.py +77 -0
  149. drivine/manager/null_policy.py +17 -0
  150. drivine/manager/patch_result.py +13 -0
  151. drivine/manager/path_key.py +14 -0
  152. drivine/manager/persistence_manager.py +51 -0
  153. drivine/manager/persistence_manager_factory.py +38 -0
  154. drivine/manager/persistence_manager_type.py +5 -0
  155. drivine/manager/property_key.py +11 -0
  156. drivine/manager/relate_mode.py +8 -0
  157. drivine/manager/removed_targets.py +17 -0
  158. drivine/manager/save_options.py +33 -0
  159. drivine/manager/scored.py +14 -0
  160. drivine/manager/stale_object_error.py +33 -0
  161. drivine/manager/stateless_graph_object_manager.py +923 -0
  162. drivine/manager/transactional_persistence_manager.py +40 -0
  163. drivine/mapper/__init__.py +0 -0
  164. drivine/mapper/filter_post_processor.py +12 -0
  165. drivine/mapper/graph_object_mapper.py +154 -0
  166. drivine/mapper/graph_result_mapper.py +39 -0
  167. drivine/mapper/map_post_processor.py +12 -0
  168. drivine/mapper/result_post_processor.py +7 -0
  169. drivine/mapper/transform_post_processor.py +24 -0
  170. drivine/model/__init__.py +0 -0
  171. drivine/model/aggregate_model.py +20 -0
  172. drivine/model/field_mapping.py +27 -0
  173. drivine/model/field_shape.py +53 -0
  174. drivine/model/fragment_model.py +36 -0
  175. drivine/model/graph_view.py +26 -0
  176. drivine/model/graph_view_model.py +26 -0
  177. drivine/model/model_registry.py +590 -0
  178. drivine/model/node_fragment.py +47 -0
  179. drivine/model/node_labels_model.py +14 -0
  180. drivine/model/path_model.py +33 -0
  181. drivine/model/property_bag_model.py +11 -0
  182. drivine/model/property_names.py +19 -0
  183. drivine/model/relationship_fragment.py +26 -0
  184. drivine/model/relationship_fragment_model.py +23 -0
  185. drivine/model/relationship_model.py +48 -0
  186. drivine/model/schema_declaration.py +18 -0
  187. drivine/model/stamps.py +82 -0
  188. drivine/model/target_model.py +13 -0
  189. drivine/model/vector_field.py +12 -0
  190. drivine/py.typed +0 -0
  191. drivine/query/__init__.py +0 -0
  192. drivine/query/compiled_query.py +14 -0
  193. drivine/query/query_specification.py +106 -0
  194. drivine/query/query_specification_compiler.py +35 -0
  195. drivine/query/statement.py +51 -0
  196. drivine/schema/__init__.py +0 -0
  197. drivine/schema/constraint_manager.py +74 -0
  198. drivine/schema/engine_vector_options.py +18 -0
  199. drivine/schema/ensure_result.py +27 -0
  200. drivine/schema/full_text_index_spec.py +13 -0
  201. drivine/schema/index_manager.py +180 -0
  202. drivine/schema/native_operation.py +13 -0
  203. drivine/schema/range_index_spec.py +13 -0
  204. drivine/schema/schema_catalog.py +103 -0
  205. drivine/schema/schema_executor.py +65 -0
  206. drivine/schema/schema_grammar.py +364 -0
  207. drivine/schema/schema_item.py +20 -0
  208. drivine/schema/schema_listing.py +15 -0
  209. drivine/schema/schema_manager.py +233 -0
  210. drivine/schema/schema_options.py +21 -0
  211. drivine/schema/schema_specs.py +68 -0
  212. drivine/schema/uniqueness_constraint_spec.py +13 -0
  213. drivine/schema/vector_index_spec.py +43 -0
  214. drivine/schema/vector_tuning.py +13 -0
  215. drivine/store/__init__.py +0 -0
  216. drivine/store/store_identity.py +22 -0
  217. drivine/store/store_identity_resolver.py +105 -0
  218. drivine/stubs/__init__.py +0 -0
  219. drivine/stubs/__main__.py +55 -0
  220. drivine/stubs/stub_writer.py +249 -0
  221. drivine/sync/__init__.py +246 -0
  222. drivine/sync/concurrency.py +30 -0
  223. drivine/sync/connection/__init__.py +0 -0
  224. drivine/sync/connection/connection.py +40 -0
  225. drivine/sync/connection/connection_provider.py +30 -0
  226. drivine/sync/connection/connection_provider_builder.py +200 -0
  227. drivine/sync/connection/database_registry.py +66 -0
  228. drivine/sync/connection/falkordb/__init__.py +0 -0
  229. drivine/sync/connection/falkordb/falkordb_connection.py +63 -0
  230. drivine/sync/connection/falkordb/falkordb_connection_provider.py +75 -0
  231. drivine/sync/connection/falkordb/falkordb_cursor.py +40 -0
  232. drivine/sync/connection/neo4j/__init__.py +0 -0
  233. drivine/sync/connection/neo4j/neo4j_connection.py +76 -0
  234. drivine/sync/connection/neo4j/neo4j_connection_provider.py +94 -0
  235. drivine/sync/connection/neo4j/neo4j_cursor.py +34 -0
  236. drivine/sync/connection/oracle/__init__.py +0 -0
  237. drivine/sync/connection/oracle/oracle_connection.py +116 -0
  238. drivine/sync/connection/oracle/oracle_connection_provider.py +90 -0
  239. drivine/sync/connection/oracle/oracle_cursor.py +32 -0
  240. drivine/sync/cursor/__init__.py +0 -0
  241. drivine/sync/cursor/buffered_cursor.py +40 -0
  242. drivine/sync/cursor/cursor.py +40 -0
  243. drivine/sync/drivine_assembly.py +120 -0
  244. drivine/sync/dsl/__init__.py +0 -0
  245. drivine/sync/dsl/query_index_advisor.py +116 -0
  246. drivine/sync/manager/__init__.py +0 -0
  247. drivine/sync/manager/contention.py +52 -0
  248. drivine/sync/manager/delegating_persistence_manager.py +39 -0
  249. drivine/sync/manager/edge_operations.py +79 -0
  250. drivine/sync/manager/graph_object_manager_factory.py +35 -0
  251. drivine/sync/manager/group_operations.py +104 -0
  252. drivine/sync/manager/non_transactional_persistence_manager.py +79 -0
  253. drivine/sync/manager/persistence_manager.py +53 -0
  254. drivine/sync/manager/persistence_manager_factory.py +40 -0
  255. drivine/sync/manager/stateless_graph_object_manager.py +915 -0
  256. drivine/sync/manager/transactional_persistence_manager.py +42 -0
  257. drivine/sync/schema/__init__.py +0 -0
  258. drivine/sync/schema/constraint_manager.py +74 -0
  259. drivine/sync/schema/index_manager.py +182 -0
  260. drivine/sync/schema/schema_executor.py +67 -0
  261. drivine/sync/schema/schema_manager.py +235 -0
  262. drivine/sync/schema/schema_options.py +23 -0
  263. drivine/sync/store/__init__.py +0 -0
  264. drivine/sync/store/store_identity_resolver.py +107 -0
  265. drivine/sync/transaction/__init__.py +0 -0
  266. drivine/sync/transaction/transaction.py +218 -0
  267. drivine/sync/transaction/transactional.py +123 -0
  268. drivine/testing/__init__.py +0 -0
  269. drivine/testing/container_connection.py +14 -0
  270. drivine/testing/drivine_test_containers.py +199 -0
  271. drivine/testing/plugin.py +32 -0
  272. drivine/testing/test_container_spec.py +22 -0
  273. drivine/transaction/__init__.py +0 -0
  274. drivine/transaction/transaction.py +216 -0
  275. drivine/transaction/transaction_rolled_back_error.py +11 -0
  276. drivine/transaction/transactional.py +121 -0
  277. drivine/utils/__init__.py +0 -0
  278. drivine/utils/short_id.py +8 -0
  279. drivine-0.1.0.dist-info/METADATA +644 -0
  280. drivine-0.1.0.dist-info/RECORD +283 -0
  281. drivine-0.1.0.dist-info/WHEEL +4 -0
  282. drivine-0.1.0.dist-info/entry_points.txt +2 -0
  283. drivine-0.1.0.dist-info/licenses/LICENSE +201 -0
drivine/__init__.py ADDED
@@ -0,0 +1,244 @@
1
+ """
2
+ Drivine: a graph database client for Python. https://drivine.org
3
+ """
4
+
5
+ from drivine.annotation.aggregate import Aggregate, Count
6
+ from drivine.annotation.aggregate_function import AggregateFunction
7
+ from drivine.annotation.direction import Direction
8
+ from drivine.annotation.empty_when_absent import EmptyWhenAbsent
9
+ from drivine.annotation.full_text_index import FullTextIndex
10
+ from drivine.annotation.graph_path import GraphPath
11
+ from drivine.annotation.graph_property import GraphProperty
12
+ from drivine.annotation.hop import Hop, hop
13
+ from drivine.annotation.json_packed import JsonPacked
14
+ from drivine.annotation.node_id import NodeId
15
+ from drivine.annotation.node_labels import NodeLabels
16
+ from drivine.annotation.node_stamp import NodeStamp
17
+ from drivine.annotation.null_as_default import NullAsDefault
18
+ from drivine.annotation.property_bag import PropertyBag
19
+ from drivine.annotation.range_index import RangeIndex
20
+ from drivine.annotation.read_only import ReadOnly
21
+ from drivine.annotation.relationship import Relationship
22
+ from drivine.annotation.root import Root
23
+ from drivine.annotation.sorted_by import SortedBy
24
+ from drivine.annotation.target_node import TargetNode
25
+ from drivine.annotation.transient import Transient
26
+ from drivine.annotation.unique import Unique
27
+ from drivine.annotation.vector_index import VectorIndex
28
+ from drivine.connection.connection import Connection
29
+ from drivine.connection.connection_properties import ConnectionProperties
30
+ from drivine.connection.connection_provider import ConnectionProvider
31
+ from drivine.connection.connection_provider_builder import ConnectionProviderBuilder
32
+ from drivine.connection.database_registry import DatabaseRegistry
33
+ from drivine.connection.database_type import DatabaseType
34
+ from drivine.connection.transaction_mode import TransactionMode
35
+ from drivine.cursor.cursor import Cursor
36
+ from drivine.cursor.cursor_specification import CursorSpecification
37
+ from drivine.drivine_error import DrivineError
38
+ from drivine.dsl.bag_refs import BagRefs
39
+ from drivine.dsl.comparable_ref import ComparableRef
40
+ from drivine.dsl.condition import Condition, Where, all_of, any_of, not_
41
+ from drivine.dsl.index_advice_policy import IndexAdvicePolicy
42
+ from drivine.dsl.list_ref import ListRef
43
+ from drivine.dsl.node_tests import NodeTests
44
+ from drivine.dsl.order_expressions import (
45
+ above,
46
+ at_least,
47
+ at_most,
48
+ below,
49
+ case_of,
50
+ coalesce,
51
+ div,
52
+ epoch_seconds,
53
+ equal_to,
54
+ exp,
55
+ floor,
56
+ has_no_value,
57
+ has_value,
58
+ minus,
59
+ negate,
60
+ not_equal_to,
61
+ param,
62
+ plus,
63
+ times,
64
+ )
65
+ from drivine.dsl.order_term import OrderTerm
66
+ from drivine.dsl.query_index_advisor import QueryIndexAdvisor
67
+ from drivine.dsl.ref import Ref, refs
68
+ from drivine.dsl.seek_value import SeekValue
69
+ from drivine.dsl.string_ref import StringRef
70
+ from drivine.dsl.value_ref import ValueRef
71
+ from drivine.manager.cascade_type import CascadeType
72
+ from drivine.manager.delegating_persistence_manager import DelegatingPersistenceManager
73
+ from drivine.manager.edge_operations import EdgeOperations
74
+ from drivine.manager.graph_object_manager_factory import GraphObjectManagerFactory
75
+ from drivine.manager.group_aggregate import GroupAggregate
76
+ from drivine.manager.group_operations import GroupOperations
77
+ from drivine.manager.groups import avg, count, key, max_, min_, path_key, sum_
78
+ from drivine.manager.node_ref import NodeRef, node_ref
79
+ from drivine.manager.non_transactional_persistence_manager import NonTransactionalPersistenceManager
80
+ from drivine.manager.null_policy import NullPolicy
81
+ from drivine.manager.patch_result import PatchResult
82
+ from drivine.manager.path_key import PathKey
83
+ from drivine.manager.persistence_manager import PersistenceManager
84
+ from drivine.manager.persistence_manager_factory import PersistenceManagerFactory
85
+ from drivine.manager.property_key import PropertyKey
86
+ from drivine.manager.relate_mode import RelateMode
87
+ from drivine.manager.removed_targets import RemovedTargets
88
+ from drivine.manager.save_options import SaveOptions
89
+ from drivine.manager.scored import Scored
90
+ from drivine.manager.stale_object_error import StaleObjectError
91
+ from drivine.manager.stateless_graph_object_manager import StatelessGraphObjectManager
92
+ from drivine.manager.transactional_persistence_manager import TransactionalPersistenceManager
93
+ from drivine.model import stamps
94
+ from drivine.model.graph_view import GraphView
95
+ from drivine.model.model_registry import ModelRegistry
96
+ from drivine.model.node_fragment import NodeFragment
97
+ from drivine.model.property_names import PropertyNames
98
+ from drivine.model.relationship_fragment import RelationshipFragment
99
+ from drivine.query.query_specification import QuerySpecification
100
+ from drivine.query.statement import Statement, cypher_file, cypher_statement, sql_file, sql_statement
101
+ from drivine.schema.constraint_manager import ConstraintManager
102
+ from drivine.schema.engine_vector_options import EngineVectorOptions
103
+ from drivine.schema.ensure_result import EnsureResult
104
+ from drivine.schema.index_manager import IndexManager
105
+ from drivine.schema.schema_catalog import SchemaCatalog
106
+ from drivine.schema.schema_manager import SchemaManager
107
+ from drivine.schema.schema_options import SchemaOptions
108
+ from drivine.schema.schema_specs import full_text_index, range_index, uniqueness_constraint, vector_index
109
+ from drivine.store.store_identity import StoreIdentity
110
+ from drivine.transaction.transaction import Transaction, current_transaction
111
+ from drivine.transaction.transaction_rolled_back_error import TransactionRolledBackError
112
+ from drivine.transaction.transactional import transaction, transactional
113
+
114
+ __all__ = [
115
+ "above",
116
+ "Aggregate",
117
+ "AggregateFunction",
118
+ "all_of",
119
+ "any_of",
120
+ "at_least",
121
+ "at_most",
122
+ "avg",
123
+ "BagRefs",
124
+ "below",
125
+ "CascadeType",
126
+ "case_of",
127
+ "coalesce",
128
+ "ComparableRef",
129
+ "Condition",
130
+ "Connection",
131
+ "ConnectionProperties",
132
+ "ConnectionProvider",
133
+ "ConnectionProviderBuilder",
134
+ "ConstraintManager",
135
+ "Count",
136
+ "count",
137
+ "current_transaction",
138
+ "Cursor",
139
+ "CursorSpecification",
140
+ "cypher_file",
141
+ "cypher_statement",
142
+ "DatabaseRegistry",
143
+ "DatabaseType",
144
+ "DelegatingPersistenceManager",
145
+ "Direction",
146
+ "div",
147
+ "DrivineError",
148
+ "EdgeOperations",
149
+ "EmptyWhenAbsent",
150
+ "EngineVectorOptions",
151
+ "EnsureResult",
152
+ "epoch_seconds",
153
+ "equal_to",
154
+ "exp",
155
+ "floor",
156
+ "full_text_index",
157
+ "FullTextIndex",
158
+ "GraphObjectManagerFactory",
159
+ "GraphPath",
160
+ "GraphProperty",
161
+ "GraphView",
162
+ "GroupAggregate",
163
+ "GroupOperations",
164
+ "has_no_value",
165
+ "has_value",
166
+ "Hop",
167
+ "hop",
168
+ "IndexAdvicePolicy",
169
+ "IndexManager",
170
+ "JsonPacked",
171
+ "key",
172
+ "ListRef",
173
+ "max_",
174
+ "min_",
175
+ "minus",
176
+ "ModelRegistry",
177
+ "negate",
178
+ "node_ref",
179
+ "NodeFragment",
180
+ "NodeId",
181
+ "NodeLabels",
182
+ "NodeRef",
183
+ "NodeStamp",
184
+ "NodeTests",
185
+ "NonTransactionalPersistenceManager",
186
+ "not_",
187
+ "not_equal_to",
188
+ "NullAsDefault",
189
+ "NullPolicy",
190
+ "OrderTerm",
191
+ "param",
192
+ "PatchResult",
193
+ "path_key",
194
+ "PathKey",
195
+ "PersistenceManager",
196
+ "PersistenceManagerFactory",
197
+ "plus",
198
+ "PropertyBag",
199
+ "PropertyKey",
200
+ "PropertyNames",
201
+ "QueryIndexAdvisor",
202
+ "QuerySpecification",
203
+ "range_index",
204
+ "RangeIndex",
205
+ "ReadOnly",
206
+ "Ref",
207
+ "refs",
208
+ "RelateMode",
209
+ "Relationship",
210
+ "RelationshipFragment",
211
+ "RemovedTargets",
212
+ "Root",
213
+ "SaveOptions",
214
+ "SchemaCatalog",
215
+ "SchemaManager",
216
+ "SchemaOptions",
217
+ "Scored",
218
+ "SeekValue",
219
+ "SortedBy",
220
+ "sql_file",
221
+ "sql_statement",
222
+ "StaleObjectError",
223
+ "stamps",
224
+ "StatelessGraphObjectManager",
225
+ "Statement",
226
+ "StoreIdentity",
227
+ "StringRef",
228
+ "sum_",
229
+ "TargetNode",
230
+ "times",
231
+ "Transaction",
232
+ "transaction",
233
+ "transactional",
234
+ "TransactionalPersistenceManager",
235
+ "TransactionMode",
236
+ "TransactionRolledBackError",
237
+ "Transient",
238
+ "Unique",
239
+ "uniqueness_constraint",
240
+ "ValueRef",
241
+ "vector_index",
242
+ "VectorIndex",
243
+ "Where",
244
+ ]
File without changes
@@ -0,0 +1,25 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from drivine.annotation.aggregate_function import AggregateFunction
6
+ from drivine.annotation.direction import Direction
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class Aggregate:
11
+ """
12
+ A field of a view computed in the query from the nodes one relationship type leads to from the root: their
13
+ number, or the SUM, AVG, MIN or MAX of one of their properties, named as stored. SUM and COUNT of none are 0; AVG,
14
+ MIN and MAX of none are None. Read-only.
15
+ """
16
+
17
+ function: AggregateFunction
18
+ type: str
19
+ property: str | None = None
20
+ direction: Direction = Direction.OUTGOING
21
+
22
+
23
+ def Count(type: str, direction: Direction = Direction.OUTGOING) -> Aggregate: # noqa: N802 - reads as a marker
24
+ """The number of nodes a relationship type leads to from the view's root. Read-only."""
25
+ return Aggregate(AggregateFunction.COUNT, type, None, direction)
@@ -0,0 +1,9 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class AggregateFunction(StrEnum):
5
+ COUNT = "COUNT"
6
+ SUM = "SUM"
7
+ AVG = "AVG"
8
+ MIN = "MIN"
9
+ MAX = "MAX"
@@ -0,0 +1,7 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class Direction(StrEnum):
5
+ OUTGOING = "OUTGOING"
6
+ INCOMING = "INCOMING"
7
+ UNDIRECTED = "UNDIRECTED"
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class EmptyWhenAbsent:
6
+ """
7
+ Loads an absent or null collection as an empty one: a list, set or tuple as one with no items, a dict as `{}`.
8
+ """
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class FullTextIndex:
9
+ """A full-text index over the field, or, as a class argument, over the fields named. Drives `load_matching`."""
10
+
11
+ properties: Sequence[str] = ()
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+ from dataclasses import dataclass
5
+
6
+ from drivine.annotation.hop import Hop
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class GraphPath:
11
+ """
12
+ A field of a view holding the nodes at the far end of a fixed list of hops from the root, each once, skipping the
13
+ nodes between: `directors: Annotated[list[Director], GraphPath([hop("ACTED_IN"), hop("DIRECTED_BY")])] = []`.
14
+ Read-only. A single path typed without `None` is required, and a list is with `required=True`.
15
+ """
16
+
17
+ hops: Sequence[Hop]
18
+ required: bool = False
19
+
20
+ def __hash__(self) -> int:
21
+ return hash((tuple(self.hops), self.required))
@@ -0,0 +1,11 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class GraphProperty:
6
+ """
7
+ Stores a field under the given property name, rather than the one the fragment's naming gives it:
8
+ `url_v2: Annotated[str, GraphProperty("urlV2")]`.
9
+ """
10
+
11
+ name: str
@@ -0,0 +1,29 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from drivine.annotation.direction import Direction
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class Hop:
10
+ """
11
+ One hop of a path: a relationship type, its direction, and optionally a label the node it reaches must carry,
12
+ and a property of that node to read the path in the order of. See TypeScript's `Hop` for how an order is read.
13
+ """
14
+
15
+ type: str
16
+ direction: Direction = Direction.OUTGOING
17
+ label: str | None = None
18
+ order_by: str | None = None
19
+ ascending: bool = True
20
+
21
+
22
+ def hop(
23
+ type: str,
24
+ direction: Direction = Direction.OUTGOING,
25
+ label: str | None = None,
26
+ order_by: str | None = None,
27
+ ascending: bool = True,
28
+ ) -> Hop:
29
+ return Hop(type, direction, label, order_by, ascending)
@@ -0,0 +1,9 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class JsonPacked:
6
+ """
7
+ Stores a field as a JSON string, for a value an engine can't store as a property: a list of maps, or a map.
8
+ Unpacked on load.
9
+ """
@@ -0,0 +1,9 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class NodeId:
6
+ """
7
+ Marks the field that identifies a node: `uuid: Annotated[str, NodeId()]`. A fragment has at most one, and needs
8
+ one to be loaded or saved by id.
9
+ """
@@ -0,0 +1,25 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterable
4
+ from dataclasses import dataclass
5
+ from enum import Enum
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class NodeLabels:
10
+ """
11
+ Maps a field holding strings, a list or a set, to the node's labels beyond its fragment's own. With `members` (a
12
+ list of names, or a string Enum) the set is closed: the field reads only those labels. Without, it is open: it
13
+ reads every label besides the fragment's own. One to a fragment.
14
+ """
15
+
16
+ members: tuple[str, ...] | None = None
17
+
18
+ def __init__(self, members: Iterable[str] | type[Enum] | None = None) -> None:
19
+ if members is None:
20
+ names = None
21
+ elif isinstance(members, type):
22
+ names = tuple(str(it.value) for it in members)
23
+ else:
24
+ names = tuple(members)
25
+ object.__setattr__(self, "members", names)
@@ -0,0 +1,10 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class NodeStamp:
6
+ """
7
+ Marks the field that holds the node's stamp, which a save checks to refuse overwriting a newer write:
8
+ `stamp: Annotated[str | None, NodeStamp()] = None`. Stored as `__drivine.stamp`, as TypeScript and drivine4j
9
+ store it.
10
+ """
@@ -0,0 +1,9 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class NullAsDefault:
6
+ """
7
+ Loads a stored null as the field's default: `status: Annotated[str, NullAsDefault()] = "active"`. A property the
8
+ node doesn't have gets the default anyway. TypeScript's `@Default`.
9
+ """
@@ -0,0 +1,16 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class PropertyBag:
6
+ """
7
+ Maps a dict field of a node fragment to node properties, one for each entry, stored as `<prefix><delimiter><key>`:
8
+ real properties, visible and indexable. `prefix` defaults to the field's stored name and `delimiter` to `.`.
9
+
10
+ A flat bag has no prefix: each entry is stored under its bare key, and the bag reads back every property no field
11
+ or other bag accounts for. One to a fragment.
12
+ """
13
+
14
+ prefix: str | None = None
15
+ delimiter: str = "."
16
+ flat: bool = False
@@ -0,0 +1,14 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class RangeIndex:
9
+ """
10
+ A range index over the field, `Annotated[str, RangeIndex()]`, or, as a class argument, over the fields named:
11
+ `class Session(NodeFragment, labels=[...], schema=[RangeIndex(["last_activity_at", "session_id"])])`.
12
+ """
13
+
14
+ properties: Sequence[str] = ()
@@ -0,0 +1,9 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class ReadOnly:
6
+ """
7
+ Marks a relationship field of a view that is loaded and never written. A list of fragments read over several hops
8
+ (`max_depth` above 1) is read-only whether or not it is marked so.
9
+ """
@@ -0,0 +1,21 @@
1
+ from dataclasses import dataclass
2
+
3
+ from drivine.annotation.direction import Direction
4
+
5
+
6
+ @dataclass(frozen=True)
7
+ class Relationship:
8
+ """
9
+ Marks a view's field as a relationship from its root: `employment_history: Annotated[list[WorkHistory],
10
+ Relationship("WORKS_FOR")] = []`. What it holds, a node fragment, a relationship fragment or a view, is read from
11
+ the annotation, so is whether it is a list.
12
+
13
+ A single relationship typed without `None` is required: only roots that have it are loaded. A list is required
14
+ when `required=True`. `max_depth` is how deep a relationship to the view's own class, or one that leads back to
15
+ it, is expanded.
16
+ """
17
+
18
+ type: str
19
+ direction: Direction = Direction.OUTGOING
20
+ max_depth: int = 1
21
+ required: bool = False
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class Root:
6
+ """
7
+ Marks a view's root, the node fragment the query starts from: `person: Annotated[Person, Root()]`. A view has one.
8
+ """
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class SortedBy:
6
+ """
7
+ Sorts a list relationship of a view after it is loaded, by a field path: `"name"`, or `"person.name"` into a
8
+ related view or relationship fragment. Nulls go last.
9
+ """
10
+
11
+ path: str
12
+ ascending: bool = True
@@ -0,0 +1,9 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class TargetNode:
6
+ """
7
+ Marks the field of a relationship fragment that holds the node the relationship leads to: a node fragment or a
8
+ view.
9
+ """
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class Transient:
6
+ """
7
+ Marks a field that is neither loaded nor saved. It needs a default.
8
+ """
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class Unique:
9
+ """A uniqueness constraint over the field, or, as a class argument, over the fields named."""
10
+
11
+ properties: Sequence[str] = ()
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Literal
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class VectorIndex:
9
+ """
10
+ A vector index over the field. Its dimensions come from the catalog's dimension provider when the catalog is built
11
+ (they belong to the embedding model, known at run time), unless given here. Drives `load_nearest`.
12
+ """
13
+
14
+ similarity: Literal["COSINE", "EUCLIDEAN"] = "COSINE"
15
+ dimensions: int | None = None
16
+ hnsw_m: int | None = None
17
+ hnsw_ef_construction: int | None = None
File without changes
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from drivine.backend.cypher_backend import CypherBackend
4
+ from drivine.backend.cypher_grammar import cypher_grammar_for
5
+ from drivine.backend.graph_backend import GraphBackend
6
+ from drivine.connection.database_type import DatabaseType
7
+
8
+
9
+ def backend_for(type: DatabaseType, graph_name: str | None = None) -> GraphBackend:
10
+ """The backend that writes an engine's statements: on Oracle, over the tables of the graph named."""
11
+ if type is DatabaseType.ORACLE:
12
+ from drivine.backend.oracle.oracle_backend import OracleBackend
13
+ from drivine.backend.oracle.oracle_graph import DEFAULT_GRAPH, OracleGraph
14
+
15
+ return OracleBackend(OracleGraph(graph_name or DEFAULT_GRAPH))
16
+ return CypherBackend(cypher_grammar_for(type))
@@ -0,0 +1,64 @@
1
+ from __future__ import annotations
2
+
3
+ from drivine.annotation.direction import Direction
4
+ from drivine.backend.cypher import label_expression, quote_name
5
+ from drivine.backend.cypher_grammar import CypherGrammar
6
+ from drivine.backend.view_projector import ViewProjector, label_test, target
7
+ from drivine.model.fragment_model import FragmentModel
8
+ from drivine.model.graph_view_model import GraphViewModel
9
+ from drivine.model.relationship_model import RelationshipModel
10
+
11
+
12
+ class CascadeTargets:
13
+ """
14
+ The nodes a view reaches from its root, as one list expression: a pattern comprehension for each position in the
15
+ view, each a flat path from the root, joined with `+`. Paths are flat, with no comprehension nested in another,
16
+ because FalkorDB evaluates nested ones wrongly when they are combined (FalkorDB/FalkorDB#2006, #3386).
17
+
18
+ The view's max_depth and the requirements of its nested views apply, so the list holds what loading the view would
19
+ load. A node reached by two paths is listed twice.
20
+ """
21
+
22
+ def __init__(self, grammar: CypherGrammar) -> None:
23
+ self.grammar = grammar
24
+ self._alias_count = 0
25
+
26
+ def of(self, model: GraphViewModel, root: str) -> str:
27
+ lists = self._view(model, f"({root})", [], [])
28
+ return " + ".join(lists) if lists else "[]"
29
+
30
+ def _view(
31
+ self, model: GraphViewModel, chain: str, conditions: list[str], path: list[RelationshipModel]
32
+ ) -> list[str]:
33
+ lists: list[str] = []
34
+ for rel in model.relationships:
35
+ if sum(1 for it in path if it is rel) >= rel.max_depth:
36
+ continue
37
+ self._alias_count += 1
38
+ alias = f"c{self._alias_count}"
39
+ into = target(rel)
40
+ hops = f"*1..{rel.max_depth}" if isinstance(into, FragmentModel) and rel.max_depth > 1 else ""
41
+ labels = into.root.labels if isinstance(into, GraphViewModel) else into.labels
42
+ step = f"{chain}{_hop(rel, hops)}({alias}"
43
+ extended = f"{step}{label_expression(labels)})"
44
+ own = ViewProjector(self.grammar).requirements(into, alias) if isinstance(into, GraphViewModel) else []
45
+ every = [*conditions, *own]
46
+ where = f" WHERE {' AND '.join(every)}" if every else ""
47
+ # Where the grammar says so, the far node's labels are tested after the match, the next level's chain
48
+ # keeping them.
49
+ if self.grammar.far_labels_after_match:
50
+ lists.append(f"[{alias} IN [{step}){where} | {alias}] WHERE {label_test(alias, labels)}]")
51
+ else:
52
+ lists.append(f"[{extended}{where} | {alias}]")
53
+ if isinstance(into, GraphViewModel):
54
+ lists.extend(self._view(into, extended, every, [*path, rel]))
55
+ return lists
56
+
57
+
58
+ def _hop(rel: RelationshipModel, hops: str) -> str:
59
+ edge = f"[:{quote_name(rel.type)}{hops}]"
60
+ if rel.direction is Direction.INCOMING:
61
+ return f"<-{edge}-"
62
+ if rel.direction is Direction.UNDIRECTED:
63
+ return f"-{edge}-"
64
+ return f"-{edge}->"