ruby-kuzu 0.0.3 → 0.1.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
- checksums.yaml.gz.sig +0 -0
- data/History.md +8 -0
- data/ext/kuzu_ext/connection.c +21 -0
- data/ext/kuzu_ext/prepared_statement.c +4 -0
- data/lib/kuzu/prepared_statement.rb +2 -0
- data/lib/kuzu/result.rb +16 -0
- data/lib/kuzu.rb +1 -1
- data/spec/kuzu/connection_spec.rb +36 -0
- data/spec/kuzu/database_spec.rb +1 -1
- data/spec/kuzu/result_spec.rb +21 -2
- data.tar.gz.sig +0 -0
- metadata +4 -3
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 992fc29928cf3ac28d7ef615302fafdbb65c18311bcac23ad7178ff56c2949f9
|
4
|
+
data.tar.gz: 8ccd0253875842c9db1ef0b9de49d5a2120dd93193bcc19a840b020c8b3a8940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adce4adb10a022eb7ac6c079a66faaf91fb260e29a55f78b9ea235f3ecac3a6c2b068342e7274ac2bf3a8f6ba297ae494f19ba8e404c67d423f34976f0ce22d8
|
7
|
+
data.tar.gz: 36b289d90d94cf0273745e89590be11ee62d005beac8f2b9fb7024e08414683bb510f1f158a81ced28ece50f082ba21d9efbb338795738a472c1397fc8045586
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Release History for ruby-kuzu
|
2
2
|
|
3
3
|
---
|
4
|
+
## v0.1.0 [2025-06-17] Michael Granger <ged@FaerieMUD.org>
|
5
|
+
|
6
|
+
Enhancements:
|
7
|
+
|
8
|
+
- Add Connection#database
|
9
|
+
- Squelch some warnings
|
10
|
+
- Add Result#tuples and Result#[].
|
11
|
+
|
4
12
|
|
5
13
|
## v0.0.3 [2025-05-22] Michael Granger <ged@FaerieMUD.org>
|
6
14
|
|
data/ext/kuzu_ext/connection.c
CHANGED
@@ -170,7 +170,10 @@ rkuzu_connection_do_query( VALUE self, VALUE query )
|
|
170
170
|
rkuzu_connection_do_query_without_gvl, (void *)&qcall,
|
171
171
|
rkuzu_connection_cancel_query, (void *)&conn->conn );
|
172
172
|
|
173
|
+
_Pragma("GCC diagnostic push")
|
174
|
+
_Pragma("GCC diagnostic ignored \"-Wvoid-pointer-to-enum-cast\"")
|
173
175
|
query_state = (kuzu_state)result_ptr;
|
176
|
+
_Pragma("GCC diagnostic pop")
|
174
177
|
|
175
178
|
if ( query_state != KuzuSuccess ) {
|
176
179
|
char *err_detail = kuzu_query_result_get_error_message( &result );
|
@@ -278,6 +281,21 @@ rkuzu_connection_query_timeout_eq( VALUE self, VALUE timeout )
|
|
278
281
|
}
|
279
282
|
|
280
283
|
|
284
|
+
/*
|
285
|
+
* call-seq:
|
286
|
+
* connection.database -> database
|
287
|
+
*
|
288
|
+
* Return the database object the connection belongs to (a Kuzu::Database).
|
289
|
+
*
|
290
|
+
*/
|
291
|
+
static VALUE
|
292
|
+
rkuzu_connection_database( VALUE self )
|
293
|
+
{
|
294
|
+
rkuzu_connection *ptr = CHECK_CONNECTION( self );
|
295
|
+
return ptr->database;
|
296
|
+
}
|
297
|
+
|
298
|
+
|
281
299
|
|
282
300
|
/*
|
283
301
|
* Document-class: Kuzu::Connection
|
@@ -306,5 +324,8 @@ rkuzu_init_connection( void )
|
|
306
324
|
|
307
325
|
rb_define_method( rkuzu_cKuzuConnection, "query_timeout=", rkuzu_connection_query_timeout_eq, 1 );
|
308
326
|
|
327
|
+
rb_define_method( rkuzu_cKuzuConnection, "database", rkuzu_connection_database, 0 );
|
328
|
+
rb_define_alias( rkuzu_cKuzuConnection, "db", "database" );
|
329
|
+
|
309
330
|
rb_require( "kuzu/connection" );
|
310
331
|
}
|
@@ -181,7 +181,11 @@ rkuzu_prepared_statement_do_execute( VALUE self )
|
|
181
181
|
result_ptr = rb_thread_call_without_gvl(
|
182
182
|
rkuzu_connection_do_execute_without_gvl, (void *)&qcall,
|
183
183
|
rkuzu_connection_cancel_execute, (void *)&conn->conn );
|
184
|
+
|
185
|
+
_Pragma("GCC diagnostic push")
|
186
|
+
_Pragma("GCC diagnostic ignored \"-Wvoid-pointer-to-enum-cast\"")
|
184
187
|
execute_state = (kuzu_state)result_ptr;
|
188
|
+
_Pragma("GCC diagnostic pop")
|
185
189
|
|
186
190
|
if ( execute_state != KuzuSuccess ) {
|
187
191
|
char *err_detail = kuzu_query_result_get_error_message( &result );
|
@@ -18,6 +18,8 @@ class Kuzu::PreparedStatement
|
|
18
18
|
### then finished automatically, and the return value of the block returned
|
19
19
|
### instead.
|
20
20
|
def execute( **bound_variables, &block )
|
21
|
+
self.log.debug "Executing statement:\n%s\nwith variables:\n%p" %
|
22
|
+
[ self.query, bound_variables ]
|
21
23
|
self.bind( **bound_variables )
|
22
24
|
result = self._execute
|
23
25
|
return Kuzu::Result.wrap_block_result( result, &block )
|
data/lib/kuzu/result.rb
CHANGED
@@ -74,6 +74,19 @@ class Kuzu::Result
|
|
74
74
|
end
|
75
75
|
|
76
76
|
|
77
|
+
### Return the tuples from the current result set. This method is memoized
|
78
|
+
### for efficiency.
|
79
|
+
def tuples
|
80
|
+
return @_tuples ||= self.to_a
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
### Index operator: fetch the tuple at +index+ of the current result set.
|
85
|
+
def []( index )
|
86
|
+
return self.tuples[ index ]
|
87
|
+
end
|
88
|
+
|
89
|
+
|
77
90
|
### Return the next result set after this one as a Kuzu::Result, or `nil`if
|
78
91
|
### there is no next set.
|
79
92
|
def next_set
|
@@ -116,6 +129,7 @@ class Kuzu::Result
|
|
116
129
|
|
117
130
|
### Return an Enumerator that yields result tuples as Hashes.
|
118
131
|
def tuple_enum
|
132
|
+
self.log.debug "Fetching a tuple Enumerator"
|
119
133
|
return Enumerator.new do |yielder|
|
120
134
|
self.reset_iterator
|
121
135
|
while self.has_next?
|
@@ -126,7 +140,9 @@ class Kuzu::Result
|
|
126
140
|
end
|
127
141
|
|
128
142
|
|
143
|
+
### Return an Enumerator that yields a Result for each set.
|
129
144
|
def next_set_enum
|
145
|
+
self.log.debug "Fetching a result set Enumerator"
|
130
146
|
result = self
|
131
147
|
return Enumerator.new do |yielder|
|
132
148
|
while result
|
data/lib/kuzu.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
require 'kuzu/connection'
|
6
|
+
|
7
|
+
|
8
|
+
RSpec.describe( Kuzu::Connection ) do
|
9
|
+
|
10
|
+
let( :db ) { Kuzu.database }
|
11
|
+
|
12
|
+
|
13
|
+
it "can set the maximum number of threads for execution" do
|
14
|
+
connection = db.connect
|
15
|
+
|
16
|
+
expect {
|
17
|
+
connection.max_num_threads_for_exec += 1
|
18
|
+
}.to change { connection.max_num_threads_for_exec }.by( 1 )
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
it "shows the number of threads used for execution when inspected" do
|
23
|
+
connection = db.connect
|
24
|
+
|
25
|
+
expect( connection.inspect ).to match( /threads:\d+/i )
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
it "knows what database it's a connection for" do
|
30
|
+
connection = db.connect
|
31
|
+
|
32
|
+
expect( connection.database ).to eq( db )
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
data/spec/kuzu/database_spec.rb
CHANGED
@@ -21,7 +21,7 @@ RSpec.describe( Kuzu::Database ) do
|
|
21
21
|
|
22
22
|
|
23
23
|
it "can be created read-only from an existing on-disk database" do
|
24
|
-
|
24
|
+
_original = described_class.new( db_path.to_s )
|
25
25
|
|
26
26
|
ro = described_class.new( db_path.to_s, read_only: true )
|
27
27
|
expect( ro ).to be_read_only
|
data/spec/kuzu/result_spec.rb
CHANGED
@@ -78,7 +78,7 @@ RSpec.describe( Kuzu::Result ) do
|
|
78
78
|
expect( result ).to be_success
|
79
79
|
expect( result.num_columns ).to eq( 3 )
|
80
80
|
expect( result.column_names ).to eq([ "a.name", "b.name", "f.since" ])
|
81
|
-
expect( result.
|
81
|
+
expect( result.to_a ).to eq([
|
82
82
|
{ "a.name" => "Adam", "b.name" => "Karissa", "f.since" => 2020 },
|
83
83
|
{ "a.name" => "Adam", "b.name" => "Zhang", "f.since" => 2020 },
|
84
84
|
{ "a.name" => "Karissa", "b.name" => "Zhang", "f.since" => 2021 },
|
@@ -89,6 +89,25 @@ RSpec.describe( Kuzu::Result ) do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
|
92
|
+
it "can fetch individual result tuples via the index operator" do
|
93
|
+
setup_demo_db()
|
94
|
+
|
95
|
+
result = described_class.from_query( connection, <<~END_OF_QUERY )
|
96
|
+
MATCH ( a:User )-[ f:Follows ]->( b:User )
|
97
|
+
RETURN a.name, b.name, f.since;
|
98
|
+
END_OF_QUERY
|
99
|
+
|
100
|
+
tuples = result.to_a
|
101
|
+
|
102
|
+
expect( result[0] ).to eq( tuples[0] )
|
103
|
+
expect( result[1] ).to eq( tuples[1] )
|
104
|
+
expect( result[2] ).to eq( tuples[2] )
|
105
|
+
expect( result[3] ).to eq( tuples[3] )
|
106
|
+
|
107
|
+
result.finish
|
108
|
+
end
|
109
|
+
|
110
|
+
|
92
111
|
it "can iterate over result sets" do
|
93
112
|
result = described_class.from_query( connection, <<~END_QUERY )
|
94
113
|
return 1;
|
@@ -97,7 +116,7 @@ RSpec.describe( Kuzu::Result ) do
|
|
97
116
|
END_QUERY
|
98
117
|
|
99
118
|
rval = result.each_set.flat_map do |subset|
|
100
|
-
subset.
|
119
|
+
subset.to_a
|
101
120
|
end
|
102
121
|
|
103
122
|
expect( rval ).to eq([
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-kuzu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
8qAqdfV+4u6Huu1KzAuDQCheyEyISsLST37sU/irV3czV6BiFipWag1XiJciRT3A
|
35
35
|
wZqCfTNVHTdtsCbfdA1DsA3RdG2iEH3TOHzv1Rqzqh4=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2025-
|
37
|
+
date: 2025-06-17 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake-compiler
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/kuzu/rel.rb
|
128
128
|
- lib/kuzu/result.rb
|
129
129
|
- spec/kuzu/config_spec.rb
|
130
|
+
- spec/kuzu/connection_spec.rb
|
130
131
|
- spec/kuzu/database_spec.rb
|
131
132
|
- spec/kuzu/prepared_statement_spec.rb
|
132
133
|
- spec/kuzu/query_summary_spec.rb
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: '0'
|
159
160
|
requirements: []
|
160
|
-
rubygems_version: 3.6.
|
161
|
+
rubygems_version: 3.6.7
|
161
162
|
specification_version: 4
|
162
163
|
summary: A Ruby binding for the Kùzu embedded graph database.
|
163
164
|
test_files: []
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�x02ڶ�X?�' ��]Ԛ;�h'���L�%�qo�q;��(C~���f�US��RF-h�Ϛl�R�.L`�c�R�E��:�~nj�8c��Q�K�6�����r���2ۍ_E�kȼm�#j�-H#]��t�����/#ȩ~L(K}�Y��8�T��<A���?���m�
|
2
|
+
$��c;�T:5�f%b�TIn,۳`W~F~`j�H8Y��߉��#@qſ�,`�n���Ԅ�r�j.e�N&}!�f�� ��
|