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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9ef51b4e013cad8b7f0434db1a6fac89068681273f0d53981761c56a570628d
4
- data.tar.gz: db7e93a8c4537f33cfa3bf77a6315ccb334f74d437869b2f053f1d479be7ee6b
3
+ metadata.gz: 992fc29928cf3ac28d7ef615302fafdbb65c18311bcac23ad7178ff56c2949f9
4
+ data.tar.gz: 8ccd0253875842c9db1ef0b9de49d5a2120dd93193bcc19a840b020c8b3a8940
5
5
  SHA512:
6
- metadata.gz: 2b70df49dbb9038ea0d02c0d6edb1e00c19ccfce943c464fd05efc55f6e848f110732aee64ce2910fc11107f1942fcfe5d8f19efd868bbffa5ceaeab8aaa7eae
7
- data.tar.gz: 6633c48dd7c4cfad5b13de88b6123b7c7226dabcc2323a59831519db29b992f5efff9b48c946311934b96a3fffe8fe0ef17ca38afe3ba8f79094cc195ba2d880
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
 
@@ -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
@@ -11,7 +11,7 @@ module Kuzu
11
11
 
12
12
 
13
13
  # Library version
14
- VERSION = '0.0.3'
14
+ VERSION = '0.1.0'
15
15
 
16
16
 
17
17
  # Set up a logger for Kuzu classes
@@ -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
+
@@ -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
- original = described_class.new( db_path.to_s )
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
@@ -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.each.to_a ).to eq([
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.each.to_a
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.3
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-05-22 00:00:00.000000000 Z
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.2
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
- zA���H_��8PT�%�9��T[:��l���mࡷ�aU^�� 2��l�D��5v�tv��Oh6f��E$"�ӡ���U�pWE�gCR7��.�鉐���蘩q���K� �l��>#�m���~���C�*X+� 0�R�mb��QĬ� N���o������T{�J��%��eø6�v�3O���b>��§����i@���j����0>�)�}E�^�!$d8y� h)�2�(~��"��4cO��wrB �.m-��[��Ż��9;¹fa��3L{I���k���!-cS͘L��A �^���� n��y�� ��NE��ٻ(��!Wl`�+Ǐ
2
- r�� NSXt6P����U}ޅ��.dN
1
+ �x02ڶ�X?�' ��]Ԛ;�h'���L�%�qoq;��(C~���f�US��RF-h�Ϛl�R�.L`�cR�E��:�~nj�8c��Q�K�6�����r�𿿫��2ۍ_Ekȼm�#j�-H#]��t�����/#ȩ~L(K}�Y��8T��<A���?���m
2
+ $��c;�T:5�f%b�T In,۳`W~F~`jH8Y��߉��#@qſ�,`�n���Ԅ�rj.e�N&}!�f�� ��