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.
@@ -0,0 +1,130 @@
1
+ /*
2
+ * kuzu_ext.h - Ruby binding for Kùzu
3
+ *
4
+ * Authors:
5
+ * * Michael Granger <ged@FaerieMUD.org>
6
+ *
7
+ */
8
+
9
+ #ifndef KUZU_EXT_H_AA9CC4A5
10
+ #define KUZU_EXT_H_AA9CC4A5
11
+
12
+ #include "extconf.h"
13
+
14
+ #include <ruby.h>
15
+ #include <ruby/encoding.h>
16
+ #include <ruby/intern.h>
17
+ #include <ruby/thread.h>
18
+ #include <ruby/version.h>
19
+
20
+ #include <stdbool.h>
21
+
22
+ #include "kuzu.h"
23
+
24
+ /* --------------------------------------------------------------
25
+ * Declarations
26
+ * -------------------------------------------------------------- */
27
+
28
+ #ifdef HAVE_STDARG_PROTOTYPES
29
+ #include <stdarg.h>
30
+ #define va_init_list(a, b) va_start (a, b)
31
+ void rkuzu_log_obj (VALUE, const char *, const char *, ...);
32
+ void rkuzu_log (const char *, const char *, ...);
33
+ #else
34
+ #include <varargs.h>
35
+ #define va_init_list(a, b) va_start (a)
36
+ void rkuzu_log_obj (VALUE, const char *, const char *, va_dcl);
37
+ void rkuzu_log (const char *, const char *, va_dcl);
38
+ #endif
39
+
40
+ /* --------------------------------------------------------------
41
+ * Structs
42
+ * -------------------------------------------------------------- */
43
+
44
+ typedef struct {
45
+ kuzu_database db;
46
+ VALUE path;
47
+ VALUE config;
48
+ } rkuzu_database;
49
+
50
+ typedef struct {
51
+ kuzu_connection conn;
52
+ VALUE database;
53
+ VALUE queries;
54
+ VALUE statements;
55
+ } rkuzu_connection;
56
+
57
+ typedef struct {
58
+ kuzu_query_result result;
59
+ VALUE connection;
60
+ VALUE query;
61
+ VALUE statement;
62
+ VALUE previous_result;
63
+ VALUE next_result;
64
+ bool finished;
65
+ } rkuzu_query_result;
66
+
67
+ typedef struct {
68
+ kuzu_prepared_statement statement;
69
+ VALUE connection;
70
+ VALUE query;
71
+ bool finished;
72
+ } rkuzu_prepared_statement;
73
+
74
+
75
+ /* -------------------------------------------------------
76
+ * Globals
77
+ * ------------------------------------------------------- */
78
+
79
+ // Modules and classes
80
+ extern VALUE rkuzu_mKuzu;
81
+ extern VALUE rkuzu_cKuzuDatabase;
82
+ extern VALUE rkuzu_cKuzuConfig;
83
+ extern VALUE rkuzu_cKuzuConnection;
84
+ extern VALUE rkuzu_cKuzuPreparedStatement;
85
+ extern VALUE rkuzu_cKuzuResult;
86
+ extern VALUE rkuzu_cKuzuQuerySummary;
87
+ extern VALUE rkuzu_cKuzuNode;
88
+ extern VALUE rkuzu_cKuzuRecursiveRel;
89
+ extern VALUE rkuzu_cKuzuRel;
90
+
91
+ // Exception types
92
+ extern VALUE rkuzu_eError;
93
+ extern VALUE rkuzu_eDatabaseError;
94
+ extern VALUE rkuzu_eConnectionError;
95
+ extern VALUE rkuzu_eQueryError;
96
+ extern VALUE rkuzu_eFinishedError;
97
+
98
+ // Internal refs to external classes
99
+ extern VALUE rkuzu_rb_cDate;
100
+ extern VALUE rkuzu_rb_cOstruct;
101
+
102
+
103
+ /* -------------------------------------------------------
104
+ * Initializer functions
105
+ * ------------------------------------------------------- */
106
+ extern void Init_kuzu_ext _ ((void));
107
+
108
+ extern void rkuzu_init_database _ ((void));
109
+ extern void rkuzu_init_config _ ((void));
110
+ extern void rkuzu_init_connection _ ((void));
111
+ extern void rkuzu_init_prepared_statement _ ((void));
112
+ extern void rkuzu_init_result _ ((void));
113
+ extern void rkuzu_init_query_summary _ ((void));
114
+ extern void rkuzu_init_node _ ((void));
115
+ extern void rkuzu_init_rel _ ((void));
116
+ extern void rkuzu_init_recursive_rel _ ((void));
117
+
118
+ extern rkuzu_database *rkuzu_get_database _ ((VALUE));
119
+ extern kuzu_system_config *rkuzu_get_config _ ((VALUE));
120
+ extern rkuzu_connection *rkuzu_get_connection _ ((VALUE));
121
+ extern rkuzu_prepared_statement *rkuzu_get_prepared_statement _ ((VALUE));
122
+ extern rkuzu_query_result *rkuzu_get_result _ ((VALUE));
123
+
124
+ extern VALUE rkuzu_convert_kuzu_value_to_ruby _ ((kuzu_data_type_id, kuzu_value *));
125
+ extern VALUE rkuzu_convert_logical_kuzu_value_to_ruby _ ((kuzu_logical_type *, kuzu_value *));
126
+ extern VALUE rkuzu_value_to_ruby _ (( kuzu_value * ));
127
+ extern VALUE rkuzu_result_from_query _ ((VALUE, VALUE, VALUE, kuzu_query_result));
128
+ extern VALUE rkuzu_result_from_prepared_statement _ ((VALUE, VALUE, VALUE, kuzu_query_result));
129
+
130
+ #endif /* end of include guard: KUZU_EXT_H_AA9CC4A5 */
@@ -0,0 +1,24 @@
1
+ /*
2
+ * node.c - Kuzu::Node class
3
+ *
4
+ */
5
+
6
+ #include "kuzu_ext.h"
7
+
8
+ VALUE rkuzu_cKuzuNode;
9
+
10
+
11
+ /*
12
+ * Document-class: Kuzu::Node
13
+ */
14
+ void
15
+ rkuzu_init_node( void )
16
+ {
17
+ #ifdef FOR_RDOC
18
+ rkuzu_mKuzu = rb_define_module( "Kuzu" );
19
+ #endif
20
+
21
+ rkuzu_cKuzuNode = rb_define_class_under( rkuzu_mKuzu, "Node", rb_cObject );
22
+
23
+ rb_require( "kuzu/node" );
24
+ }
@@ -0,0 +1,392 @@
1
+ /*
2
+ * prepared_statement.c - Kuzu::PreparedStatement class
3
+ *
4
+ */
5
+
6
+ #include "kuzu.h"
7
+ #include "kuzu_ext.h"
8
+
9
+ #define CHECK_PREPARED_STATEMENT( self ) \
10
+ ((rkuzu_prepared_statement *)rb_check_typeddata( (self), &rkuzu_prepared_statement_type) )
11
+ // #define DEBUG_GC(msg, ptr) fprintf( stderr, msg, ptr )
12
+ #define DEBUG_GC(msg, ptr)
13
+
14
+
15
+ VALUE rkuzu_cKuzuPreparedStatement;
16
+
17
+ static void rkuzu_prepared_statement_free( void * );
18
+ static void rkuzu_prepared_statement_mark( void * );
19
+ static void rkuzu_bind_string( rkuzu_prepared_statement *, const char *, VALUE );
20
+
21
+ static const rb_data_type_t rkuzu_prepared_statement_type = {
22
+ .wrap_struct_name = "Kuzu::PreparedStatement",
23
+ .function = {
24
+ .dfree = rkuzu_prepared_statement_free,
25
+ .dmark = rkuzu_prepared_statement_mark,
26
+ },
27
+ .data = NULL,
28
+ };
29
+
30
+
31
+
32
+ /*
33
+ * Fetch function
34
+ */
35
+ rkuzu_prepared_statement *
36
+ rkuzu_get_prepared_statement( VALUE prepared_statement_obj )
37
+ {
38
+ return CHECK_PREPARED_STATEMENT( prepared_statement_obj );
39
+ }
40
+
41
+
42
+ /*
43
+ * Allocation function
44
+ */
45
+ static rkuzu_prepared_statement *
46
+ rkuzu_prepared_statement_alloc()
47
+ {
48
+ rkuzu_prepared_statement *ptr = ALLOC( rkuzu_prepared_statement );
49
+
50
+ ptr->connection = Qnil;
51
+ ptr->query = Qnil;
52
+
53
+ return ptr;
54
+ }
55
+
56
+
57
+ /*
58
+ * dmark function
59
+ */
60
+ static void
61
+ rkuzu_prepared_statement_mark( void *ptr )
62
+ {
63
+ rkuzu_prepared_statement *prepared_statement_s = (rkuzu_prepared_statement *)ptr;
64
+
65
+ if ( ptr ) {
66
+ rb_gc_mark( prepared_statement_s->connection );
67
+ rb_gc_mark( prepared_statement_s->query );
68
+ }
69
+ }
70
+
71
+
72
+ /*
73
+ * dfree function
74
+ */
75
+ static void
76
+ rkuzu_prepared_statement_free( void *ptr )
77
+ {
78
+ if ( ptr ) {
79
+ DEBUG_GC( ">>> freeing prepared statement %p\n", ptr );
80
+ // Can't kuzu_prepared_statement_destroy here because the database or connection
81
+ // might already have been destroyed.
82
+ xfree( ptr );
83
+ ptr = NULL;
84
+ }
85
+ }
86
+
87
+
88
+ /*
89
+ * ::allocate function
90
+ */
91
+ static VALUE
92
+ rkuzu_prepared_statement_s_allocate( VALUE klass )
93
+ {
94
+ return TypedData_Wrap_Struct( klass, &rkuzu_prepared_statement_type, NULL );
95
+ }
96
+
97
+
98
+ static VALUE
99
+ rkuzu_prepared_statement_initialize( VALUE self, VALUE connection, VALUE query )
100
+ {
101
+ rkuzu_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
102
+
103
+ if ( !stmt ) {
104
+ rkuzu_connection *conn = rkuzu_get_connection( connection );
105
+ const char *query_s = StringValueCStr( query );
106
+
107
+ stmt = rkuzu_prepared_statement_alloc();
108
+
109
+ if ( kuzu_connection_prepare(&conn->conn, query_s, &stmt->statement) != KuzuSuccess ) {
110
+ char *err_detail = kuzu_prepared_statement_get_error_message( &stmt->statement );
111
+ char errmsg[ 4096 ] = "\0";
112
+
113
+ snprintf( errmsg, 4096, "Could not prepare query `%s': %s.", query_s, err_detail );
114
+
115
+ xfree( stmt );
116
+ stmt = NULL;
117
+ kuzu_destroy_string( err_detail );
118
+
119
+ rb_raise( rkuzu_eQueryError, "%s", errmsg );
120
+ }
121
+
122
+ DEBUG_GC( ">>> allocated prepared statement %p\n", stmt );
123
+ RTYPEDDATA_DATA( self ) = stmt;
124
+
125
+ stmt->connection = connection;
126
+ stmt->query = query;
127
+
128
+ } else {
129
+ rb_raise( rb_eRuntimeError, "cannot reinit prepared statement" );
130
+ }
131
+
132
+ rb_call_super( 0, 0 );
133
+
134
+ return Qtrue;
135
+ }
136
+
137
+
138
+ struct execute_call {
139
+ kuzu_connection *conn;
140
+ kuzu_prepared_statement *stmt;
141
+ kuzu_query_result *result;
142
+ };
143
+
144
+
145
+ static void *
146
+ rkuzu_connection_do_execute_without_gvl( void *ptr )
147
+ {
148
+ struct execute_call *qcall = (struct execute_call *)ptr;
149
+ kuzu_state state;
150
+
151
+ state = kuzu_connection_execute( qcall->conn, qcall->stmt, qcall->result );
152
+
153
+ return (void *)state;
154
+ }
155
+
156
+
157
+ static void
158
+ rkuzu_connection_cancel_execute( void *ptr )
159
+ {
160
+ kuzu_connection *conn = (kuzu_connection *)ptr;
161
+ kuzu_connection_interrupt( conn );
162
+ }
163
+
164
+
165
+ // Inner prepared statement constructor
166
+ static kuzu_query_result
167
+ rkuzu_prepared_statement_do_execute( VALUE self )
168
+ {
169
+ rkuzu_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
170
+ VALUE connection = stmt->connection;
171
+ rkuzu_connection *conn = rkuzu_get_connection( connection );
172
+ kuzu_query_result result;
173
+ struct execute_call qcall;
174
+ kuzu_state execute_state;
175
+ void *result_ptr;
176
+
177
+ qcall.conn = &conn->conn;
178
+ qcall.stmt = &stmt->statement;
179
+ qcall.result = &result;
180
+
181
+ result_ptr = rb_thread_call_without_gvl(
182
+ rkuzu_connection_do_execute_without_gvl, (void *)&qcall,
183
+ rkuzu_connection_cancel_execute, (void *)&conn->conn );
184
+ execute_state = (kuzu_state)result_ptr;
185
+
186
+ if ( execute_state != KuzuSuccess ) {
187
+ char *err_detail = kuzu_query_result_get_error_message( &result );
188
+ char errmsg[ 4096 ] = "\0";
189
+
190
+ snprintf( errmsg, 4096, "Could not execute prepared statement: %s.", err_detail );
191
+
192
+ kuzu_destroy_string( err_detail );
193
+ kuzu_query_result_destroy( &result );
194
+
195
+ rb_raise( rkuzu_eQueryError, "%s", errmsg );
196
+ }
197
+
198
+ return *qcall.result;
199
+ }
200
+
201
+
202
+ static VALUE
203
+ rkuzu_prepared_statement__execute( VALUE self )
204
+ {
205
+ rkuzu_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
206
+ kuzu_query_result result = rkuzu_prepared_statement_do_execute( self );
207
+
208
+ return rkuzu_result_from_prepared_statement( rkuzu_cKuzuResult, stmt->connection, self, result );
209
+ }
210
+
211
+
212
+ static VALUE
213
+ rkuzu_prepared_statement__execute_bang( VALUE self )
214
+ {
215
+ kuzu_query_result result = rkuzu_prepared_statement_do_execute( self );
216
+ return kuzu_query_result_is_success( &result ) ? Qtrue : Qfalse;
217
+ }
218
+
219
+
220
+ /*
221
+ * call-seq:
222
+ * statement.success? -> true or false
223
+ *
224
+ * Returns +true+ if the query was prepared successfully.
225
+ *
226
+ */
227
+ static VALUE
228
+ rkuzu_prepared_statement_success_p( VALUE self )
229
+ {
230
+ rkuzu_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
231
+
232
+ if ( kuzu_prepared_statement_is_success(&stmt->statement) ) {
233
+ return Qtrue;
234
+ } else {
235
+ return Qfalse;
236
+ }
237
+ }
238
+
239
+
240
+ /*
241
+ * call-seq:
242
+ * statement.bind_variable( name, value )
243
+ *
244
+ * Binds the given +value+ to the given parameter +name+ in the prepared statement
245
+ *
246
+ */
247
+ static VALUE
248
+ rkuzu_prepared_statement_bind_variable( VALUE self, VALUE name, VALUE value )
249
+ {
250
+ rkuzu_prepared_statement *stmt = CHECK_PREPARED_STATEMENT( self );
251
+ VALUE name_string = rb_funcall( name, rb_intern("to_s"), 0 );
252
+ const char *name_s = StringValueCStr( name_string );
253
+ kuzu_value *null_value;
254
+
255
+ switch (TYPE(value)) {
256
+ case T_TRUE:
257
+ case T_FALSE:
258
+ kuzu_prepared_statement_bind_bool( &stmt->statement, name_s, RTEST(value) );
259
+ break;
260
+
261
+ // fallthrough
262
+ case T_FLOAT:
263
+ kuzu_prepared_statement_bind_float( &stmt->statement, name_s, NUM2DBL(value) );
264
+ break;
265
+
266
+ case T_BIGNUM:
267
+ kuzu_prepared_statement_bind_int64( &stmt->statement, name_s, NUM2LL(value) );
268
+ break;
269
+
270
+ case T_FIXNUM:
271
+ kuzu_prepared_statement_bind_int32( &stmt->statement, name_s, NUM2INT(value) );
272
+ break;
273
+
274
+ case T_SYMBOL:
275
+ rb_notimplement();
276
+ break; // not reached
277
+
278
+ case T_NIL:
279
+ null_value = kuzu_value_create_null();
280
+ kuzu_prepared_statement_bind_value( &stmt->statement, name_s, null_value );
281
+ kuzu_value_destroy( null_value );
282
+ break;
283
+
284
+ case T_OBJECT:
285
+ case T_CLASS:
286
+ case T_MODULE:
287
+ case T_REGEXP:
288
+ case T_ARRAY:
289
+ case T_HASH:
290
+ case T_STRUCT:
291
+ case T_COMPLEX:
292
+ case T_RATIONAL:
293
+ case T_FILE:
294
+ case T_DATA:
295
+ case T_STRING:
296
+ default:
297
+ rkuzu_bind_string( stmt, name_s, value );
298
+ break;
299
+
300
+ // kuzu_prepared_statement_bind_int8
301
+ // kuzu_prepared_statement_bind_int16
302
+ // kuzu_prepared_statement_bind_uint64
303
+ // kuzu_prepared_statement_bind_uint32
304
+ // kuzu_prepared_statement_bind_uint16
305
+ // kuzu_prepared_statement_bind_uint8
306
+
307
+ // kuzu_prepared_statement_bind_double
308
+ // kuzu_prepared_statement_bind_date
309
+ // kuzu_prepared_statement_bind_timestamp_ns
310
+ // kuzu_prepared_statement_bind_timestamp_sec
311
+ // kuzu_prepared_statement_bind_timestamp_tz
312
+ // kuzu_prepared_statement_bind_timestamp_ms
313
+ // kuzu_prepared_statement_bind_timestamp
314
+ // kuzu_prepared_statement_bind_interval
315
+ // kuzu_prepared_statement_bind_value
316
+ }
317
+
318
+ return Qtrue;
319
+ }
320
+
321
+
322
+ static void
323
+ rkuzu_bind_string( rkuzu_prepared_statement *stmt, const char *name_s, VALUE value )
324
+ {
325
+ const char *value_s = StringValueCStr( value );
326
+ kuzu_prepared_statement_bind_string( &stmt->statement, name_s, value_s );
327
+ }
328
+
329
+
330
+ /*
331
+ * call-seq:
332
+ * statement.connection -> conn
333
+ *
334
+ * Return the Kuzu::Connection used to run this statement.
335
+ *
336
+ */
337
+ static VALUE
338
+ rkuzu_prepared_statement_connection( VALUE self )
339
+ {
340
+ rkuzu_prepared_statement *statement_s = rkuzu_get_prepared_statement( self );
341
+ return statement_s->connection;
342
+ }
343
+
344
+
345
+ /*
346
+ * call-seq:
347
+ * statement.query -> string
348
+ *
349
+ * Return the query string used to build this statement.
350
+ *
351
+ */
352
+ static VALUE
353
+ rkuzu_prepared_statement_query( VALUE self )
354
+ {
355
+ rkuzu_prepared_statement *statement_s = rkuzu_get_prepared_statement( self );
356
+ return statement_s->query;
357
+ }
358
+
359
+
360
+
361
+ /*
362
+ * Document-class: Kuzu::PreparedStatement
363
+ */
364
+ void
365
+ rkuzu_init_prepared_statement( void )
366
+ {
367
+ #ifdef FOR_RDOC
368
+ rkuzu_mKuzu = rb_define_module( "Kuzu" );
369
+ #endif
370
+
371
+ rkuzu_cKuzuPreparedStatement = rb_define_class_under( rkuzu_mKuzu, "PreparedStatement", rb_cObject );
372
+
373
+ rb_define_alloc_func( rkuzu_cKuzuPreparedStatement, rkuzu_prepared_statement_s_allocate );
374
+
375
+ rb_define_protected_method( rkuzu_cKuzuPreparedStatement, "initialize",
376
+ rkuzu_prepared_statement_initialize, 2 );
377
+ rb_define_protected_method( rkuzu_cKuzuPreparedStatement, "_execute",
378
+ rkuzu_prepared_statement__execute, 0 );
379
+ rb_define_protected_method( rkuzu_cKuzuPreparedStatement, "_execute!",
380
+ rkuzu_prepared_statement__execute_bang, 0 );
381
+
382
+ rb_define_method( rkuzu_cKuzuPreparedStatement, "connection",
383
+ rkuzu_prepared_statement_connection, 0 );
384
+ rb_define_method( rkuzu_cKuzuPreparedStatement, "query",
385
+ rkuzu_prepared_statement_query, 0 );
386
+
387
+ rb_define_method( rkuzu_cKuzuPreparedStatement, "success?", rkuzu_prepared_statement_success_p, 0 );
388
+ rb_define_method( rkuzu_cKuzuPreparedStatement, "bind_variable",
389
+ rkuzu_prepared_statement_bind_variable, 2 );
390
+
391
+ rb_require( "kuzu/prepared_statement" );
392
+ }
@@ -0,0 +1,140 @@
1
+ /*
2
+ * query_summary.c - Kuzu::QuerySummary class
3
+ *
4
+ */
5
+
6
+ #include "kuzu_ext.h"
7
+
8
+ #define CHECK_QUERY_SUMMARY(self) \
9
+ ((kuzu_query_summary*)rb_check_typeddata((self), &rkuzu_query_summary_type))
10
+ // #define DEBUG_GC(msg, ptr) fprintf( stderr, msg, ptr )
11
+ #define DEBUG_GC(msg, ptr)
12
+
13
+
14
+ VALUE rkuzu_cKuzuQuerySummary;
15
+
16
+ static void rkuzu_query_summary_free( void * );
17
+
18
+ static const rb_data_type_t rkuzu_query_summary_type = {
19
+ .wrap_struct_name = "Kuzu::QuerySummary",
20
+ .function = {
21
+ .dfree = rkuzu_query_summary_free,
22
+ },
23
+ .data = NULL,
24
+ };
25
+
26
+
27
+ static void
28
+ rkuzu_query_summary_free( void *ptr )
29
+ {
30
+ kuzu_query_summary *query_summary = (kuzu_query_summary *)ptr;
31
+
32
+ if ( ptr ) {
33
+ DEBUG_GC( ">>> freeing query summary %p\n", ptr );
34
+ kuzu_query_summary_destroy( query_summary );
35
+ xfree( ptr );
36
+ }
37
+ }
38
+
39
+
40
+ /*
41
+ * ::allocate function
42
+ */
43
+ static VALUE
44
+ rkuzu_query_summary_s_allocate( VALUE klass )
45
+ {
46
+ return TypedData_Wrap_Struct( klass, &rkuzu_query_summary_type, NULL );
47
+ }
48
+
49
+
50
+ /*
51
+ * call-seq:
52
+ * Kuzu::QuerySummary.from_result( result ) -> query_summary
53
+ *
54
+ * Return a Kuzu::QuerySummary from a Kuzu::QueryResult.
55
+ *
56
+ */
57
+ static VALUE
58
+ rkuzu_query_summary_s_from_result( VALUE klass, VALUE query_result )
59
+ {
60
+ rkuzu_query_result *result = rkuzu_get_result( query_result );
61
+
62
+ kuzu_query_summary *query_summary = ALLOC( kuzu_query_summary );
63
+ VALUE query_summary_obj = rb_class_new_instance( 0, 0, klass );
64
+
65
+ /*
66
+ TODO Release the GIL
67
+ */
68
+ if ( kuzu_query_result_get_query_summary(&result->result, query_summary) != KuzuSuccess ) {
69
+ xfree( query_summary );
70
+ query_summary = NULL;
71
+ rb_raise( rkuzu_eQueryError, "Could not fetch the query summary." );
72
+ }
73
+
74
+ DEBUG_GC( ">>> allocated query summary %p\n", query_summary );
75
+ RTYPEDDATA_DATA( query_summary_obj ) = query_summary;
76
+
77
+ return query_summary_obj;
78
+ }
79
+
80
+
81
+ /**
82
+ * call-seq:
83
+ * summary.compiling_time -> float
84
+ *
85
+ * Returns the compilation time of the given query summary in milliseconds.
86
+ *
87
+ */
88
+ static VALUE
89
+ rkuzu_query_summary_compiling_time( VALUE self )
90
+ {
91
+ kuzu_query_summary *summary = CHECK_QUERY_SUMMARY( self );
92
+ double result = kuzu_query_summary_get_compiling_time( summary );
93
+
94
+ return rb_float_new( result );
95
+ }
96
+
97
+
98
+ /**
99
+ * call-seq:
100
+ * summary.execution_time -> float
101
+ *
102
+ * Returns the execution time of the given query summary in milliseconds.
103
+ *
104
+ */
105
+ static VALUE
106
+ rkuzu_query_summary_execution_time( VALUE self )
107
+ {
108
+ kuzu_query_summary *summary = CHECK_QUERY_SUMMARY( self );
109
+ double result = kuzu_query_summary_get_execution_time( summary );
110
+
111
+ return rb_float_new( result );
112
+ }
113
+
114
+
115
+ /*
116
+ * Document-class: Kuzu::QuerySummary
117
+ */
118
+ void
119
+ rkuzu_init_query_summary( void )
120
+ {
121
+ #ifdef FOR_RDOC
122
+ rkuzu_mKuzu = rb_define_module( "Kuzu" );
123
+ #endif
124
+
125
+ rkuzu_cKuzuQuerySummary = rb_define_class_under( rkuzu_mKuzu, "QuerySummary", rb_cObject );
126
+
127
+ rb_define_alloc_func( rkuzu_cKuzuQuerySummary, rkuzu_query_summary_s_allocate );
128
+ rb_undef_method( CLASS_OF(rkuzu_cKuzuQuerySummary), "new" );
129
+
130
+ rb_define_singleton_method( rkuzu_cKuzuQuerySummary, "from_result",
131
+ rkuzu_query_summary_s_from_result, 1 );
132
+ rb_define_alias( CLASS_OF(rkuzu_cKuzuQuerySummary), "from_query_result", "from_result" );
133
+
134
+ rb_define_method( rkuzu_cKuzuQuerySummary, "compiling_time",
135
+ rkuzu_query_summary_compiling_time, 0 );
136
+ rb_define_method( rkuzu_cKuzuQuerySummary, "execution_time",
137
+ rkuzu_query_summary_execution_time, 0 );
138
+
139
+ rb_require( "kuzu/query_summary" );
140
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * recursive_rel.c - Kuzu::RecursiveRel class
3
+ *
4
+ */
5
+
6
+ #include "kuzu_ext.h"
7
+
8
+ VALUE rkuzu_cKuzuRecursiveRel;
9
+
10
+
11
+ /*
12
+ * Document-class: Kuzu::RecursiveRel
13
+ */
14
+ void
15
+ rkuzu_init_recursive_rel( void )
16
+ {
17
+ #ifdef FOR_RDOC
18
+ rkuzu_mKuzu = rb_define_module( "Kuzu" );
19
+ #endif
20
+
21
+ rkuzu_cKuzuRecursiveRel = rb_define_class_under( rkuzu_mKuzu, "RecursiveRel", rb_cObject );
22
+
23
+ rb_require( "kuzu/recursive_rel" );
24
+ }