gqlite 1.2.2 → 1.3.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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +20 -0
  3. data/ext/gqlitedb/Cargo.toml +77 -0
  4. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
  5. data/ext/gqlitedb/gqlite_bench_data/README.MD +6 -0
  6. data/ext/gqlitedb/gqlite_bench_data/scripts/generate_smaller_pokec.rb +85 -0
  7. data/ext/gqlitedb/gqlite_bench_data/scripts/to_efficient_pokec.rb +34 -0
  8. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/release.toml +2 -2
  9. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/arithmetic.rs +1 -0
  10. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/stats.rs +27 -49
  11. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators.rs +7 -7
  12. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/capi.rs +34 -10
  13. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/expression_analyser.rs +10 -4
  14. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/variables_manager.rs +36 -39
  15. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler.rs +46 -41
  16. data/ext/gqlitedb/src/connection.rs +300 -0
  17. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/error.rs +113 -50
  18. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/containers.rs +21 -26
  19. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/edge.rs +3 -3
  20. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/math.rs +3 -3
  21. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/node.rs +2 -2
  22. data/ext/gqlitedb/src/functions/path.rs +75 -0
  23. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +3 -3
  24. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/string.rs +1 -1
  25. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +7 -7
  26. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +29 -31
  27. data/ext/gqlitedb/src/graph.rs +11 -0
  28. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +178 -224
  29. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +8 -2
  30. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +9 -5
  31. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/ast.rs +54 -76
  32. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/gql.pest +9 -4
  33. data/ext/{gqliterb/vendor/gqlitedb/src/parser/parser.rs → gqlitedb/src/parser/parser_impl.rs} +86 -34
  34. data/ext/gqlitedb/src/parser.rs +4 -0
  35. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/prelude.rs +3 -2
  36. data/ext/gqlitedb/src/query_result.rs +88 -0
  37. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/redb.rs +260 -170
  38. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/sqlite.rs +157 -142
  39. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store.rs +30 -23
  40. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/evaluators.rs +41 -85
  41. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/redb.rs +12 -5
  42. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/sqlite.rs +12 -5
  43. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store.rs +106 -114
  44. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/ast.rs +29 -29
  45. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/programs.rs +4 -4
  46. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/compare.rs +13 -20
  47. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/contains.rs +2 -2
  48. data/ext/gqlitedb/src/value.rs +225 -0
  49. data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value_table.rs +22 -18
  50. data/ext/gqliterb/Cargo.toml +12 -34
  51. data/ext/gqliterb/src/lib.rs +67 -39
  52. data/ext/graphcore/Cargo.toml +19 -0
  53. data/ext/graphcore/README.MD +4 -0
  54. data/ext/graphcore/release.toml +1 -0
  55. data/ext/graphcore/src/error.rs +28 -0
  56. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/graph.rs +146 -35
  57. data/ext/graphcore/src/lib.rs +16 -0
  58. data/ext/graphcore/src/prelude.rs +4 -0
  59. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/serialize_with.rs +2 -2
  60. data/ext/graphcore/src/table.rs +272 -0
  61. data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/value/value_map.rs +44 -49
  62. data/ext/graphcore/src/value.rs +413 -0
  63. metadata +94 -83
  64. data/ext/gqliterb/.cargo/config.toml +0 -2
  65. data/ext/gqliterb/Cargo.lock +0 -1109
  66. data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +0 -2060
  67. data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +0 -132
  68. data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +0 -208
  69. data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +0 -48
  70. data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +0 -4
  71. data/ext/gqliterb/vendor/gqlitedb/src/value.rs +0 -559
  72. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/askama.toml +0 -0
  73. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/mod.rs +0 -0
  74. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_divan.rs +0 -0
  75. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_iai.rs +0 -0
  76. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/containers.rs +0 -0
  77. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/count.rs +0 -0
  78. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/consts.rs +0 -0
  79. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/mod.rs +0 -0
  80. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/pgql.rs +0 -0
  81. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/compiler.rs +0 -0
  82. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/parser.rs +0 -0
  83. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates.rs +0 -0
  84. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests.rs +0 -0
  85. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/utils.rs +0 -0
  86. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/call_stats.sql +0 -0
  87. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_count_for_node.sql +0 -0
  88. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_create.sql +0 -0
  89. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete.sql +0 -0
  90. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete_by_nodes.sql +0 -0
  91. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_select.sql +0 -0
  92. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_update.sql +0 -0
  93. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_create.sql +0 -0
  94. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_delete.sql +0 -0
  95. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_create_table.sql +0 -0
  96. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_get.sql +0 -0
  97. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_set.sql +0 -0
  98. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_create.sql +0 -0
  99. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_delete.sql +0 -0
  100. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_select.sql +0 -0
  101. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_update.sql +0 -0
  102. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/table_exists.sql +0 -0
  103. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_from_1_01.sql +0 -0
  104. /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_graph_from_1_01.sql +0 -0
@@ -243,7 +243,7 @@ pub(crate) fn unwind() -> Program
243
243
  pub(crate) fn match_loop() -> Program
244
244
  {
245
245
  vec![
246
- Block::BlockMatch {
246
+ Block::Match {
247
247
  blocks: vec![BlockMatch::MatchEdge {
248
248
  instructions: vec![
249
249
  Instruction::Push {
@@ -297,7 +297,7 @@ pub(crate) fn match_loop() -> Program
297
297
  pub(crate) fn optional_match() -> Program
298
298
  {
299
299
  vec![
300
- Block::BlockMatch {
300
+ Block::Match {
301
301
  blocks: vec![BlockMatch::MatchNode {
302
302
  instructions: vec![
303
303
  Instruction::Push {
@@ -336,7 +336,7 @@ pub(crate) fn optional_match() -> Program
336
336
  pub(crate) fn match_count(function_manager: &functions::Manager) -> Program
337
337
  {
338
338
  vec![
339
- Block::BlockMatch {
339
+ Block::Match {
340
340
  blocks: vec![BlockMatch::MatchNode {
341
341
  instructions: vec![
342
342
  Instruction::Push {
@@ -387,7 +387,7 @@ pub(crate) fn match_count(function_manager: &functions::Manager) -> Program
387
387
  pub(crate) fn aggregation(function_manager: &functions::Manager) -> Program
388
388
  {
389
389
  vec![
390
- Block::BlockMatch {
390
+ Block::Match {
391
391
  blocks: vec![BlockMatch::MatchNode {
392
392
  instructions: vec![
393
393
  Instruction::Push {
@@ -43,11 +43,7 @@ fn compare_map(lhs: &value::ValueMap, rhs: &value::ValueMap) -> Ordering
43
43
  o => o.into(),
44
44
  }
45
45
  })
46
- .find(|p| match p
47
- {
48
- Ordering::Equal => false,
49
- _ => true,
50
- })
46
+ .find(|p| !matches!(p, Ordering::Equal))
51
47
  .unwrap_or(Ordering::Equal)
52
48
  }
53
49
  else if lhs.len() < rhs.len()
@@ -74,7 +70,7 @@ fn compare_f64(lhs: &f64, rhs: &f64) -> Ordering
74
70
 
75
71
  fn compare_node(lhs: &graph::Node, rhs: &graph::Node) -> Ordering
76
72
  {
77
- lhs.key.uuid.cmp(&rhs.key.uuid).into()
73
+ lhs.key().uuid().cmp(&rhs.key().uuid()).into()
78
74
  }
79
75
 
80
76
  pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
@@ -83,6 +79,12 @@ pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
83
79
  match lhs
84
80
  {
85
81
  Value::Null => Ordering::ComparedNull,
82
+ Value::Key(kl) => match rhs
83
+ {
84
+ Value::Key(kr) => kl.uuid().cmp(&kr.uuid()).into(),
85
+ Value::Null => Ordering::ComparedNull,
86
+ _ => Ordering::Null,
87
+ },
86
88
  Value::Boolean(bl) => match rhs
87
89
  {
88
90
  Value::Boolean(br) => bl.cmp(br).into(),
@@ -175,30 +177,21 @@ pub(crate) fn compare(lhs: &value::Value, rhs: &value::Value) -> Ordering
175
177
  },
176
178
  Value::Edge(lhs) => match rhs
177
179
  {
178
- Value::Edge(rhs) =>
179
- {
180
- lhs.key.uuid.cmp(&rhs.key.uuid).into()
181
- // let labels_cmp = lhs.labels.cmp(&rhs.labels);
182
- // match labels_cmp
183
- // {
184
- // std::cmp::Ordering::Equal => compare_map(&lhs.properties, &rhs.properties),
185
- // o => o.into(),
186
- // }
187
- }
180
+ Value::Edge(rhs) => lhs.key().uuid().cmp(&rhs.key().uuid()).into(),
188
181
  _ => Ordering::Null,
189
182
  },
190
183
  Value::Path(lhs) => match rhs
191
184
  {
192
185
  Value::Path(rhs) =>
193
186
  {
194
- let labels_cmp = lhs.labels.cmp(&rhs.labels);
187
+ let labels_cmp = lhs.labels().cmp(rhs.labels());
195
188
  match labels_cmp
196
189
  {
197
- std::cmp::Ordering::Equal => match compare_map(&lhs.properties, &rhs.properties)
190
+ std::cmp::Ordering::Equal => match compare_map(lhs.properties(), rhs.properties())
198
191
  {
199
- Ordering::Equal => match compare_node(&lhs.source, &rhs.source)
192
+ Ordering::Equal => match compare_node(lhs.source(), rhs.source())
200
193
  {
201
- Ordering::Equal => compare_node(&lhs.destination, &rhs.destination),
194
+ Ordering::Equal => compare_node(lhs.destination(), rhs.destination()),
202
195
  o => o,
203
196
  },
204
197
  o => o,
@@ -8,7 +8,7 @@ pub(crate) enum ContainResult
8
8
  }
9
9
 
10
10
  /// Compute contains, according to OpenCypher specification, specifically handling the comparison with null.
11
- pub(crate) fn contains(container: &Vec<value::Value>, value: &value::Value) -> ContainResult
11
+ pub(crate) fn contains(container: &[value::Value], value: &value::Value) -> ContainResult
12
12
  {
13
13
  if value.is_null()
14
14
  {
@@ -27,7 +27,7 @@ pub(crate) fn contains(container: &Vec<value::Value>, value: &value::Value) -> C
27
27
  for v_c in container.iter()
28
28
  {
29
29
  use value::ContainResult;
30
- match value::compare(v_c, &value)
30
+ match value::compare(v_c, value)
31
31
  {
32
32
  value::Ordering::Equal => return ContainResult::True,
33
33
  value::Ordering::ComparedNull => has_compared_to_null = true,
@@ -0,0 +1,225 @@
1
+ mod compare;
2
+ mod contains;
3
+
4
+ pub(crate) use compare::{compare, Ordering};
5
+ pub(crate) use contains::{contains, ContainResult};
6
+
7
+ pub use graphcore::{array, value_map, Value, ValueMap, ValueTryIntoRef};
8
+
9
+ pub(crate) trait ValueExt
10
+ {
11
+ fn access<'a>(&self, path: impl Iterator<Item = &'a String>) -> Value;
12
+ fn compare(&self, rhs: &Value) -> crate::value::Ordering;
13
+
14
+ /// Compute the order between self and rhs, for OrderBy, according to the OpenCypher specification.
15
+ /// This order is total.
16
+ fn orderability(&self, rhs: &Value) -> std::cmp::Ordering;
17
+ }
18
+
19
+ fn orderability_map(lhs: &ValueMap, rhs: &ValueMap) -> std::cmp::Ordering
20
+ {
21
+ let o = lhs.len().cmp(&rhs.len());
22
+ match o
23
+ {
24
+ std::cmp::Ordering::Equal => lhs
25
+ .iter()
26
+ .map(|(key, value)| value.orderability(rhs.get(key).unwrap_or(&Value::Null)))
27
+ .find(|p| *p != std::cmp::Ordering::Equal)
28
+ .unwrap_or(std::cmp::Ordering::Equal),
29
+ o => o,
30
+ }
31
+ }
32
+ fn orderability_float(lhs: &f64, rhs: &f64) -> std::cmp::Ordering
33
+ {
34
+ if lhs.is_nan()
35
+ {
36
+ if rhs.is_nan()
37
+ {
38
+ std::cmp::Ordering::Equal
39
+ }
40
+ else
41
+ {
42
+ std::cmp::Ordering::Greater
43
+ }
44
+ }
45
+ else if rhs.is_nan()
46
+ {
47
+ std::cmp::Ordering::Less
48
+ }
49
+ else
50
+ {
51
+ lhs.total_cmp(rhs)
52
+ }
53
+ }
54
+ impl ValueExt for Value
55
+ {
56
+ fn access<'a>(&self, mut path: impl Iterator<Item = &'a String>) -> Value
57
+ {
58
+ match path.next()
59
+ {
60
+ Some(name) => match self
61
+ {
62
+ Value::Node(node) => match node.properties().get(name)
63
+ {
64
+ Some(val) => val.access(path),
65
+ None => Value::Null,
66
+ },
67
+ Value::Edge(edge) => match edge.properties().get(name)
68
+ {
69
+ Some(val) => val.access(path),
70
+ None => Value::Null,
71
+ },
72
+ Value::Map(obj) => match obj.get(name)
73
+ {
74
+ Some(val) => val.access(path),
75
+ None => Value::Null,
76
+ },
77
+ _ => Value::Null,
78
+ },
79
+ None => self.to_owned(),
80
+ }
81
+ }
82
+ fn compare(&self, rhs: &Value) -> crate::value::Ordering
83
+ {
84
+ crate::value::compare(self, rhs)
85
+ }
86
+
87
+ /// Compute the order between self and rhs, for OrderBy, according to the OpenCypher specification.
88
+ /// This order is total.
89
+ fn orderability(&self, rhs: &Value) -> std::cmp::Ordering
90
+ {
91
+ match self
92
+ {
93
+ Value::Null => match rhs
94
+ {
95
+ Value::Null => std::cmp::Ordering::Equal,
96
+ _ => std::cmp::Ordering::Greater,
97
+ },
98
+ Value::Key(lhs) => match rhs
99
+ {
100
+ Value::Null => std::cmp::Ordering::Less,
101
+ Value::Key(rhs) => lhs.uuid().cmp(&rhs.uuid()),
102
+ _ => std::cmp::Ordering::Greater,
103
+ },
104
+ Value::Integer(lhs) => match rhs
105
+ {
106
+ Value::Null | Value::Key(..) => std::cmp::Ordering::Less,
107
+ Value::Integer(rhs) => lhs.cmp(rhs),
108
+ Value::Float(rhs) => orderability_float(&(*lhs as f64), rhs),
109
+ _ => std::cmp::Ordering::Greater,
110
+ },
111
+ Value::Float(lhs) => match rhs
112
+ {
113
+ Value::Null | Value::Key(..) => std::cmp::Ordering::Less,
114
+ Value::Integer(rhs) => orderability_float(lhs, &(*rhs as f64)),
115
+ Value::Float(rhs) => orderability_float(lhs, rhs),
116
+ _ => std::cmp::Ordering::Greater,
117
+ },
118
+ Value::Boolean(lhs) => match rhs
119
+ {
120
+ Value::Null | Value::Key(..) | Value::Integer(..) | Value::Float(..) =>
121
+ {
122
+ std::cmp::Ordering::Less
123
+ }
124
+ Value::Boolean(rhs) => lhs.cmp(rhs),
125
+ _ => std::cmp::Ordering::Greater,
126
+ },
127
+ Value::String(lhs) => match rhs
128
+ {
129
+ Value::Null
130
+ | Value::Key(..)
131
+ | Value::Integer(..)
132
+ | Value::Float(..)
133
+ | Value::Boolean(..) => std::cmp::Ordering::Less,
134
+ Value::String(rhs) => lhs.cmp(rhs),
135
+ _ => std::cmp::Ordering::Greater,
136
+ },
137
+ Value::Path(lhs) => match rhs
138
+ {
139
+ Value::Null
140
+ | Value::Key(..)
141
+ | Value::Integer(..)
142
+ | Value::Float(..)
143
+ | Value::Boolean(..)
144
+ | Value::String(..) => std::cmp::Ordering::Less,
145
+ Value::Path(rhs) =>
146
+ {
147
+ match orderability_map(lhs.source().properties(), rhs.source().properties())
148
+ {
149
+ std::cmp::Ordering::Equal =>
150
+ {
151
+ match orderability_map(lhs.properties(), rhs.properties())
152
+ {
153
+ std::cmp::Ordering::Equal => orderability_map(
154
+ lhs.destination().properties(),
155
+ rhs.destination().properties(),
156
+ ),
157
+ o => o,
158
+ }
159
+ }
160
+ o => o,
161
+ }
162
+ }
163
+ _ => std::cmp::Ordering::Greater,
164
+ },
165
+ Value::Array(lhs) => match rhs
166
+ {
167
+ Value::Null
168
+ | Value::Key(..)
169
+ | Value::Integer(..)
170
+ | Value::Float(..)
171
+ | Value::Boolean(..)
172
+ | Value::String(..)
173
+ | Value::Path(..) => std::cmp::Ordering::Less,
174
+ Value::Array(rhs) => lhs
175
+ .iter()
176
+ .zip(rhs.iter())
177
+ .map(|(lhs, rhs)| Self::orderability(lhs, rhs))
178
+ .find(|p| *p != std::cmp::Ordering::Equal)
179
+ .unwrap_or(lhs.len().cmp(&rhs.len())),
180
+ _ => std::cmp::Ordering::Greater,
181
+ },
182
+ Value::Edge(lhs) => match rhs
183
+ {
184
+ Value::Null
185
+ | Value::Key(..)
186
+ | Value::Integer(..)
187
+ | Value::Float(..)
188
+ | Value::Boolean(..)
189
+ | Value::String(..)
190
+ | Value::Path(..)
191
+ | Value::Array(..) => std::cmp::Ordering::Less,
192
+ Value::Edge(rhs) => orderability_map(lhs.properties(), rhs.properties()),
193
+ _ => std::cmp::Ordering::Greater,
194
+ },
195
+ Value::Node(lhs) => match rhs
196
+ {
197
+ Value::Null
198
+ | Value::Key(..)
199
+ | Value::Integer(..)
200
+ | Value::Float(..)
201
+ | Value::Boolean(..)
202
+ | Value::String(..)
203
+ | Value::Path(..)
204
+ | Value::Array(..)
205
+ | Value::Edge(..) => std::cmp::Ordering::Less,
206
+ Value::Node(rhs) => orderability_map(lhs.properties(), rhs.properties()),
207
+ _ => std::cmp::Ordering::Greater,
208
+ },
209
+ Value::Map(lhs) => match rhs
210
+ {
211
+ Value::Null
212
+ | Value::Key(..)
213
+ | Value::Integer(..)
214
+ | Value::Float(..)
215
+ | Value::Boolean(..)
216
+ | Value::String(..)
217
+ | Value::Path(..)
218
+ | Value::Array(..)
219
+ | Value::Edge(..)
220
+ | Value::Node(..) => std::cmp::Ordering::Less,
221
+ Value::Map(rhs) => orderability_map(lhs, rhs),
222
+ },
223
+ }
224
+ }
225
+ }
@@ -11,6 +11,7 @@ pub(crate) trait RowInterface: Debug
11
11
  {
12
12
  Ok(self.get(index)?.to_owned())
13
13
  }
14
+ #[cfg(test)]
14
15
  fn len(&self) -> usize;
15
16
  }
16
17
 
@@ -52,7 +53,7 @@ impl Row
52
53
  {
53
54
  Err(
54
55
  InternalError::InvalidIndex {
55
- index: index,
56
+ index,
56
57
  length: self.values.len(),
57
58
  }
58
59
  .into(),
@@ -97,6 +98,7 @@ impl RowInterface for Row
97
98
  .into()
98
99
  })
99
100
  }
101
+ #[cfg(test)]
100
102
  fn len(&self) -> usize
101
103
  {
102
104
  self.values.len()
@@ -136,11 +138,11 @@ impl MutableRowInterface for Row
136
138
  }
137
139
  }
138
140
 
139
- impl Into<value::Value> for Row
141
+ impl From<Row> for value::Value
140
142
  {
141
- fn into(self) -> value::Value
143
+ fn from(v: Row) -> Self
142
144
  {
143
- value::Value::Array(self.values)
145
+ value::Value::Array(v.values)
144
146
  }
145
147
  }
146
148
 
@@ -152,10 +154,19 @@ impl FromIterator<value::Value> for Row
152
154
  }
153
155
  }
154
156
 
157
+ impl IntoIterator for Row
158
+ {
159
+ type Item = value::Value;
160
+ type IntoIter = <Vec<Self::Item> as IntoIterator>::IntoIter;
161
+ fn into_iter(self) -> Self::IntoIter
162
+ {
163
+ self.values.into_iter()
164
+ }
165
+ }
166
+
155
167
  pub(crate) trait Header
156
168
  {
157
169
  fn columns(&self) -> usize;
158
- fn titles(&self) -> Option<Vec<String>>;
159
170
  }
160
171
 
161
172
  impl Header for usize
@@ -164,10 +175,6 @@ impl Header for usize
164
175
  {
165
176
  *self
166
177
  }
167
- fn titles(&self) -> Option<Vec<String>>
168
- {
169
- None
170
- }
171
178
  }
172
179
 
173
180
  impl Header for Vec<String>
@@ -176,10 +183,6 @@ impl Header for Vec<String>
176
183
  {
177
184
  self.len()
178
185
  }
179
- fn titles(&self) -> Option<Vec<String>>
180
- {
181
- Some(self.clone())
182
- }
183
186
  }
184
187
 
185
188
  #[derive(Debug)]
@@ -256,12 +259,14 @@ where
256
259
  Ok(())
257
260
  }
258
261
 
262
+ #[allow(dead_code)]
259
263
  pub fn row_count(&self) -> usize
260
264
  {
261
265
  self.row_count
262
266
  }
263
267
 
264
268
  /// Create a RowView into a specific row
269
+ #[allow(dead_code)]
265
270
  pub fn row_view(&self, row_index: usize) -> Option<RowView<'_>>
266
271
  {
267
272
  if self.header.columns() == 0 && row_index >= self.row_count
@@ -302,10 +307,6 @@ where
302
307
  index: 0,
303
308
  }
304
309
  }
305
- pub(crate) fn first_row(&self) -> Option<RowView>
306
- {
307
- self.row_view(0)
308
- }
309
310
  pub(crate) fn remove_first_rows(&mut self, n: usize)
310
311
  {
311
312
  let n = n * self.header.columns();
@@ -334,6 +335,7 @@ pub(crate) struct RowView<'a>
334
335
 
335
336
  impl<'a> RowView<'a>
336
337
  {
338
+ #[allow(dead_code)]
337
339
  /// Create an owned Row by cloning the values in this row view
338
340
  pub fn to_row(&self) -> Row
339
341
  {
@@ -341,6 +343,7 @@ impl<'a> RowView<'a>
341
343
  values: self.row.to_vec(),
342
344
  }
343
345
  }
346
+ #[allow(dead_code)]
344
347
  /// Create an owned Row by cloning the values in this row view, and extend it to the given size
345
348
  pub fn to_extended_row(&self, length: usize) -> Result<Row>
346
349
  {
@@ -363,6 +366,7 @@ impl<'a> RowInterface for RowView<'a>
363
366
  .into()
364
367
  })
365
368
  }
369
+ #[cfg(test)]
366
370
  fn len(&self) -> usize
367
371
  {
368
372
  self.row.len()
@@ -449,7 +453,7 @@ impl Iterator for IntoRowIter
449
453
  else
450
454
  {
451
455
  let v: Vec<_> = self.data.by_ref().take(self.columns).collect();
452
- if v.len() == 0
456
+ if v.is_empty()
453
457
  {
454
458
  None
455
459
  }
@@ -1,43 +1,21 @@
1
- # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2
- #
3
- # When uploading crates to the registry Cargo will automatically
4
- # "normalize" Cargo.toml files for maximal compatibility
5
- # with all versions of Cargo and also rewrite `path` dependencies
6
- # to registry (e.g., crates.io) dependencies.
7
- #
8
- # If you are reading this file be aware that the original Cargo.toml
9
- # will likely look very different (and much more reasonable).
10
- # See Cargo.toml.orig for the original contents.
11
-
12
1
  [package]
13
- edition = "2021"
14
2
  name = "gqliterb"
15
- version = "0.5.2"
16
- build = false
17
- autolib = false
18
- autobins = false
19
- autoexamples = false
20
- autotests = false
21
- autobenches = false
22
3
  description = "Crate with the Ruby bindings for GQLite."
23
- homepage = "https://gqlite.org"
24
- readme = false
25
- license = "MIT"
26
- repository = "https://gitlab.com/gqlite/gqlite"
27
-
28
- [package.metadata.release]
29
- release = false
4
+ version.workspace = true
5
+ edition.workspace = true
6
+ license.workspace = true
7
+ homepage.workspace = true
8
+ repository.workspace = true
30
9
 
31
10
  [lib]
32
- name = "gqliterb"
33
11
  crate-type = ["cdylib"]
34
- path = "src/lib.rs"
35
12
 
36
- [dependencies.gqlitedb]
37
- version = "0.5.2"
13
+ [dependencies]
14
+ gqlitedb = { workspace = true }
15
+ magnus = "0.8"
38
16
 
39
- [dependencies.magnus]
40
- version = "0.7"
17
+ [build-dependencies]
18
+ rb-sys-env = "0.2"
41
19
 
42
- [build-dependencies.rb-sys-env]
43
- version = "0.2"
20
+ [package.metadata.release]
21
+ release = false