gqlite 1.5.1 → 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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Cargo.toml +10 -4
  3. data/ext/db-index/Cargo.toml +29 -0
  4. data/ext/db-index/src/hnsw/error.rs +66 -0
  5. data/ext/db-index/src/hnsw/graph_store.rs +272 -0
  6. data/ext/db-index/src/hnsw/id.rs +36 -0
  7. data/ext/db-index/src/hnsw/implementation.rs +1517 -0
  8. data/ext/db-index/src/hnsw/kernels.rs +1228 -0
  9. data/ext/db-index/src/hnsw/metric.rs +244 -0
  10. data/ext/db-index/src/hnsw/scalar.rs +72 -0
  11. data/ext/db-index/src/hnsw/simple_store.rs +140 -0
  12. data/ext/db-index/src/hnsw/store.rs +472 -0
  13. data/ext/db-index/src/hnsw/vector.rs +105 -0
  14. data/ext/db-index/src/hnsw/vectors.rs +568 -0
  15. data/ext/db-index/src/hnsw.rs +42 -0
  16. data/ext/db-index/src/lib.rs +3 -0
  17. data/ext/gqlitedb/Cargo.toml +19 -9
  18. data/ext/gqlitedb/benches/common/pokec.rs +62 -2
  19. data/ext/gqlitedb/benches/pokec_divan.rs +66 -2
  20. data/ext/gqlitedb/benches/pokec_iai.rs +60 -3
  21. data/ext/gqlitedb/release.toml +2 -2
  22. data/ext/gqlitedb/src/aggregators/arithmetic.rs +3 -1
  23. data/ext/gqlitedb/src/aggregators/containers.rs +1 -1
  24. data/ext/gqlitedb/src/aggregators/stats.rs +21 -12
  25. data/ext/gqlitedb/src/capi.rs +1 -1
  26. data/ext/gqlitedb/src/compiler/expression_analyser.rs +28 -20
  27. data/ext/gqlitedb/src/compiler/variables_manager.rs +97 -29
  28. data/ext/gqlitedb/src/compiler.rs +505 -225
  29. data/ext/gqlitedb/src/connection.rs +149 -11
  30. data/ext/gqlitedb/src/consts.rs +1 -2
  31. data/ext/gqlitedb/src/error.rs +123 -61
  32. data/ext/gqlitedb/src/functions/common.rs +39 -2
  33. data/ext/gqlitedb/src/functions/math.rs +8 -3
  34. data/ext/gqlitedb/src/functions/path.rs +48 -11
  35. data/ext/gqlitedb/src/functions/value.rs +1 -1
  36. data/ext/gqlitedb/src/functions.rs +23 -7
  37. data/ext/gqlitedb/src/graph.rs +1 -9
  38. data/ext/gqlitedb/src/interpreter/evaluators.rs +968 -130
  39. data/ext/gqlitedb/src/interpreter/instructions.rs +39 -2
  40. data/ext/gqlitedb/src/lib.rs +5 -4
  41. data/ext/gqlitedb/src/planner.rs +329 -0
  42. data/ext/gqlitedb/src/prelude.rs +3 -3
  43. data/ext/gqlitedb/src/store/pgrx.rs +1 -1
  44. data/ext/gqlitedb/src/store/postgres.rs +735 -7
  45. data/ext/gqlitedb/src/store/redb/hnsw_store.rs +702 -0
  46. data/ext/gqlitedb/src/store/redb/index.rs +274 -0
  47. data/ext/gqlitedb/src/store/redb.rs +1268 -113
  48. data/ext/gqlitedb/src/store/sqlbase/sqlmetadata.rs +28 -0
  49. data/ext/gqlitedb/src/store/sqlbase/sqlstore.rs +103 -0
  50. data/ext/gqlitedb/src/store/sqlbase.rs +146 -16
  51. data/ext/gqlitedb/src/store/sqlite.rs +569 -5
  52. data/ext/gqlitedb/src/store/vector_extract.rs +56 -0
  53. data/ext/gqlitedb/src/store.rs +123 -3
  54. data/ext/gqlitedb/src/tests/compiler.rs +207 -10
  55. data/ext/gqlitedb/src/tests/connection/postgres.rs +38 -3
  56. data/ext/gqlitedb/src/tests/connection/redb.rs +23 -0
  57. data/ext/gqlitedb/src/tests/connection/sqlite.rs +31 -0
  58. data/ext/gqlitedb/src/tests/connection.rs +61 -1
  59. data/ext/gqlitedb/src/tests/evaluators.rs +162 -7
  60. data/ext/gqlitedb/src/tests/parser.rs +54 -23
  61. data/ext/gqlitedb/src/tests/planner.rs +511 -0
  62. data/ext/gqlitedb/src/tests/store/postgres.rs +7 -0
  63. data/ext/gqlitedb/src/tests/store/redb.rs +8 -0
  64. data/ext/gqlitedb/src/tests/store/sqlite.rs +8 -0
  65. data/ext/gqlitedb/src/tests/store/vector_index/postgres.rs +182 -0
  66. data/ext/gqlitedb/src/tests/store/vector_index/redb.rs +386 -0
  67. data/ext/gqlitedb/src/tests/store/vector_index/sqlite.rs +166 -0
  68. data/ext/gqlitedb/src/tests/store/vector_index.rs +2313 -0
  69. data/ext/gqlitedb/src/tests/store.rs +78 -14
  70. data/ext/gqlitedb/src/tests/templates/ast.rs +92 -16
  71. data/ext/gqlitedb/src/tests/templates/programs.rs +14 -7
  72. data/ext/gqlitedb/src/tests.rs +15 -9
  73. data/ext/gqlitedb/src/utils.rs +6 -1
  74. data/ext/gqlitedb/src/value/compare.rs +61 -3
  75. data/ext/gqlitedb/src/value.rs +136 -7
  76. data/ext/gqlitedb/templates/sql/postgres/metadata_delete.sql +1 -0
  77. data/ext/gqlitedb/templates/sql/postgres/node_select.sql +1 -1
  78. data/ext/gqlitedb/templates/sql/sqlite/metadata_delete.sql +1 -0
  79. data/ext/gqliterb/src/lib.rs +53 -8
  80. data/ext/gqlparser/Cargo.toml +25 -0
  81. data/ext/gqlparser/README.MD +9 -0
  82. data/ext/gqlparser/benches/pokec_divan.rs +34 -0
  83. data/ext/gqlparser/src/common.rs +69 -0
  84. data/ext/gqlparser/src/gqls/ast.rs +69 -0
  85. data/ext/gqlparser/src/gqls/constraint.rs +79 -0
  86. data/ext/gqlparser/src/gqls/error.rs +22 -0
  87. data/ext/gqlparser/src/gqls/parser.rs +813 -0
  88. data/ext/gqlparser/src/gqls/prelude.rs +8 -0
  89. data/ext/gqlparser/src/gqls/properties.rs +115 -0
  90. data/ext/gqlparser/src/gqls/resolve.rs +207 -0
  91. data/ext/gqlparser/src/gqls.rs +265 -0
  92. data/ext/gqlparser/src/lib.rs +7 -0
  93. data/ext/gqlparser/src/oc/ast.rs +680 -0
  94. data/ext/gqlparser/src/oc/error.rs +172 -0
  95. data/ext/gqlparser/src/oc/lexer.rs +429 -0
  96. data/ext/gqlparser/src/oc/parser/tests.rs +2284 -0
  97. data/ext/gqlparser/src/oc/parser.rs +2005 -0
  98. data/ext/gqlparser/src/oc.rs +33 -0
  99. data/ext/gqlparser/src/prelude.rs +3 -0
  100. data/ext/graphcore/Cargo.toml +1 -0
  101. data/ext/graphcore/src/error.rs +26 -0
  102. data/ext/graphcore/src/graph.rs +177 -51
  103. data/ext/graphcore/src/lib.rs +4 -2
  104. data/ext/graphcore/src/open_cypher.rs +12 -0
  105. data/ext/graphcore/src/table.rs +50 -2
  106. data/ext/graphcore/src/timestamp.rs +127 -104
  107. data/ext/graphcore/src/value/tensor.rs +739 -0
  108. data/ext/graphcore/src/value/value_map.rs +1 -1
  109. data/ext/graphcore/src/value.rs +343 -19
  110. metadata +90 -22
  111. data/ext/gqlitedb/src/parser/ast.rs +0 -604
  112. data/ext/gqlitedb/src/parser/parser_impl.rs +0 -1213
  113. data/ext/gqlitedb/src/parser.rs +0 -4
@@ -1,104 +1,127 @@
1
- use std::fmt;
2
-
3
- use jiff::{tz::TimeZone, Zoned};
4
- use serde::{Deserialize, Serialize};
5
-
6
- ccutils::alias!(#[doc = "Represent a timestamp"] pub TimeStamp, Zoned, display, derive: Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord);
7
-
8
- impl TimeStamp
9
- {
10
- /// Create a new time stamp with the given unix timestamp and offset
11
- pub fn from_unix_timestamp(
12
- seconds: i64,
13
- nanoseconds: i32,
14
- offset_whole_seconds: i32,
15
- ) -> Result<TimeStamp, crate::Error>
16
- {
17
- let ts = jiff::Timestamp::new(seconds, nanoseconds)?;
18
- Ok(Self(ts.to_zoned(jiff::tz::TimeZone::fixed(
19
- jiff::tz::Offset::from_seconds(offset_whole_seconds)?,
20
- ))))
21
- }
22
-
23
- /// Convert from the current time zone to Utc (aka offset == 0)
24
- pub fn to_utc(&self) -> TimeStamp
25
- {
26
- Self(self.with_time_zone(TimeZone::UTC))
27
- }
28
- /// Return the unix timestamp
29
- pub fn unix_timestamp(&self) -> (i64, i32)
30
- {
31
- let ts = self.0.timestamp();
32
- (ts.as_second(), ts.subsec_nanosecond())
33
- }
34
- /// Return the number of whole seconds in the offset
35
- pub fn offset_seconds(&self) -> i32
36
- {
37
- self.0.offset().seconds()
38
- }
39
- /// Return the year in the timestamp timezone
40
- pub fn year(&self) -> i16
41
- {
42
- self.0.year()
43
- }
44
- /// Return the month in the timestamp timezone
45
- pub fn month(&self) -> i8
46
- {
47
- self.0.month()
48
- }
49
- /// Return the day in the timestamp timezone
50
- pub fn day(&self) -> i8
51
- {
52
- self.0.day()
53
- }
54
- /// Return the hour in the timestamp timezone
55
- pub fn hour(&self) -> i8
56
- {
57
- self.0.hour()
58
- }
59
- /// Return the minute in the timestamp timezone
60
- pub fn minute(&self) -> i8
61
- {
62
- self.0.minute()
63
- }
64
- /// Return the second in the timestamp timezone
65
- pub fn second(&self) -> i8
66
- {
67
- self.0.second()
68
- }
69
- /// Return the microseconds in the timestamp timezone
70
- pub fn microsecond(&self) -> i16
71
- {
72
- self.0.microsecond()
73
- }
74
- /// Parse the time string
75
- pub fn parse(date: &str) -> Result<TimeStamp, crate::Error>
76
- {
77
- Ok(TimeStamp(date.parse()?))
78
- }
79
- }
80
-
81
- // Serde impl
82
-
83
- impl Serialize for TimeStamp
84
- {
85
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
86
- where
87
- S: serde::Serializer,
88
- {
89
- self.0.to_string().serialize(serializer)
90
- }
91
- }
92
-
93
- impl<'de> Deserialize<'de> for TimeStamp
94
- {
95
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
96
- where
97
- D: serde::Deserializer<'de>,
98
- {
99
- use serde::de::Error;
100
- let s = String::deserialize(deserializer)?;
101
- TimeStamp::parse(&s)
102
- .map_err(|e| D::Error::custom(format!("Error deserializing timestamp: {}.", e)))
103
- }
104
- }
1
+ use std::fmt;
2
+
3
+ use jiff::{Zoned, tz::TimeZone};
4
+ use serde::{Deserialize, Serialize};
5
+
6
+ ccutils::alias!(#[doc = "Represent a timestamp"] pub TimeStamp, Zoned, display, derive: Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord);
7
+
8
+ impl TimeStamp
9
+ {
10
+ /// Create a new timestamp with the current time
11
+ pub fn now() -> Self
12
+ {
13
+ let ts = jiff::Zoned::now();
14
+ Self(ts)
15
+ }
16
+ /// Create a new time stamp with the given unix timestamp and offset
17
+ pub fn from_unix_timestamp(
18
+ seconds: i64,
19
+ nanoseconds: i32,
20
+ offset_whole_seconds: i32,
21
+ ) -> Result<TimeStamp, crate::Error>
22
+ {
23
+ let ts = jiff::Timestamp::new(seconds, nanoseconds)?;
24
+ Ok(Self(ts.to_zoned(jiff::tz::TimeZone::fixed(
25
+ jiff::tz::Offset::from_seconds(offset_whole_seconds)?,
26
+ ))))
27
+ }
28
+
29
+ /// Convert from the current time zone to Utc (aka offset == 0)
30
+ pub fn to_utc(&self) -> TimeStamp
31
+ {
32
+ Self(self.with_time_zone(TimeZone::UTC))
33
+ }
34
+ /// Return the unix timestamp
35
+ pub fn unix_timestamp(&self) -> (i64, i32)
36
+ {
37
+ let ts = self.0.timestamp();
38
+ (ts.as_second(), ts.subsec_nanosecond())
39
+ }
40
+ /// Return the number of whole seconds in the offset
41
+ pub fn offset_seconds(&self) -> i32
42
+ {
43
+ self.0.offset().seconds()
44
+ }
45
+ /// Return the year in the timestamp timezone
46
+ pub fn year(&self) -> i16
47
+ {
48
+ self.0.year()
49
+ }
50
+ /// Return the month in the timestamp timezone
51
+ pub fn month(&self) -> i8
52
+ {
53
+ self.0.month()
54
+ }
55
+ /// Return the day in the timestamp timezone
56
+ pub fn day(&self) -> i8
57
+ {
58
+ self.0.day()
59
+ }
60
+ /// Return the hour in the timestamp timezone
61
+ pub fn hour(&self) -> i8
62
+ {
63
+ self.0.hour()
64
+ }
65
+ /// Return the minute in the timestamp timezone
66
+ pub fn minute(&self) -> i8
67
+ {
68
+ self.0.minute()
69
+ }
70
+ /// Return the second in the timestamp timezone
71
+ pub fn second(&self) -> i8
72
+ {
73
+ self.0.second()
74
+ }
75
+ /// Return the microseconds in the timestamp timezone
76
+ pub fn microsecond(&self) -> i16
77
+ {
78
+ self.0.microsecond()
79
+ }
80
+ /// Parse the time string
81
+ pub fn parse(date: &str) -> Result<TimeStamp, crate::Error>
82
+ {
83
+ Ok(TimeStamp(date.parse()?))
84
+ }
85
+ }
86
+
87
+ // Serde impl
88
+
89
+ impl Serialize for TimeStamp
90
+ {
91
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
92
+ where
93
+ S: serde::Serializer,
94
+ {
95
+ self.0.to_string().serialize(serializer)
96
+ }
97
+ }
98
+
99
+ impl<'de> Deserialize<'de> for TimeStamp
100
+ {
101
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
102
+ where
103
+ D: serde::Deserializer<'de>,
104
+ {
105
+ use serde::de::Error;
106
+ let s = String::deserialize(deserializer)?;
107
+ TimeStamp::parse(&s)
108
+ .map_err(|e| D::Error::custom(format!("Error deserializing timestamp: {}.", e)))
109
+ }
110
+ }
111
+
112
+ // Reference-based comparison traits for constraint validation in generated code
113
+ impl std::cmp::PartialOrd<&TimeStamp> for TimeStamp
114
+ {
115
+ fn partial_cmp(&self, other: &&TimeStamp) -> Option<std::cmp::Ordering>
116
+ {
117
+ self.partial_cmp(*other)
118
+ }
119
+ }
120
+
121
+ impl std::cmp::PartialEq<&TimeStamp> for TimeStamp
122
+ {
123
+ fn eq(&self, other: &&TimeStamp) -> bool
124
+ {
125
+ self.eq(*other)
126
+ }
127
+ }