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.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +10 -4
- 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 -9
- 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 +1 -1
- data/ext/gqlitedb/src/compiler/expression_analyser.rs +28 -20
- data/ext/gqlitedb/src/compiler/variables_manager.rs +97 -29
- data/ext/gqlitedb/src/compiler.rs +505 -225
- data/ext/gqlitedb/src/connection.rs +149 -11
- data/ext/gqlitedb/src/consts.rs +1 -2
- data/ext/gqlitedb/src/error.rs +123 -61
- data/ext/gqlitedb/src/functions/common.rs +39 -2
- data/ext/gqlitedb/src/functions/math.rs +8 -3
- data/ext/gqlitedb/src/functions/path.rs +48 -11
- data/ext/gqlitedb/src/functions/value.rs +1 -1
- data/ext/gqlitedb/src/functions.rs +23 -7
- 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/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 +735 -7
- 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 +569 -5
- data/ext/gqlitedb/src/store/vector_extract.rs +56 -0
- data/ext/gqlitedb/src/store.rs +123 -3
- 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 +90 -22
- 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
|
@@ -1,104 +1,127 @@
|
|
|
1
|
-
use std::fmt;
|
|
2
|
-
|
|
3
|
-
use jiff::{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
|
|
11
|
-
pub fn
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
}
|
|
34
|
-
/// Return the
|
|
35
|
-
pub fn
|
|
36
|
-
{
|
|
37
|
-
self.0.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
}
|