gqlite 1.1.0 → 1.2.2
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/gqliterb/.cargo/config.toml +2 -0
- data/ext/gqliterb/Cargo.lock +1109 -0
- data/ext/gqliterb/Cargo.toml +43 -0
- data/ext/gqliterb/extconf.rb +4 -0
- data/ext/gqliterb/src/lib.rs +260 -0
- data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +2060 -0
- data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +132 -0
- data/ext/gqliterb/vendor/gqlitedb/askama.toml +3 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/common/mod.rs +25 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/common/pokec.rs +185 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/pokec_divan.rs +137 -0
- data/ext/gqliterb/vendor/gqlitedb/benches/pokec_iai.rs +122 -0
- data/ext/gqliterb/vendor/gqlitedb/release.toml +7 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/arithmetic.rs +96 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/containers.rs +33 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/count.rs +35 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators/stats.rs +168 -0
- data/ext/gqliterb/vendor/gqlitedb/src/aggregators.rs +74 -0
- data/ext/gqliterb/vendor/gqlitedb/src/capi.rs +236 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler/expression_analyser.rs +427 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler/variables_manager.rs +620 -0
- data/ext/gqliterb/vendor/gqlitedb/src/compiler.rs +1106 -0
- data/ext/gqliterb/vendor/gqlitedb/src/connection.rs +208 -0
- data/ext/gqliterb/vendor/gqlitedb/src/consts.rs +10 -0
- data/ext/gqliterb/vendor/gqlitedb/src/error.rs +621 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/containers.rs +115 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/edge.rs +20 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/math.rs +44 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/node.rs +16 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/path.rs +48 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/scalar.rs +86 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/string.rs +28 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions/value.rs +99 -0
- data/ext/gqliterb/vendor/gqlitedb/src/functions.rs +412 -0
- data/ext/gqliterb/vendor/gqlitedb/src/graph.rs +268 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/evaluators.rs +1788 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/instructions.rs +262 -0
- data/ext/gqliterb/vendor/gqlitedb/src/interpreter/mod.rs +4 -0
- data/ext/gqliterb/vendor/gqlitedb/src/lib.rs +42 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/ast.rs +625 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/gql.pest +191 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser/parser.rs +1153 -0
- data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +4 -0
- data/ext/gqliterb/vendor/gqlitedb/src/prelude.rs +8 -0
- data/ext/gqliterb/vendor/gqlitedb/src/serialize_with.rs +94 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/pgql.rs +121 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/redb.rs +1250 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store/sqlite.rs +994 -0
- data/ext/gqliterb/vendor/gqlitedb/src/store.rs +432 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/compiler.rs +92 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/evaluators.rs +227 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/parser.rs +81 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store/redb.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store/sqlite.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/store.rs +462 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/ast.rs +356 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates/programs.rs +455 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests/templates.rs +2 -0
- data/ext/gqliterb/vendor/gqlitedb/src/tests.rs +39 -0
- data/ext/gqliterb/vendor/gqlitedb/src/utils.rs +28 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/compare.rs +212 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/contains.rs +47 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value/value_map.rs +298 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value.rs +559 -0
- data/ext/gqliterb/vendor/gqlitedb/src/value_table.rs +616 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/call_stats.sql +22 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_count_for_node.sql +3 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_create.sql +6 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete_by_nodes.sql +2 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_select.sql +139 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_update.sql +4 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_create.sql +16 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_delete.sql +3 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_create_table.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_get.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_set.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_create.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_delete.sql +1 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_select.sql +42 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_update.sql +4 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/table_exists.sql +5 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_from_1_01.sql +2 -0
- data/ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_graph_from_1_01.sql +65 -0
- data/lib/gqlite.rb +1 -75
- metadata +118 -25
- data/ext/gqlite/extconf.rb +0 -21
- data/ext/gqlite/gqlite-amalgamate.cpp +0 -9599
- data/ext/gqlite/gqlite-c.h +0 -95
- data/ext/gqlite/gqlite.h +0 -141
@@ -0,0 +1,139 @@
|
|
1
|
+
SELECT
|
2
|
+
e.edge_key AS edge_key,
|
3
|
+
e.labels AS edge_labels,
|
4
|
+
e.properties AS edge_properties,
|
5
|
+
{% if is_undirected %}e.reversed{% else %}0{% endif %} AS edge_reversed,
|
6
|
+
|
7
|
+
n_left.node_key AS left_node_key,
|
8
|
+
n_left.labels AS left_node_labels,
|
9
|
+
n_left.properties AS left_node_properties,
|
10
|
+
|
11
|
+
n_right.node_key AS right_node_key,
|
12
|
+
n_right.labels AS right_node_labels,
|
13
|
+
n_right.properties AS right_node_properties
|
14
|
+
|
15
|
+
FROM gqlite_{{ graph_name }}_edges{{ table_suffix }} AS e
|
16
|
+
JOIN gqlite_{{ graph_name }}_nodes AS n_left ON e.left = n_left.id
|
17
|
+
JOIN gqlite_{{ graph_name }}_nodes AS n_right ON e.right = n_right.id
|
18
|
+
WHERE
|
19
|
+
-- Filter by key list (if not empty)
|
20
|
+
{% if has_edge_keys %}
|
21
|
+
(
|
22
|
+
hex(e.edge_key) IN (
|
23
|
+
SELECT value FROM json_each(:edge_keys)
|
24
|
+
)
|
25
|
+
)
|
26
|
+
{% else %}
|
27
|
+
1
|
28
|
+
{% endif %}
|
29
|
+
AND
|
30
|
+
{% if has_edge_labels %}
|
31
|
+
-- Filter by required labels (must all be in e.labels)
|
32
|
+
(
|
33
|
+
NOT EXISTS (
|
34
|
+
SELECT 1
|
35
|
+
FROM json_each(:edge_labels) AS required_label
|
36
|
+
WHERE NOT EXISTS (
|
37
|
+
SELECT 1
|
38
|
+
FROM json_each(e.labels) AS edge_label
|
39
|
+
WHERE edge_label.value = required_label.value
|
40
|
+
)
|
41
|
+
)
|
42
|
+
)
|
43
|
+
{% else %}
|
44
|
+
1
|
45
|
+
{% endif %}
|
46
|
+
AND
|
47
|
+
{% if has_edge_properties %}
|
48
|
+
-- Filter by required properties (must all exist and match)
|
49
|
+
NOT EXISTS (
|
50
|
+
SELECT 1
|
51
|
+
FROM json_each(:edge_properties) AS required_prop
|
52
|
+
WHERE json_extract(e.properties, '$.' || required_prop.key) IS NULL
|
53
|
+
OR json_extract(e.properties, '$.' || required_prop.key) != required_prop.value
|
54
|
+
)
|
55
|
+
{% else %}
|
56
|
+
1
|
57
|
+
{% endif %}
|
58
|
+
-- Filter by key list (if not empty)
|
59
|
+
AND
|
60
|
+
{% if has_n_left_keys %}
|
61
|
+
(
|
62
|
+
hex(n_left.node_key) IN (
|
63
|
+
SELECT value FROM json_each(:n_left_keys)
|
64
|
+
)
|
65
|
+
)
|
66
|
+
{% else %}
|
67
|
+
1
|
68
|
+
{% endif %}
|
69
|
+
AND
|
70
|
+
{% if has_n_left_labels %}
|
71
|
+
-- Filter by required labels (must all be in n_left.labels)
|
72
|
+
(
|
73
|
+
NOT EXISTS (
|
74
|
+
SELECT 1
|
75
|
+
FROM json_each(:n_left_labels) AS required_label
|
76
|
+
WHERE NOT EXISTS (
|
77
|
+
SELECT 1
|
78
|
+
FROM json_each(n_left.labels) AS node_label
|
79
|
+
WHERE node_label.value = required_label.value
|
80
|
+
)
|
81
|
+
)
|
82
|
+
)
|
83
|
+
{% else %}
|
84
|
+
1
|
85
|
+
{% endif %}
|
86
|
+
AND
|
87
|
+
{% if has_n_left_properties %}
|
88
|
+
-- Filter by required properties (must all exist and match)
|
89
|
+
(
|
90
|
+
NOT EXISTS (
|
91
|
+
SELECT 1
|
92
|
+
FROM json_each(:n_left_properties) AS required_prop
|
93
|
+
WHERE json_extract(n_left.properties, '$.' || required_prop.key) IS NULL
|
94
|
+
OR json_extract(n_left.properties, '$.' || required_prop.key) != required_prop.value
|
95
|
+
)
|
96
|
+
)
|
97
|
+
{% else %}
|
98
|
+
1
|
99
|
+
{% endif %}
|
100
|
+
AND
|
101
|
+
-- Filter by key list (if not empty)
|
102
|
+
{% if has_n_right_keys %}
|
103
|
+
(
|
104
|
+
hex(n_right.node_key) IN (
|
105
|
+
SELECT value FROM json_each(:n_right_keys)
|
106
|
+
)
|
107
|
+
)
|
108
|
+
{% else %}
|
109
|
+
1
|
110
|
+
{% endif %}
|
111
|
+
AND
|
112
|
+
{% if has_n_right_labels %}
|
113
|
+
-- Filter by required labels (must all be in n_right.labels)
|
114
|
+
(
|
115
|
+
NOT EXISTS (
|
116
|
+
SELECT 1
|
117
|
+
FROM json_each(:n_right_labels) AS required_label
|
118
|
+
WHERE NOT EXISTS (
|
119
|
+
SELECT 1
|
120
|
+
FROM json_each(n_right.labels) AS node_label
|
121
|
+
WHERE node_label.value = required_label.value
|
122
|
+
)
|
123
|
+
)
|
124
|
+
)
|
125
|
+
{% else %}
|
126
|
+
1
|
127
|
+
{% endif %}
|
128
|
+
|
129
|
+
{% if has_n_right_properties %}
|
130
|
+
-- Filter by required properties (must all exist and match)
|
131
|
+
AND (
|
132
|
+
NOT EXISTS (
|
133
|
+
SELECT 1
|
134
|
+
FROM json_each(:n_right_properties) AS required_prop
|
135
|
+
WHERE json_extract(n_right.properties, '$.' || required_prop.key) IS NULL
|
136
|
+
OR json_extract(n_right.properties, '$.' || required_prop.key) != required_prop.value
|
137
|
+
)
|
138
|
+
);
|
139
|
+
{% endif %}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
CREATE TABLE gqlite_{{ graph_name }}_nodes(id INTEGER PRIMARY KEY AUTOINCREMENT, node_key BLOB NOT NULL, labels TEXT NOT NULL, properties TEXT NOT NULL);
|
2
|
+
CREATE TABLE gqlite_{{ graph_name }}_edges(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
3
|
+
edge_key BLOB NOT NULL,
|
4
|
+
labels TEXT NOT NULL,
|
5
|
+
properties TEXT NOT NULL,
|
6
|
+
left INTEGER NOT NULL,
|
7
|
+
right INTEGER NOT NULL,
|
8
|
+
FOREIGN KEY(left) REFERENCES gqlite_{{ graph_name }}_nodes(id), FOREIGN KEY(right) REFERENCES gqlite_{{ graph_name }}_nodes(id));
|
9
|
+
|
10
|
+
---------------- views ----------------
|
11
|
+
|
12
|
+
-- view for querying for undirected edges
|
13
|
+
CREATE VIEW gqlite_{{ graph_name }}_edges_undirected (id, edge_key, labels, properties, left, right, reversed) AS
|
14
|
+
SELECT id, edge_key, labels, properties, left, right, 0 FROM gqlite_{{ graph_name }}_edges
|
15
|
+
UNION SELECT id, edge_key, labels, properties, right, left, 1 FROM gqlite_{{ graph_name }}_edges;
|
16
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
CREATE TABLE gqlite_metadata(name TEXT PRIMARY KEY, value TEXT NOT NULL)
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT value FROM gqlite_metadata WHERE name=:name
|
@@ -0,0 +1 @@
|
|
1
|
+
INSERT INTO gqlite_metadata (name, value) VALUES (:name, :value) ON CONFLICT(name) DO UPDATE SET value=:value
|
@@ -0,0 +1 @@
|
|
1
|
+
INSERT INTO gqlite_{{ graph_name }}_nodes (node_key, labels, properties) VALUES (?1, ?2, ?3)
|
@@ -0,0 +1 @@
|
|
1
|
+
DELETE FROM gqlite_{{ graph_name }}_nodes WHERE hex(node_key) IN ('{{ keys | join("', '") }}')
|
@@ -0,0 +1,42 @@
|
|
1
|
+
SELECT node_key, labels, properties
|
2
|
+
FROM gqlite_{{ graph_name }}_nodes AS nodes
|
3
|
+
WHERE
|
4
|
+
-- Filter by key list (if not empty)
|
5
|
+
{% if has_keys %}
|
6
|
+
(
|
7
|
+
hex(nodes.node_key) IN (
|
8
|
+
SELECT value FROM json_each(:keys)
|
9
|
+
)
|
10
|
+
)
|
11
|
+
{% else %}
|
12
|
+
1
|
13
|
+
{% endif %}
|
14
|
+
AND
|
15
|
+
{% if has_labels %}
|
16
|
+
-- Filter by required labels (must all be in nodes.labels)
|
17
|
+
(
|
18
|
+
NOT EXISTS (
|
19
|
+
SELECT 1
|
20
|
+
FROM json_each(:labels) AS required_label
|
21
|
+
WHERE NOT EXISTS (
|
22
|
+
SELECT 1
|
23
|
+
FROM json_each(nodes.labels) AS node_label
|
24
|
+
WHERE node_label.value = required_label.value
|
25
|
+
)
|
26
|
+
)
|
27
|
+
)
|
28
|
+
{% else %}
|
29
|
+
1
|
30
|
+
{% endif %}
|
31
|
+
|
32
|
+
{% if has_properties %}
|
33
|
+
-- Filter by required properties (must all exist and match)
|
34
|
+
AND (
|
35
|
+
NOT EXISTS (
|
36
|
+
SELECT 1
|
37
|
+
FROM json_each(:properties) AS required_prop
|
38
|
+
WHERE json_extract(nodes.properties, '$.' || required_prop.key) IS NULL
|
39
|
+
OR json_extract(nodes.properties, '$.' || required_prop.key) != required_prop.value
|
40
|
+
)
|
41
|
+
);
|
42
|
+
{% endif %}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
-- Step 1: Create new nodes table
|
2
|
+
CREATE TABLE gqlite_{{ graph_name }}_nodes_new (
|
3
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
4
|
+
node_key BLOB NOT NULL DEFAULT '',
|
5
|
+
labels TEXT NOT NULL,
|
6
|
+
properties TEXT NOT NULL
|
7
|
+
);
|
8
|
+
|
9
|
+
-- Step 2: Create new edges table
|
10
|
+
CREATE TABLE gqlite_{{ graph_name }}_edges_new (
|
11
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
12
|
+
edge_key BLOB NOT NULL DEFAULT '',
|
13
|
+
labels TEXT NOT NULL,
|
14
|
+
properties TEXT NOT NULL,
|
15
|
+
left INTEGER NOT NULL,
|
16
|
+
right INTEGER NOT NULL,
|
17
|
+
FOREIGN KEY(left) REFERENCES gqlite_{{ graph_name }}_nodes_new(id),
|
18
|
+
FOREIGN KEY(right) REFERENCES gqlite_{{ graph_name }}_nodes_new(id)
|
19
|
+
);
|
20
|
+
|
21
|
+
-- Step 3: Migrate nodes with labels as JSON array
|
22
|
+
INSERT INTO gqlite_{{ graph_name }}_nodes_new (id, node_key, labels, properties)
|
23
|
+
SELECT
|
24
|
+
n.id,
|
25
|
+
CAST(uuid() AS BLOB) AS node_key,
|
26
|
+
COALESCE(json_group_array(gl.label), '[]') AS labels,
|
27
|
+
n.properties
|
28
|
+
FROM gqlite_{{ graph_name }}_nodes n
|
29
|
+
LEFT JOIN gqlite_{{ graph_name }}_labels nl ON nl.node_id = n.id
|
30
|
+
LEFT JOIN gqlite_labels gl ON gl.id = nl.label
|
31
|
+
GROUP BY n.id;
|
32
|
+
|
33
|
+
-- Step 4: Migrate edges, converting label to text
|
34
|
+
INSERT INTO gqlite_{{ graph_name }}_edges_new (id, edge_key, labels, properties, left, right)
|
35
|
+
SELECT
|
36
|
+
e.id,
|
37
|
+
CAST(uuid() AS BLOB) AS edge_key,
|
38
|
+
COALESCE(json_group_array(gl.label), '[]') AS labels,
|
39
|
+
e.properties,
|
40
|
+
e.left,
|
41
|
+
e.right
|
42
|
+
FROM gqlite_{{ graph_name }}_edges e
|
43
|
+
LEFT JOIN gqlite_labels gl ON gl.id = e.label
|
44
|
+
GROUP BY e.id;
|
45
|
+
|
46
|
+
-- Step 5: Drop old views and tables
|
47
|
+
DROP VIEW IF EXISTS gqlite_{{ graph_name }}_nodes_as_json;
|
48
|
+
DROP VIEW IF EXISTS gqlite_{{ graph_name }}_edges_as_json;
|
49
|
+
DROP VIEW IF EXISTS gqlite_{{ graph_name }}_edges_undirected;
|
50
|
+
|
51
|
+
DROP TABLE gqlite_{{ graph_name }}_labels;
|
52
|
+
DROP TABLE gqlite_{{ graph_name }}_edges;
|
53
|
+
DROP TABLE gqlite_{{ graph_name }}_nodes;
|
54
|
+
|
55
|
+
-- Step 6: Rename new tables
|
56
|
+
ALTER TABLE gqlite_{{ graph_name }}_nodes_new RENAME TO gqlite_{{ graph_name }}_nodes;
|
57
|
+
ALTER TABLE gqlite_{{ graph_name }}_edges_new RENAME TO gqlite_{{ graph_name }}_edges;
|
58
|
+
|
59
|
+
-- Step 7: Recreate the updated undirected edges view
|
60
|
+
CREATE VIEW gqlite_{{ graph_name }}_edges_undirected (
|
61
|
+
id, edge_key, labels, properties, left, right, reversed
|
62
|
+
) AS
|
63
|
+
SELECT id, edge_key, labels, properties, left, right, 0 FROM gqlite_{{ graph_name }}_edges
|
64
|
+
UNION
|
65
|
+
SELECT id, edge_key, labels, properties, right, left, 1 FROM gqlite_{{ graph_name }}_edges;
|
data/lib/gqlite.rb
CHANGED
@@ -1,75 +1 @@
|
|
1
|
-
require '
|
2
|
-
require 'objspace'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module GQLite
|
6
|
-
class Error < StandardError
|
7
|
-
end
|
8
|
-
module CApi
|
9
|
-
extend FFI::Library
|
10
|
-
|
11
|
-
# Attempt to find the gqlite build that is shipped with gem
|
12
|
-
def CApi.get_lib_name()
|
13
|
-
path = "#{File.dirname __FILE__}/#{FFI::Platform::LIBPREFIX}gqlite.#{FFI::Platform::LIBSUFFIX}"
|
14
|
-
return path if File.exist?(path)
|
15
|
-
path = "#{File.dirname __FILE__}/gqlite.#{FFI::Platform::LIBSUFFIX}"
|
16
|
-
return path if File.exist?(path)
|
17
|
-
return "gqlite"
|
18
|
-
end
|
19
|
-
|
20
|
-
ffi_lib CApi.get_lib_name()
|
21
|
-
attach_function :gqlite_api_context_create, [], :pointer
|
22
|
-
attach_function :gqlite_api_context_destroy, [:pointer], :void
|
23
|
-
attach_function :gqlite_api_context_clear_error, [:pointer], :void
|
24
|
-
attach_function :gqlite_api_context_has_error, [:pointer], :bool
|
25
|
-
attach_function :gqlite_api_context_get_message, [:pointer], :string
|
26
|
-
attach_function :gqlite_connection_create_from_sqlite_file, [:pointer, :string, :pointer], :pointer
|
27
|
-
attach_function :gqlite_connection_destroy, [:pointer, :pointer], :void
|
28
|
-
attach_function :gqlite_connection_oc_query, [:pointer, :pointer, :string, :pointer], :pointer
|
29
|
-
attach_function :gqlite_value_create, [:pointer], :pointer
|
30
|
-
attach_function :gqlite_value_destroy, [:pointer, :pointer], :void
|
31
|
-
attach_function :gqlite_value_to_json, [:pointer, :pointer], :string
|
32
|
-
attach_function :gqlite_value_from_json, [:pointer, :string], :pointer
|
33
|
-
attach_function :gqlite_value_is_valid, [:pointer, :pointer], :bool
|
34
|
-
ApiContext = CApi.gqlite_api_context_create()
|
35
|
-
def CApi.call_function(fname, *args)
|
36
|
-
r = CApi.send fname, ApiContext, *args
|
37
|
-
if CApi.gqlite_api_context_has_error(ApiContext)
|
38
|
-
err = CApi.gqlite_api_context_get_message ApiContext
|
39
|
-
CApi.gqlite_api_context_clear_error ApiContext
|
40
|
-
raise Error.new err
|
41
|
-
end
|
42
|
-
return r
|
43
|
-
end
|
44
|
-
end
|
45
|
-
class Connection
|
46
|
-
attr_reader :dbhandle
|
47
|
-
def initialize(sqlite_filename: nil)
|
48
|
-
if sqlite_filename != nil
|
49
|
-
@dbhandle = CApi.call_function :gqlite_connection_create_from_sqlite_file, sqlite_filename, nil
|
50
|
-
else
|
51
|
-
raise Error.new "No connection backend was selected."
|
52
|
-
end
|
53
|
-
ObjectSpace.define_finalizer @dbhandle, proc {|id|
|
54
|
-
CApi.call_function :gqlite_connection_destroy, @dbhandle
|
55
|
-
}
|
56
|
-
end
|
57
|
-
def execute_oc_query(query, bindings: nil)
|
58
|
-
b = nil
|
59
|
-
if bindings
|
60
|
-
b = CApi.call_function :gqlite_value_from_json, bindings.to_json
|
61
|
-
end
|
62
|
-
ret = CApi.call_function :gqlite_connection_oc_query, @dbhandle, query, b
|
63
|
-
if b
|
64
|
-
CApi.call_function :gqlite_value_destroy, b
|
65
|
-
end
|
66
|
-
if CApi.call_function(:gqlite_value_is_valid, ret)
|
67
|
-
val = JSON.parse(CApi.call_function :gqlite_value_to_json, ret)
|
68
|
-
else
|
69
|
-
val = nil
|
70
|
-
end
|
71
|
-
CApi.call_function :gqlite_value_destroy, ret
|
72
|
-
return val
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
1
|
+
require 'gqliterb'
|
metadata
CHANGED
@@ -1,60 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gqlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyrille Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rb_sys
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.9.39
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
|
26
|
+
version: 0.9.39
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0
|
41
|
+
description: "GQLite is a Rust-language library, with a C interface, that implements
|
28
42
|
a small, fast, self-contained, high-reliability, full-featured, Graph Query database
|
29
|
-
engine
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ISO GQL in the future when it become available.\n \nExample of use\n--------------\n\n```ruby\nrequire
|
43
|
+
engine.\nGQLite support multiple database backends, such as SQLite and redb.\nThis
|
44
|
+
enable to achieve high performance and for application to combine Graph queries
|
45
|
+
with traditional SQL queries.\n\nGQLite source code is license under the [MIT License](LICENSE)
|
46
|
+
and is free to everyone to use for any purpose. \n\nThe official repositories contains
|
47
|
+
bindings/APIs for C, C++, Python, Ruby and Crystal.\n\nThe library is still in its
|
48
|
+
early stage, but it is now fully functional. Development effort has now slowed down
|
49
|
+
and new features are added on a by-need basis. It supports a subset of OpenCypher,
|
50
|
+
with some ISO GQL extensions.\n \nExample of use\n--------------\n\n```ruby\nrequire
|
38
51
|
'gqlite'\n\nbegin\n # Create a database on the file \"test.db\"\n connection =
|
39
|
-
GQLite::Connection.new
|
40
|
-
|
52
|
+
GQLite::Connection.new filename: \"test.db\"\n\n # Execute a simple query to create
|
53
|
+
a node and return all the nodes\n value = connection.execute_oc_query(\"CREATE
|
41
54
|
() MATCH (n) RETURN n\")\n\n # Print the result\n if value.nil?\n puts \"Empty
|
42
55
|
results\"\n else\n puts \"Results are #{value.to_s}\"\n end\nrescue GQLite::Error
|
43
56
|
=> ex\n # Report any error\n puts \"An error has occured: #{ex.message}\"\nend\n\n```\n\nThe
|
44
|
-
documentation for the
|
45
|
-
and for the [API](https://
|
57
|
+
documentation for the GQL query language can found in [OpenCypher](https://auksys.org/documentation/5/libraries/gqlite/opencypher/)
|
58
|
+
and for the [API](https://auksys.org/documentation/5/libraries/gqlite/api/).\n\n"
|
46
59
|
email:
|
47
60
|
executables: []
|
48
61
|
extensions:
|
49
|
-
- ext/
|
62
|
+
- ext/gqliterb/extconf.rb
|
50
63
|
extra_rdoc_files: []
|
51
64
|
files:
|
52
|
-
- ext/
|
53
|
-
- ext/
|
54
|
-
- ext/
|
55
|
-
- ext/
|
65
|
+
- ext/gqliterb/.cargo/config.toml
|
66
|
+
- ext/gqliterb/Cargo.lock
|
67
|
+
- ext/gqliterb/Cargo.toml
|
68
|
+
- ext/gqliterb/extconf.rb
|
69
|
+
- ext/gqliterb/src/lib.rs
|
70
|
+
- ext/gqliterb/vendor/gqlitedb/Cargo.lock
|
71
|
+
- ext/gqliterb/vendor/gqlitedb/Cargo.toml
|
72
|
+
- ext/gqliterb/vendor/gqlitedb/askama.toml
|
73
|
+
- ext/gqliterb/vendor/gqlitedb/benches/common/mod.rs
|
74
|
+
- ext/gqliterb/vendor/gqlitedb/benches/common/pokec.rs
|
75
|
+
- ext/gqliterb/vendor/gqlitedb/benches/pokec_divan.rs
|
76
|
+
- ext/gqliterb/vendor/gqlitedb/benches/pokec_iai.rs
|
77
|
+
- ext/gqliterb/vendor/gqlitedb/release.toml
|
78
|
+
- ext/gqliterb/vendor/gqlitedb/src/aggregators.rs
|
79
|
+
- ext/gqliterb/vendor/gqlitedb/src/aggregators/arithmetic.rs
|
80
|
+
- ext/gqliterb/vendor/gqlitedb/src/aggregators/containers.rs
|
81
|
+
- ext/gqliterb/vendor/gqlitedb/src/aggregators/count.rs
|
82
|
+
- ext/gqliterb/vendor/gqlitedb/src/aggregators/stats.rs
|
83
|
+
- ext/gqliterb/vendor/gqlitedb/src/capi.rs
|
84
|
+
- ext/gqliterb/vendor/gqlitedb/src/compiler.rs
|
85
|
+
- ext/gqliterb/vendor/gqlitedb/src/compiler/expression_analyser.rs
|
86
|
+
- ext/gqliterb/vendor/gqlitedb/src/compiler/variables_manager.rs
|
87
|
+
- ext/gqliterb/vendor/gqlitedb/src/connection.rs
|
88
|
+
- ext/gqliterb/vendor/gqlitedb/src/consts.rs
|
89
|
+
- ext/gqliterb/vendor/gqlitedb/src/error.rs
|
90
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions.rs
|
91
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/containers.rs
|
92
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/edge.rs
|
93
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/math.rs
|
94
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/node.rs
|
95
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/path.rs
|
96
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/scalar.rs
|
97
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/string.rs
|
98
|
+
- ext/gqliterb/vendor/gqlitedb/src/functions/value.rs
|
99
|
+
- ext/gqliterb/vendor/gqlitedb/src/graph.rs
|
100
|
+
- ext/gqliterb/vendor/gqlitedb/src/interpreter/evaluators.rs
|
101
|
+
- ext/gqliterb/vendor/gqlitedb/src/interpreter/instructions.rs
|
102
|
+
- ext/gqliterb/vendor/gqlitedb/src/interpreter/mod.rs
|
103
|
+
- ext/gqliterb/vendor/gqlitedb/src/lib.rs
|
104
|
+
- ext/gqliterb/vendor/gqlitedb/src/parser.rs
|
105
|
+
- ext/gqliterb/vendor/gqlitedb/src/parser/ast.rs
|
106
|
+
- ext/gqliterb/vendor/gqlitedb/src/parser/gql.pest
|
107
|
+
- ext/gqliterb/vendor/gqlitedb/src/parser/parser.rs
|
108
|
+
- ext/gqliterb/vendor/gqlitedb/src/prelude.rs
|
109
|
+
- ext/gqliterb/vendor/gqlitedb/src/serialize_with.rs
|
110
|
+
- ext/gqliterb/vendor/gqlitedb/src/store.rs
|
111
|
+
- ext/gqliterb/vendor/gqlitedb/src/store/pgql.rs
|
112
|
+
- ext/gqliterb/vendor/gqlitedb/src/store/redb.rs
|
113
|
+
- ext/gqliterb/vendor/gqlitedb/src/store/sqlite.rs
|
114
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests.rs
|
115
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/compiler.rs
|
116
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/evaluators.rs
|
117
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/parser.rs
|
118
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/store.rs
|
119
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/store/redb.rs
|
120
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/store/sqlite.rs
|
121
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/templates.rs
|
122
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/templates/ast.rs
|
123
|
+
- ext/gqliterb/vendor/gqlitedb/src/tests/templates/programs.rs
|
124
|
+
- ext/gqliterb/vendor/gqlitedb/src/utils.rs
|
125
|
+
- ext/gqliterb/vendor/gqlitedb/src/value.rs
|
126
|
+
- ext/gqliterb/vendor/gqlitedb/src/value/compare.rs
|
127
|
+
- ext/gqliterb/vendor/gqlitedb/src/value/contains.rs
|
128
|
+
- ext/gqliterb/vendor/gqlitedb/src/value/value_map.rs
|
129
|
+
- ext/gqliterb/vendor/gqlitedb/src/value_table.rs
|
130
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/call_stats.sql
|
131
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_count_for_node.sql
|
132
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_create.sql
|
133
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete.sql
|
134
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_delete_by_nodes.sql
|
135
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_select.sql
|
136
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/edge_update.sql
|
137
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_create.sql
|
138
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/graph_delete.sql
|
139
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_create_table.sql
|
140
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_get.sql
|
141
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/metadata_set.sql
|
142
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_create.sql
|
143
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_delete.sql
|
144
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_select.sql
|
145
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/node_update.sql
|
146
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/table_exists.sql
|
147
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_from_1_01.sql
|
148
|
+
- ext/gqliterb/vendor/gqlitedb/templates/sql/sqlite/upgrade_graph_from_1_01.sql
|
56
149
|
- lib/gqlite.rb
|
57
|
-
homepage: https://gitlab.com/
|
150
|
+
homepage: https://gitlab.com/auksys/gqlite
|
58
151
|
licenses:
|
59
152
|
- MIT
|
60
153
|
metadata: {}
|
data/ext/gqlite/extconf.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "mkmf"
|
2
|
-
|
3
|
-
# Build the gqlite library
|
4
|
-
|
5
|
-
# Platforms check
|
6
|
-
IS_MSWIN = !RbConfig::CONFIG['host_os'].match(/mswin/).nil?
|
7
|
-
IS_MINGW = !RbConfig::CONFIG['host_os'].match(/mingw/).nil?
|
8
|
-
IS_DARWIN = !RbConfig::CONFIG['host_os'].match(/darwin/).nil?
|
9
|
-
|
10
|
-
# gqlite
|
11
|
-
if IS_MSWIN
|
12
|
-
$CXXFLAGS += " /std:c++20 /EHsc /permissive- /bigobj"
|
13
|
-
elsif IS_MINGW
|
14
|
-
$CXXFLAGS += " -std=c++20 -Wa,-mbig-obj"
|
15
|
-
$LDFLAGS += " -lsqlite3 "
|
16
|
-
else
|
17
|
-
$CXXFLAGS += " -std=c++20"
|
18
|
-
$LDFLAGS += " -lsqlite3 "
|
19
|
-
end
|
20
|
-
|
21
|
-
create_makefile "gqlite"
|