ruby-kuzu 0.0.1
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/History.md +6 -0
- data/LICENSE.txt +20 -0
- data/README.md +95 -0
- data/ext/kuzu_ext/config.c +318 -0
- data/ext/kuzu_ext/connection.c +310 -0
- data/ext/kuzu_ext/database.c +196 -0
- data/ext/kuzu_ext/extconf.rb +20 -0
- data/ext/kuzu_ext/kuzu_ext.c +158 -0
- data/ext/kuzu_ext/kuzu_ext.h +130 -0
- data/ext/kuzu_ext/node.c +24 -0
- data/ext/kuzu_ext/prepared_statement.c +392 -0
- data/ext/kuzu_ext/query_summary.c +140 -0
- data/ext/kuzu_ext/recursive_rel.c +24 -0
- data/ext/kuzu_ext/rel.c +24 -0
- data/ext/kuzu_ext/result.c +514 -0
- data/ext/kuzu_ext/types.c +612 -0
- data/lib/kuzu/config.rb +70 -0
- data/lib/kuzu/connection.rb +51 -0
- data/lib/kuzu/database.rb +53 -0
- data/lib/kuzu/node.rb +46 -0
- data/lib/kuzu/prepared_statement.rb +42 -0
- data/lib/kuzu/query_summary.rb +28 -0
- data/lib/kuzu/recursive_rel.rb +37 -0
- data/lib/kuzu/rel.rb +51 -0
- data/lib/kuzu/result.rb +139 -0
- data/lib/kuzu.rb +79 -0
- data/spec/kuzu/config_spec.rb +98 -0
- data/spec/kuzu/database_spec.rb +51 -0
- data/spec/kuzu/prepared_statement_spec.rb +93 -0
- data/spec/kuzu/query_summary_spec.rb +30 -0
- data/spec/kuzu/result_spec.rb +190 -0
- data/spec/kuzu/types_spec.rb +254 -0
- data/spec/kuzu_spec.rb +55 -0
- data/spec/spec_helper.rb +101 -0
- data.tar.gz.sig +0 -0
- metadata +163 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7efba3eca4a268d102e73e5d356fcdd530b40a5cc4cdeadf8089ef6ef7eb54b5
|
4
|
+
data.tar.gz: 473c82d2a4ceaa1c6b9a21a8c031382ca689f0954f941778473319c75271af8b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a8f267516b68f4ab6684f9a9d3b7df2d49b4788d45140649128d83547f27ee696d2f6359428448b72a48cdafde8126830d7ebe6ec0e292f5b188ec1bb96e8ce
|
7
|
+
data.tar.gz: 996a8d10076b0452fad789ae564c640af8b77c52df5d157aed6a38ef7d0001034cf35976b69d22f25333f289284c9526d2a95fd9ffa53a737d9c46878d357a83
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/History.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2025 Michael Granger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# ruby-kuzu
|
2
|
+
|
3
|
+
home
|
4
|
+
: https://sr.ht/~ged/Ruby-Kuzu
|
5
|
+
|
6
|
+
code
|
7
|
+
: https://hg.sr.ht/~ged/Ruby-Kuzu
|
8
|
+
|
9
|
+
github
|
10
|
+
: https://github.com/ged/ruby-kuzu
|
11
|
+
|
12
|
+
docs
|
13
|
+
: https://deveiate.org/code/ruby-kuzu
|
14
|
+
|
15
|
+
|
16
|
+
## Description
|
17
|
+
|
18
|
+
A Ruby binding for the Kùzu embedded graph database.
|
19
|
+
|
20
|
+
### Connecting To/Creating A Database
|
21
|
+
|
22
|
+
### Querying
|
23
|
+
|
24
|
+
### Results
|
25
|
+
|
26
|
+
### Prepared Statements
|
27
|
+
|
28
|
+
### Datatypes
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## Examples
|
33
|
+
|
34
|
+
require 'kuzu'
|
35
|
+
|
36
|
+
db = Kuzu.database
|
37
|
+
conn = db.connect
|
38
|
+
conn.query("CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))")
|
39
|
+
conn.query("CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))")
|
40
|
+
conn.query("CREATE REL TABLE Follows(FROM User TO User, since INT64)")
|
41
|
+
conn.query("CREATE REL TABLE LivesIn(FROM User TO City)")
|
42
|
+
|
43
|
+
# Load data.
|
44
|
+
conn.query("COPY User FROM \"user.csv\"")
|
45
|
+
conn.query("COPY City FROM \"city.csv\"")
|
46
|
+
conn.query("COPY Follows FROM \"follows.csv\"")
|
47
|
+
conn.query("COPY LivesIn FROM \"lives-in.csv\"")
|
48
|
+
|
49
|
+
# Execute a simple query.
|
50
|
+
result = conn.query("MATCH (a:User)-[f:Follows]->(b:User) RETURN a.name, f.since, b.name;")
|
51
|
+
|
52
|
+
# Output query result.
|
53
|
+
result.each do |tuple|
|
54
|
+
name, since, name2 = tuple.values_at( :a_name, :f_since, :b_name )
|
55
|
+
puts "%s follows %s since %lld", [ name, name2, since ]
|
56
|
+
end
|
57
|
+
|
58
|
+
## Requirements
|
59
|
+
|
60
|
+
- Ruby >= 3
|
61
|
+
- Kuzu >= 0.9
|
62
|
+
|
63
|
+
|
64
|
+
## Install
|
65
|
+
|
66
|
+
$ gem install kuzu
|
67
|
+
|
68
|
+
|
69
|
+
## Authors
|
70
|
+
|
71
|
+
- Michael Granger <ged@FaerieMUD.org>
|
72
|
+
|
73
|
+
|
74
|
+
## Copyright
|
75
|
+
|
76
|
+
Copyright (c) 2025 Michael Granger
|
77
|
+
|
78
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
79
|
+
a copy of this software and associated documentation files (the
|
80
|
+
"Software"), to deal in the Software without restriction, including
|
81
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
82
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
83
|
+
permit persons to whom the Software is furnished to do so, subject to
|
84
|
+
the following conditions:
|
85
|
+
|
86
|
+
The above copyright notice and this permission notice shall be
|
87
|
+
included in all copies or substantial portions of the Software.
|
88
|
+
|
89
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
92
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
93
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
94
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
95
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,318 @@
|
|
1
|
+
/*
|
2
|
+
* config.c - Kuzu::Config class
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "kuzu_ext.h"
|
7
|
+
|
8
|
+
#define CHECK_CONFIG(self) ((kuzu_system_config*)rb_check_typeddata((self), &rkuzu_config_type))
|
9
|
+
|
10
|
+
|
11
|
+
VALUE rkuzu_cKuzuConfig;
|
12
|
+
|
13
|
+
static const rb_data_type_t rkuzu_config_type = {
|
14
|
+
.wrap_struct_name = "Kuzu::Config",
|
15
|
+
.function = {},
|
16
|
+
.data = NULL,
|
17
|
+
};
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
/*
|
22
|
+
* ::allocate function
|
23
|
+
*/
|
24
|
+
static VALUE
|
25
|
+
rkuzu_config_s_allocate( VALUE klass )
|
26
|
+
{
|
27
|
+
return TypedData_Wrap_Struct( klass, &rkuzu_config_type, NULL );
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
kuzu_system_config *
|
32
|
+
rkuzu_get_config( VALUE obj )
|
33
|
+
{
|
34
|
+
return CHECK_CONFIG( obj );
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
/*
|
40
|
+
* call-seq:
|
41
|
+
* new() -> config
|
42
|
+
*
|
43
|
+
* Create a Kuzu::Config with default values.
|
44
|
+
*
|
45
|
+
*/
|
46
|
+
static VALUE
|
47
|
+
rkuzu_config_initialize( VALUE self )
|
48
|
+
{
|
49
|
+
kuzu_system_config *ptr = CHECK_CONFIG( self );
|
50
|
+
|
51
|
+
if ( !ptr ) {
|
52
|
+
ptr = ALLOC( kuzu_system_config );
|
53
|
+
kuzu_system_config defaults = kuzu_default_system_config();
|
54
|
+
|
55
|
+
ptr->buffer_pool_size = defaults.buffer_pool_size;
|
56
|
+
ptr->max_num_threads = defaults.max_num_threads;
|
57
|
+
ptr->enable_compression = defaults.enable_compression;
|
58
|
+
ptr->read_only = defaults.read_only;
|
59
|
+
ptr->max_db_size = defaults.max_db_size;
|
60
|
+
ptr->auto_checkpoint = defaults.auto_checkpoint;
|
61
|
+
ptr->checkpoint_threshold = defaults.checkpoint_threshold;
|
62
|
+
|
63
|
+
RTYPEDDATA_DATA( self ) = ptr;
|
64
|
+
} else {
|
65
|
+
rb_raise( rb_eRuntimeError, "cannot reinit config" );
|
66
|
+
}
|
67
|
+
|
68
|
+
rb_call_super( 0, 0 );
|
69
|
+
|
70
|
+
return Qtrue;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
/*
|
75
|
+
* call-seq:
|
76
|
+
* config.buffer_pool_size() -> integer
|
77
|
+
*
|
78
|
+
* Return the buffer_pool_size config value.
|
79
|
+
*/
|
80
|
+
static VALUE
|
81
|
+
rkuzu_config_buffer_pool_size( VALUE self )
|
82
|
+
{
|
83
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
84
|
+
return ULONG2NUM( config->buffer_pool_size );
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
/*
|
89
|
+
* call-seq:
|
90
|
+
* config.max_num_threads() -> integer
|
91
|
+
*
|
92
|
+
* Return the max_num_threads config value.
|
93
|
+
*/
|
94
|
+
static VALUE
|
95
|
+
rkuzu_config_max_num_threads( VALUE self )
|
96
|
+
{
|
97
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
98
|
+
return ULONG2NUM( config->max_num_threads );
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
/*
|
103
|
+
* call-seq:
|
104
|
+
* config.enable_compression() -> true or false
|
105
|
+
*
|
106
|
+
* Return the enable_compression config value.
|
107
|
+
*/
|
108
|
+
static VALUE
|
109
|
+
rkuzu_config_enable_compression( VALUE self )
|
110
|
+
{
|
111
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
112
|
+
return config->enable_compression ? Qtrue : Qfalse;
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
/*
|
117
|
+
* call-seq:
|
118
|
+
* config.read_only() -> true or false
|
119
|
+
*
|
120
|
+
* Return the read_only config value.
|
121
|
+
*/
|
122
|
+
static VALUE
|
123
|
+
rkuzu_config_read_only( VALUE self )
|
124
|
+
{
|
125
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
126
|
+
return config->read_only ? Qtrue : Qfalse;
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
/*
|
131
|
+
* call-seq:
|
132
|
+
* config.max_db_size() -> integer
|
133
|
+
*
|
134
|
+
* Return the max_db_size config value.
|
135
|
+
*/
|
136
|
+
static VALUE
|
137
|
+
rkuzu_config_max_db_size( VALUE self )
|
138
|
+
{
|
139
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
140
|
+
return ULONG2NUM( config->max_db_size );
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
/*
|
145
|
+
* call-seq:
|
146
|
+
* config.auto_checkpoint() -> true or false
|
147
|
+
*
|
148
|
+
* Return the auto_checkpoint config value.
|
149
|
+
*/
|
150
|
+
static VALUE
|
151
|
+
rkuzu_config_auto_checkpoint( VALUE self )
|
152
|
+
{
|
153
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
154
|
+
return config->auto_checkpoint ? Qtrue : Qfalse;
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
/*
|
159
|
+
* call-seq:
|
160
|
+
* config.checkpoint_threshold() -> integer
|
161
|
+
*
|
162
|
+
* Return the checkpoint_threshold config value.
|
163
|
+
*/
|
164
|
+
static VALUE
|
165
|
+
rkuzu_config_checkpoint_threshold( VALUE self )
|
166
|
+
{
|
167
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
168
|
+
return ULONG2NUM( config->checkpoint_threshold );
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
/*
|
173
|
+
* call-seq:
|
174
|
+
* config.buffer_pool_size = integer
|
175
|
+
*
|
176
|
+
* Set the buffer_pool_size config value.
|
177
|
+
*/
|
178
|
+
static VALUE
|
179
|
+
rkuzu_config_buffer_pool_size_eq( VALUE self, VALUE value )
|
180
|
+
{
|
181
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
182
|
+
config->buffer_pool_size = NUM2ULONG( value );
|
183
|
+
|
184
|
+
return Qtrue;
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
/*
|
189
|
+
* call-seq:
|
190
|
+
* config.max_num_threads = integer
|
191
|
+
*
|
192
|
+
* Set the max_num_threads config value.
|
193
|
+
*/
|
194
|
+
static VALUE
|
195
|
+
rkuzu_config_max_num_threads_eq( VALUE self, VALUE value )
|
196
|
+
{
|
197
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
198
|
+
config->max_num_threads = NUM2ULONG( value );
|
199
|
+
|
200
|
+
return Qtrue;
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
/*
|
205
|
+
* call-seq:
|
206
|
+
* config.enable_compression = true or false
|
207
|
+
*
|
208
|
+
* Set the enable_compression config value.
|
209
|
+
*/
|
210
|
+
static VALUE
|
211
|
+
rkuzu_config_enable_compression_eq( VALUE self, VALUE value )
|
212
|
+
{
|
213
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
214
|
+
config->enable_compression = RTEST( value );
|
215
|
+
|
216
|
+
return Qtrue;
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
/*
|
221
|
+
* call-seq:
|
222
|
+
* config.read_only = true or false
|
223
|
+
*
|
224
|
+
* Set the read_only config value.
|
225
|
+
*/
|
226
|
+
static VALUE
|
227
|
+
rkuzu_config_read_only_eq( VALUE self, VALUE value )
|
228
|
+
{
|
229
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
230
|
+
config->read_only = RTEST( value );
|
231
|
+
|
232
|
+
return Qtrue;
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
/*
|
237
|
+
* call-seq:
|
238
|
+
* config.max_db_size = integer
|
239
|
+
*
|
240
|
+
* Set the max_db_size config value.
|
241
|
+
*/
|
242
|
+
static VALUE
|
243
|
+
rkuzu_config_max_db_size_eq( VALUE self, VALUE value )
|
244
|
+
{
|
245
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
246
|
+
config->max_db_size = NUM2ULONG( value );
|
247
|
+
|
248
|
+
return Qtrue;
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
/*
|
253
|
+
* call-seq:
|
254
|
+
* config.auto_checkpoint = true or false
|
255
|
+
*
|
256
|
+
* Set the auto_checkpoint config value.
|
257
|
+
*/
|
258
|
+
static VALUE
|
259
|
+
rkuzu_config_auto_checkpoint_eq( VALUE self, VALUE value )
|
260
|
+
{
|
261
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
262
|
+
config->auto_checkpoint = RTEST( value );
|
263
|
+
|
264
|
+
return Qtrue;
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
/*
|
269
|
+
* call-seq:
|
270
|
+
* config.checkpoint_threshold = integer
|
271
|
+
*
|
272
|
+
* Set the checkpoint_threshold config value.
|
273
|
+
*/
|
274
|
+
static VALUE
|
275
|
+
rkuzu_config_checkpoint_threshold_eq( VALUE self, VALUE value )
|
276
|
+
{
|
277
|
+
kuzu_system_config *config = CHECK_CONFIG( self );
|
278
|
+
config->checkpoint_threshold = NUM2ULONG( value );
|
279
|
+
|
280
|
+
return Qtrue;
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
/*
|
286
|
+
* Document-class: Kuzu::Config
|
287
|
+
*/
|
288
|
+
void
|
289
|
+
rkuzu_init_config( void )
|
290
|
+
{
|
291
|
+
#ifdef FOR_RDOC
|
292
|
+
rkuzu_mKuzu = rb_define_module( "Kuzu" );
|
293
|
+
#endif
|
294
|
+
|
295
|
+
rkuzu_cKuzuConfig = rb_define_class_under( rkuzu_mKuzu, "Config", rb_cObject );
|
296
|
+
|
297
|
+
rb_define_alloc_func( rkuzu_cKuzuConfig, rkuzu_config_s_allocate );
|
298
|
+
|
299
|
+
rb_define_method( rkuzu_cKuzuConfig, "initialize", rkuzu_config_initialize, 0 );
|
300
|
+
|
301
|
+
rb_define_method( rkuzu_cKuzuConfig, "buffer_pool_size", rkuzu_config_buffer_pool_size, 0 );
|
302
|
+
rb_define_method( rkuzu_cKuzuConfig, "max_num_threads", rkuzu_config_max_num_threads, 0 );
|
303
|
+
rb_define_method( rkuzu_cKuzuConfig, "enable_compression", rkuzu_config_enable_compression, 0 );
|
304
|
+
rb_define_method( rkuzu_cKuzuConfig, "read_only", rkuzu_config_read_only, 0 );
|
305
|
+
rb_define_method( rkuzu_cKuzuConfig, "max_db_size", rkuzu_config_max_db_size, 0 );
|
306
|
+
rb_define_method( rkuzu_cKuzuConfig, "auto_checkpoint", rkuzu_config_auto_checkpoint, 0 );
|
307
|
+
rb_define_method( rkuzu_cKuzuConfig, "checkpoint_threshold", rkuzu_config_checkpoint_threshold, 0 );
|
308
|
+
|
309
|
+
rb_define_method( rkuzu_cKuzuConfig, "buffer_pool_size=", rkuzu_config_buffer_pool_size_eq, 1 );
|
310
|
+
rb_define_method( rkuzu_cKuzuConfig, "max_num_threads=", rkuzu_config_max_num_threads_eq, 1 );
|
311
|
+
rb_define_method( rkuzu_cKuzuConfig, "enable_compression=", rkuzu_config_enable_compression_eq, 1 );
|
312
|
+
rb_define_method( rkuzu_cKuzuConfig, "read_only=", rkuzu_config_read_only_eq, 1 );
|
313
|
+
rb_define_method( rkuzu_cKuzuConfig, "max_db_size=", rkuzu_config_max_db_size_eq, 1 );
|
314
|
+
rb_define_method( rkuzu_cKuzuConfig, "auto_checkpoint=", rkuzu_config_auto_checkpoint_eq, 1 );
|
315
|
+
rb_define_method( rkuzu_cKuzuConfig, "checkpoint_threshold=", rkuzu_config_checkpoint_threshold_eq, 1 );
|
316
|
+
|
317
|
+
rb_require( "kuzu/config" );
|
318
|
+
}
|