duckdb 1.5.2.0 → 1.5.3.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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/duckdb.gemspec +37 -0
  4. data/ext/duckdb/aggregate_function.c +62 -100
  5. data/ext/duckdb/aggregate_function.h +2 -2
  6. data/ext/duckdb/aggregate_function_set.c +86 -0
  7. data/ext/duckdb/aggregate_function_set.h +14 -0
  8. data/ext/duckdb/appender.c +121 -39
  9. data/ext/duckdb/appender.h +1 -1
  10. data/ext/duckdb/client_context.c +5 -5
  11. data/ext/duckdb/client_context.h +2 -2
  12. data/ext/duckdb/column.c +13 -13
  13. data/ext/duckdb/column.h +1 -1
  14. data/ext/duckdb/connection.c +63 -41
  15. data/ext/duckdb/connection.h +2 -2
  16. data/ext/duckdb/converter.h +1 -7
  17. data/ext/duckdb/conveter.c +6 -6
  18. data/ext/duckdb/data_chunk.c +22 -22
  19. data/ext/duckdb/data_chunk.h +2 -2
  20. data/ext/duckdb/database.c +10 -10
  21. data/ext/duckdb/database.h +1 -1
  22. data/ext/duckdb/duckdb.c +18 -17
  23. data/ext/duckdb/expression.c +8 -8
  24. data/ext/duckdb/expression.h +1 -1
  25. data/ext/duckdb/extconf.rb +32 -16
  26. data/ext/duckdb/extracted_statements.c +15 -15
  27. data/ext/duckdb/extracted_statements.h +1 -1
  28. data/ext/duckdb/instance_cache.c +10 -10
  29. data/ext/duckdb/instance_cache.h +1 -1
  30. data/ext/duckdb/logical_type.c +94 -133
  31. data/ext/duckdb/logical_type.h +2 -2
  32. data/ext/duckdb/memory_helper.c +28 -28
  33. data/ext/duckdb/pending_result.c +27 -27
  34. data/ext/duckdb/pending_result.h +2 -2
  35. data/ext/duckdb/prepared_statement.c +120 -103
  36. data/ext/duckdb/prepared_statement.h +2 -2
  37. data/ext/duckdb/result.c +24 -74
  38. data/ext/duckdb/result.h +2 -3
  39. data/ext/duckdb/ruby-duckdb.h +5 -0
  40. data/ext/duckdb/scalar_function.c +3 -3
  41. data/ext/duckdb/table_description.c +1 -1
  42. data/ext/duckdb/table_function.c +3 -3
  43. data/ext/duckdb/table_function_bind_info.c +1 -1
  44. data/ext/duckdb/value.c +62 -50
  45. data/ext/duckdb/value.h +2 -2
  46. data/ext/duckdb/vector.c +20 -20
  47. data/ext/duckdb/vector.h +2 -2
  48. data/lib/duckdb/aggregate_function.rb +208 -3
  49. data/lib/duckdb/aggregate_function_set.rb +29 -0
  50. data/lib/duckdb/appender.rb +148 -0
  51. data/lib/duckdb/connection.rb +86 -25
  52. data/lib/duckdb/converter.rb +5 -0
  53. data/lib/duckdb/logical_type.rb +1 -3
  54. data/lib/duckdb/prepared_statement.rb +19 -1
  55. data/lib/duckdb/result.rb +39 -2
  56. data/lib/duckdb/scalar_function.rb +9 -4
  57. data/lib/duckdb/scalar_function_set.rb +0 -1
  58. data/lib/duckdb/table_description.rb +7 -0
  59. data/lib/duckdb/table_function.rb +0 -1
  60. data/lib/duckdb/table_name_parser.rb +58 -0
  61. data/lib/duckdb/value.rb +19 -0
  62. data/lib/duckdb/version.rb +1 -1
  63. data/lib/duckdb.rb +2 -0
  64. metadata +7 -3
  65. data/lib/duckdb/duckdb_native.so +0 -0
@@ -6,16 +6,17 @@ static void deallocate(void *ctx);
6
6
  static void mark(void *ctx);
7
7
  static VALUE allocate(VALUE klass);
8
8
  static size_t memsize(const void *p);
9
- static VALUE duckdb_connection_disconnect(VALUE self);
10
- static VALUE duckdb_connection_interrupt(VALUE self);
11
- static VALUE duckdb_connection_query_progress(VALUE self);
12
- static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase);
13
- static VALUE duckdb_connection_query_sql(VALUE self, VALUE str);
14
- static VALUE duckdb_connection_register_logical_type(VALUE self, VALUE logical_type);
15
- static VALUE duckdb_connection_register_scalar_function(VALUE self, VALUE scalar_function);
16
- static VALUE duckdb_connection_register_scalar_function_set(VALUE self, VALUE scalar_function_set);
17
- static VALUE duckdb_connection_register_aggregate_function(VALUE self, VALUE aggregate_function);
18
- static VALUE duckdb_connection_register_table_function(VALUE self, VALUE table_function);
9
+ static VALUE connection_disconnect(VALUE self);
10
+ static VALUE connection_interrupt(VALUE self);
11
+ static VALUE connection_query_progress(VALUE self);
12
+ static VALUE connection__connect(VALUE self, VALUE oDuckDBDatabase);
13
+ static VALUE connection__query_sql(VALUE self, VALUE str);
14
+ static VALUE connection__register_logical_type(VALUE self, VALUE logical_type);
15
+ static VALUE connection__register_scalar_function(VALUE self, VALUE scalar_function);
16
+ static VALUE connection__register_scalar_function_set(VALUE self, VALUE scalar_function_set);
17
+ static VALUE connection__register_aggregate_function(VALUE self, VALUE aggregate_function);
18
+ static VALUE connection__register_aggregate_function_set(VALUE self, VALUE aggregate_function_set);
19
+ static VALUE connection__register_table_function(VALUE self, VALUE table_function);
19
20
 
20
21
  static const rb_data_type_t connection_data_type = {
21
22
  "DuckDB/Connection",
@@ -48,7 +49,7 @@ static size_t memsize(const void *p) {
48
49
  return sizeof(rubyDuckDBConnection);
49
50
  }
50
51
 
51
- rubyDuckDBConnection *get_struct_connection(VALUE obj) {
52
+ rubyDuckDBConnection *rbduckdb_get_struct_connection(VALUE obj) {
52
53
  rubyDuckDBConnection *ctx;
53
54
  TypedData_Get_Struct(obj, rubyDuckDBConnection, &connection_data_type, ctx);
54
55
  return ctx;
@@ -71,7 +72,7 @@ VALUE rbduckdb_create_connection(VALUE oDuckDBDatabase) {
71
72
  return obj;
72
73
  }
73
74
 
74
- static VALUE duckdb_connection_disconnect(VALUE self) {
75
+ static VALUE connection_disconnect(VALUE self) {
75
76
  rubyDuckDBConnection *ctx;
76
77
 
77
78
  TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
@@ -98,7 +99,7 @@ static VALUE duckdb_connection_disconnect(VALUE self) {
98
99
  * pending_result.execute_task
99
100
  * con.interrupt # => nil
100
101
  */
101
- static VALUE duckdb_connection_interrupt(VALUE self) {
102
+ static VALUE connection_interrupt(VALUE self) {
102
103
  rubyDuckDBConnection *ctx;
103
104
 
104
105
  TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
@@ -122,7 +123,7 @@ static VALUE duckdb_connection_interrupt(VALUE self) {
122
123
  * pending_result.execute_task
123
124
  * con.query_progress # => Float
124
125
  */
125
- static VALUE duckdb_connection_query_progress(VALUE self) {
126
+ static VALUE connection_query_progress(VALUE self) {
126
127
  rubyDuckDBConnection *ctx;
127
128
  duckdb_query_progress_type progress;
128
129
 
@@ -133,7 +134,7 @@ static VALUE duckdb_connection_query_progress(VALUE self) {
133
134
  }
134
135
 
135
136
  /* :nodoc: */
136
- static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
137
+ static VALUE connection__connect(VALUE self, VALUE oDuckDBDatabase) {
137
138
  rubyDuckDBConnection *ctx;
138
139
  rubyDuckDB *ctxdb;
139
140
 
@@ -169,14 +170,14 @@ static void *duckdb_query_nogvl(void *arg) {
169
170
  }
170
171
 
171
172
  /* :nodoc: */
172
- static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
173
+ static VALUE connection__query_sql(VALUE self, VALUE str) {
173
174
  rubyDuckDBConnection *ctx;
174
175
  rubyDuckDBResult *ctxr;
175
176
 
176
177
  VALUE result = rbduckdb_create_result();
177
178
 
178
179
  TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
179
- ctxr = get_struct_result(result);
180
+ ctxr = rbduckdb_get_struct_result(result);
180
181
 
181
182
  if (!(ctx->con)) {
182
183
  rb_raise(eDuckDBError, "Database connection closed");
@@ -203,13 +204,13 @@ static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
203
204
  }
204
205
 
205
206
  /* :nodoc: */
206
- static VALUE duckdb_connection_register_logical_type(VALUE self, VALUE logical_type) {
207
+ static VALUE connection__register_logical_type(VALUE self, VALUE logical_type) {
207
208
  rubyDuckDBConnection *ctxcon;
208
209
  rubyDuckDBLogicalType *ctxlt;
209
210
  duckdb_state state;
210
211
 
211
- ctxcon = get_struct_connection(self);
212
- ctxlt = get_struct_logical_type(logical_type);
212
+ ctxcon = rbduckdb_get_struct_connection(self);
213
+ ctxlt = rbduckdb_get_struct_logical_type(logical_type);
213
214
 
214
215
  state = duckdb_register_logical_type(ctxcon->con, ctxlt->logical_type, NULL);
215
216
 
@@ -224,12 +225,12 @@ static VALUE duckdb_connection_register_logical_type(VALUE self, VALUE logical_t
224
225
  }
225
226
 
226
227
  /* :nodoc: */
227
- static VALUE duckdb_connection_register_scalar_function(VALUE self, VALUE scalar_function) {
228
+ static VALUE connection__register_scalar_function(VALUE self, VALUE scalar_function) {
228
229
  rubyDuckDBConnection *ctxcon;
229
230
  rubyDuckDBScalarFunction *ctxsf;
230
231
  duckdb_state state;
231
232
 
232
- ctxcon = get_struct_connection(self);
233
+ ctxcon = rbduckdb_get_struct_connection(self);
233
234
  ctxsf = get_struct_scalar_function(scalar_function);
234
235
 
235
236
  state = duckdb_register_scalar_function(ctxcon->con, ctxsf->scalar_function);
@@ -245,12 +246,12 @@ static VALUE duckdb_connection_register_scalar_function(VALUE self, VALUE scalar
245
246
  }
246
247
 
247
248
  /* :nodoc: */
248
- static VALUE duckdb_connection_register_scalar_function_set(VALUE self, VALUE scalar_function_set) {
249
+ static VALUE connection__register_scalar_function_set(VALUE self, VALUE scalar_function_set) {
249
250
  rubyDuckDBConnection *ctxcon;
250
251
  rubyDuckDBScalarFunctionSet *ctxsfs;
251
252
  duckdb_state state;
252
253
 
253
- ctxcon = get_struct_connection(self);
254
+ ctxcon = rbduckdb_get_struct_connection(self);
254
255
  ctxsfs = get_struct_scalar_function_set(scalar_function_set);
255
256
 
256
257
  state = duckdb_register_scalar_function_set(ctxcon->con, ctxsfs->scalar_function_set);
@@ -266,13 +267,13 @@ static VALUE duckdb_connection_register_scalar_function_set(VALUE self, VALUE sc
266
267
  }
267
268
 
268
269
  /* :nodoc: */
269
- static VALUE duckdb_connection_register_aggregate_function(VALUE self, VALUE aggregate_function) {
270
+ static VALUE connection__register_aggregate_function(VALUE self, VALUE aggregate_function) {
270
271
  rubyDuckDBConnection *ctxcon;
271
272
  rubyDuckDBAggregateFunction *ctxaf;
272
273
  duckdb_state state;
273
274
 
274
- ctxcon = get_struct_connection(self);
275
- ctxaf = get_struct_aggregate_function(aggregate_function);
275
+ ctxcon = rbduckdb_get_struct_connection(self);
276
+ ctxaf = rbduckdb_get_struct_aggregate_function(aggregate_function);
276
277
 
277
278
  state = duckdb_register_aggregate_function(ctxcon->con, ctxaf->aggregate_function);
278
279
 
@@ -286,12 +287,33 @@ static VALUE duckdb_connection_register_aggregate_function(VALUE self, VALUE agg
286
287
  return self;
287
288
  }
288
289
 
289
- static VALUE duckdb_connection_register_table_function(VALUE self, VALUE table_function) {
290
+ /* :nodoc: */
291
+ static VALUE connection__register_aggregate_function_set(VALUE self, VALUE aggregate_function_set) {
292
+ rubyDuckDBConnection *ctxcon;
293
+ rubyDuckDBAggregateFunctionSet *ctxafs;
294
+ duckdb_state state;
295
+
296
+ ctxcon = rbduckdb_get_struct_connection(self);
297
+ ctxafs = rbduckdb_get_struct_aggregate_function_set(aggregate_function_set);
298
+
299
+ state = duckdb_register_aggregate_function_set(ctxcon->con, ctxafs->aggregate_function_set);
300
+
301
+ if (state == DuckDBError) {
302
+ rb_raise(eDuckDBError, "Failed to register aggregate function set");
303
+ }
304
+
305
+ /* Keep reference to prevent GC while connection is alive */
306
+ rb_ary_push(ctxcon->registered_functions, aggregate_function_set);
307
+
308
+ return self;
309
+ }
310
+
311
+ static VALUE connection__register_table_function(VALUE self, VALUE table_function) {
290
312
  rubyDuckDBConnection *ctxcon;
291
313
  rubyDuckDBTableFunction *ctxtf;
292
314
  duckdb_state state;
293
315
 
294
- ctxcon = get_struct_connection(self);
316
+ ctxcon = rbduckdb_get_struct_connection(self);
295
317
  ctxtf = get_struct_table_function(table_function);
296
318
 
297
319
  state = duckdb_register_table_function(ctxcon->con, ctxtf->table_function);
@@ -306,22 +328,22 @@ static VALUE duckdb_connection_register_table_function(VALUE self, VALUE table_f
306
328
  return self;
307
329
  }
308
330
 
309
- void rbduckdb_init_duckdb_connection(void) {
331
+ void rbduckdb_init_connection(void) {
310
332
  #if 0
311
333
  VALUE mDuckDB = rb_define_module("DuckDB");
312
334
  #endif
313
335
  cDuckDBConnection = rb_define_class_under(mDuckDB, "Connection", rb_cObject);
314
336
  rb_define_alloc_func(cDuckDBConnection, allocate);
315
337
 
316
- rb_define_method(cDuckDBConnection, "disconnect", duckdb_connection_disconnect, 0);
317
- rb_define_method(cDuckDBConnection, "interrupt", duckdb_connection_interrupt, 0);
318
- rb_define_method(cDuckDBConnection, "query_progress", duckdb_connection_query_progress, 0);
319
- rb_define_private_method(cDuckDBConnection, "_register_logical_type", duckdb_connection_register_logical_type, 1);
320
- rb_define_private_method(cDuckDBConnection, "_register_scalar_function", duckdb_connection_register_scalar_function, 1);
321
- rb_define_private_method(cDuckDBConnection, "_register_scalar_function_set", duckdb_connection_register_scalar_function_set, 1);
322
- rb_define_private_method(cDuckDBConnection, "_register_aggregate_function", duckdb_connection_register_aggregate_function, 1);
323
- rb_define_private_method(cDuckDBConnection, "_register_table_function", duckdb_connection_register_table_function, 1);
324
- rb_define_private_method(cDuckDBConnection, "_connect", duckdb_connection_connect, 1);
325
- /* TODO: query_sql => _query_sql */
326
- rb_define_private_method(cDuckDBConnection, "query_sql", duckdb_connection_query_sql, 1);
338
+ rb_define_method(cDuckDBConnection, "disconnect", connection_disconnect, 0);
339
+ rb_define_method(cDuckDBConnection, "interrupt", connection_interrupt, 0);
340
+ rb_define_method(cDuckDBConnection, "query_progress", connection_query_progress, 0);
341
+ rb_define_private_method(cDuckDBConnection, "_register_logical_type", connection__register_logical_type, 1);
342
+ rb_define_private_method(cDuckDBConnection, "_register_scalar_function", connection__register_scalar_function, 1);
343
+ rb_define_private_method(cDuckDBConnection, "_register_scalar_function_set", connection__register_scalar_function_set, 1);
344
+ rb_define_private_method(cDuckDBConnection, "_register_aggregate_function", connection__register_aggregate_function, 1);
345
+ rb_define_private_method(cDuckDBConnection, "_register_aggregate_function_set", connection__register_aggregate_function_set, 1);
346
+ rb_define_private_method(cDuckDBConnection, "_register_table_function", connection__register_table_function, 1);
347
+ rb_define_private_method(cDuckDBConnection, "_connect", connection__connect, 1);
348
+ rb_define_private_method(cDuckDBConnection, "_query_sql", connection__query_sql, 1);
327
349
  }
@@ -8,8 +8,8 @@ struct _rubyDuckDBConnection {
8
8
 
9
9
  typedef struct _rubyDuckDBConnection rubyDuckDBConnection;
10
10
 
11
- rubyDuckDBConnection *get_struct_connection(VALUE obj);
12
- void rbduckdb_init_duckdb_connection(void);
11
+ rubyDuckDBConnection *rbduckdb_get_struct_connection(VALUE obj);
12
+ void rbduckdb_init_connection(void);
13
13
  VALUE rbduckdb_create_connection(VALUE oDuckDBDatabase);
14
14
 
15
15
  #endif
@@ -32,12 +32,6 @@ VALUE rbduckdb_time_to_ruby(duckdb_time t);
32
32
  VALUE rbduckdb_date_to_ruby(duckdb_date date);
33
33
  VALUE rbduckdb_timestamp_to_ruby(duckdb_timestamp ts);
34
34
 
35
- VALUE infinite_date_value(duckdb_date date);
36
- VALUE infinite_timestamp_value(duckdb_timestamp timestamp);
37
- VALUE infinite_timestamp_s_value(duckdb_timestamp_s timestamp_s);
38
- VALUE infinite_timestamp_ms_value(duckdb_timestamp_ms timestamp_ms);
39
- VALUE infinite_timestamp_ns_value(duckdb_timestamp_ns timestamp_ns);
40
-
41
- void rbduckdb_init_duckdb_converter(void);
35
+ void rbduckdb_init_converter(void);
42
36
 
43
37
  #endif
@@ -17,7 +17,7 @@ ID id__to_time_from_duckdb_timestamp_tz;
17
17
  ID id__to_infinity;
18
18
  ID id__decimal_to_unscaled;
19
19
 
20
- VALUE infinite_date_value(duckdb_date date) {
20
+ static VALUE infinite_date_value(duckdb_date date) {
21
21
  if (duckdb_is_finite_date(date) == false) {
22
22
  return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
23
23
  INT2NUM(date.days)
@@ -26,7 +26,7 @@ VALUE infinite_date_value(duckdb_date date) {
26
26
  return Qnil;
27
27
  }
28
28
 
29
- VALUE infinite_timestamp_value(duckdb_timestamp timestamp) {
29
+ static VALUE infinite_timestamp_value(duckdb_timestamp timestamp) {
30
30
  if (duckdb_is_finite_timestamp(timestamp) == false) {
31
31
  return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
32
32
  LL2NUM(timestamp.micros)
@@ -35,7 +35,7 @@ VALUE infinite_timestamp_value(duckdb_timestamp timestamp) {
35
35
  return Qnil;
36
36
  }
37
37
 
38
- VALUE infinite_timestamp_s_value(duckdb_timestamp_s timestamp_s) {
38
+ static VALUE infinite_timestamp_s_value(duckdb_timestamp_s timestamp_s) {
39
39
  if (duckdb_is_finite_timestamp_s(timestamp_s) == false) {
40
40
  return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
41
41
  LL2NUM(timestamp_s.seconds)
@@ -44,7 +44,7 @@ VALUE infinite_timestamp_s_value(duckdb_timestamp_s timestamp_s) {
44
44
  return Qnil;
45
45
  }
46
46
 
47
- VALUE infinite_timestamp_ms_value(duckdb_timestamp_ms timestamp_ms) {
47
+ static VALUE infinite_timestamp_ms_value(duckdb_timestamp_ms timestamp_ms) {
48
48
  if (duckdb_is_finite_timestamp_ms(timestamp_ms) == false) {
49
49
  return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
50
50
  LL2NUM(timestamp_ms.millis)
@@ -53,7 +53,7 @@ VALUE infinite_timestamp_ms_value(duckdb_timestamp_ms timestamp_ms) {
53
53
  return Qnil;
54
54
  }
55
55
 
56
- VALUE infinite_timestamp_ns_value(duckdb_timestamp_ns timestamp_ns) {
56
+ static VALUE infinite_timestamp_ns_value(duckdb_timestamp_ns timestamp_ns) {
57
57
  if (duckdb_is_finite_timestamp_ns(timestamp_ns) == false) {
58
58
  return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
59
59
  LL2NUM(timestamp_ns.nanos)
@@ -320,7 +320,7 @@ VALUE rbduckdb_timestamp_to_ruby(duckdb_timestamp ts) {
320
320
  return obj;
321
321
  }
322
322
 
323
- void rbduckdb_init_duckdb_converter(void) {
323
+ void rbduckdb_init_converter(void) {
324
324
  mDuckDBConverter = rb_define_module_under(mDuckDB, "Converter");
325
325
 
326
326
  id__to_date = rb_intern("_to_date");
@@ -6,12 +6,12 @@ extern VALUE cDuckDBVector;
6
6
  static void deallocate(void *ctx);
7
7
  static VALUE allocate(VALUE klass);
8
8
  static size_t memsize(const void *p);
9
- static VALUE initialize(int argc, VALUE *argv, VALUE self);
10
- static VALUE rbduckdb_data_chunk_column_count(VALUE self);
11
- static VALUE rbduckdb_data_chunk_get_size(VALUE self);
12
- static VALUE rbduckdb_data_chunk_set_size(VALUE self, VALUE size);
13
- static VALUE rbduckdb_data_chunk_get_vector(VALUE self, VALUE col_idx);
14
- static VALUE rbduckdb_data_chunk__reset(VALUE self);
9
+ static VALUE data_chunk_initialize(int argc, VALUE *argv, VALUE self);
10
+ static VALUE data_chunk_column_count(VALUE self);
11
+ static VALUE data_chunk_size(VALUE self);
12
+ static VALUE data_chunk_set_size(VALUE self, VALUE size);
13
+ static VALUE data_chunk_get_vector(VALUE self, VALUE col_idx);
14
+ static VALUE data_chunk__reset(VALUE self);
15
15
 
16
16
  static const rb_data_type_t data_chunk_data_type = {
17
17
  "DuckDB/DataChunk",
@@ -38,13 +38,13 @@ static size_t memsize(const void *p) {
38
38
  return sizeof(rubyDuckDBDataChunk);
39
39
  }
40
40
 
41
- rubyDuckDBDataChunk *get_struct_data_chunk(VALUE obj) {
41
+ rubyDuckDBDataChunk *rbduckdb_get_struct_data_chunk(VALUE obj) {
42
42
  rubyDuckDBDataChunk *ctx;
43
43
  TypedData_Get_Struct(obj, rubyDuckDBDataChunk, &data_chunk_data_type, ctx);
44
44
  return ctx;
45
45
  }
46
46
 
47
- static VALUE initialize(int argc, VALUE *argv, VALUE self) {
47
+ static VALUE data_chunk_initialize(int argc, VALUE *argv, VALUE self) {
48
48
  rubyDuckDBDataChunk *ctx;
49
49
  VALUE logical_types;
50
50
  idx_t column_count;
@@ -70,7 +70,7 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self) {
70
70
 
71
71
  for (i = 0; i < RARRAY_LEN(logical_types); i++) {
72
72
  VALUE logical_type = rb_ary_entry(logical_types, i);
73
- rubyDuckDBLogicalType *logical_type_ctx = get_struct_logical_type(logical_type);
73
+ rubyDuckDBLogicalType *logical_type_ctx = rbduckdb_get_struct_logical_type(logical_type);
74
74
  types[i] = logical_type_ctx->logical_type;
75
75
  }
76
76
 
@@ -94,7 +94,7 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self) {
94
94
  *
95
95
  * data_chunk.column_count # => 2
96
96
  */
97
- static VALUE rbduckdb_data_chunk_column_count(VALUE self) {
97
+ static VALUE data_chunk_column_count(VALUE self) {
98
98
  rubyDuckDBDataChunk *ctx;
99
99
  idx_t count;
100
100
 
@@ -113,7 +113,7 @@ static VALUE rbduckdb_data_chunk_column_count(VALUE self) {
113
113
  *
114
114
  * data_chunk.size # => 100
115
115
  */
116
- static VALUE rbduckdb_data_chunk_get_size(VALUE self) {
116
+ static VALUE data_chunk_size(VALUE self) {
117
117
  rubyDuckDBDataChunk *ctx;
118
118
  idx_t size;
119
119
 
@@ -132,7 +132,7 @@ static VALUE rbduckdb_data_chunk_get_size(VALUE self) {
132
132
  *
133
133
  * data_chunk.size = 50
134
134
  */
135
- static VALUE rbduckdb_data_chunk_set_size(VALUE self, VALUE size) {
135
+ static VALUE data_chunk_set_size(VALUE self, VALUE size) {
136
136
  rubyDuckDBDataChunk *ctx;
137
137
  idx_t sz;
138
138
 
@@ -152,7 +152,7 @@ static VALUE rbduckdb_data_chunk_set_size(VALUE self, VALUE size) {
152
152
  *
153
153
  * vector = data_chunk.get_vector(0)
154
154
  */
155
- static VALUE rbduckdb_data_chunk_get_vector(VALUE self, VALUE col_idx) {
155
+ static VALUE data_chunk_get_vector(VALUE self, VALUE col_idx) {
156
156
  rubyDuckDBDataChunk *ctx;
157
157
  idx_t idx;
158
158
  duckdb_vector vector;
@@ -166,7 +166,7 @@ static VALUE rbduckdb_data_chunk_get_vector(VALUE self, VALUE col_idx) {
166
166
 
167
167
  // Create Vector wrapper
168
168
  vector_obj = rb_class_new_instance(0, NULL, cDuckDBVector);
169
- vector_ctx = get_struct_vector(vector_obj);
169
+ vector_ctx = rbduckdb_get_struct_vector(vector_obj);
170
170
  vector_ctx->vector = vector;
171
171
 
172
172
  return vector_obj;
@@ -180,7 +180,7 @@ static VALUE rbduckdb_data_chunk_get_vector(VALUE self, VALUE col_idx) {
180
180
  *
181
181
  * data_chunk._reset
182
182
  */
183
- static VALUE rbduckdb_data_chunk__reset(VALUE self) {
183
+ static VALUE data_chunk__reset(VALUE self) {
184
184
  rubyDuckDBDataChunk *ctx;
185
185
 
186
186
  TypedData_Get_Struct(self, rubyDuckDBDataChunk, &data_chunk_data_type, ctx);
@@ -190,17 +190,17 @@ static VALUE rbduckdb_data_chunk__reset(VALUE self) {
190
190
  return self;
191
191
  }
192
192
 
193
- void rbduckdb_init_duckdb_data_chunk(void) {
193
+ void rbduckdb_init_data_chunk(void) {
194
194
  #if 0
195
195
  VALUE mDuckDB = rb_define_module("DuckDB");
196
196
  #endif
197
197
  cDuckDBDataChunk = rb_define_class_under(mDuckDB, "DataChunk", rb_cObject);
198
198
  rb_define_alloc_func(cDuckDBDataChunk, allocate);
199
199
 
200
- rb_define_method(cDuckDBDataChunk, "initialize", initialize, -1);
201
- rb_define_method(cDuckDBDataChunk, "column_count", rbduckdb_data_chunk_column_count, 0);
202
- rb_define_method(cDuckDBDataChunk, "size", rbduckdb_data_chunk_get_size, 0);
203
- rb_define_method(cDuckDBDataChunk, "size=", rbduckdb_data_chunk_set_size, 1);
204
- rb_define_method(cDuckDBDataChunk, "get_vector", rbduckdb_data_chunk_get_vector, 1);
205
- rb_define_private_method(cDuckDBDataChunk, "_reset", rbduckdb_data_chunk__reset, 0);
200
+ rb_define_method(cDuckDBDataChunk, "initialize", data_chunk_initialize, -1);
201
+ rb_define_method(cDuckDBDataChunk, "column_count", data_chunk_column_count, 0);
202
+ rb_define_method(cDuckDBDataChunk, "size", data_chunk_size, 0);
203
+ rb_define_method(cDuckDBDataChunk, "size=", data_chunk_set_size, 1);
204
+ rb_define_method(cDuckDBDataChunk, "get_vector", data_chunk_get_vector, 1);
205
+ rb_define_private_method(cDuckDBDataChunk, "_reset", data_chunk__reset, 0);
206
206
  }
@@ -8,7 +8,7 @@ struct _rubyDuckDBDataChunk {
8
8
 
9
9
  typedef struct _rubyDuckDBDataChunk rubyDuckDBDataChunk;
10
10
 
11
- rubyDuckDBDataChunk *get_struct_data_chunk(VALUE obj);
12
- void rbduckdb_init_duckdb_data_chunk(void);
11
+ rubyDuckDBDataChunk *rbduckdb_get_struct_data_chunk(VALUE obj);
12
+ void rbduckdb_init_data_chunk(void);
13
13
 
14
14
  #endif
@@ -7,9 +7,9 @@ static void deallocate(void * ctx);
7
7
  static VALUE allocate(VALUE klass);
8
8
  static size_t memsize(const void *p);
9
9
  static duckdb_config create_config_with_ruby_api(void);
10
- static VALUE duckdb_database__initialize(VALUE self, VALUE file, VALUE config);
11
- static VALUE duckdb_database_connect(VALUE self);
12
- static VALUE duckdb_database_close(VALUE self);
10
+ static VALUE database__initialize(VALUE self, VALUE file, VALUE config);
11
+ static VALUE database__connect(VALUE self);
12
+ static VALUE database_close(VALUE self);
13
13
 
14
14
  static const rb_data_type_t database_data_type = {
15
15
  "DuckDB/Database",
@@ -59,7 +59,7 @@ static duckdb_config create_config_with_ruby_api(void) {
59
59
  }
60
60
 
61
61
  /* :nodoc: */
62
- static VALUE duckdb_database__initialize(VALUE self, VALUE file, VALUE config) {
62
+ static VALUE database__initialize(VALUE self, VALUE file, VALUE config) {
63
63
  rubyDuckDB *ctx;
64
64
  rubyDuckDBConfig *ctx_config;
65
65
  duckdb_config config_to_use;
@@ -106,7 +106,7 @@ static VALUE duckdb_database__initialize(VALUE self, VALUE file, VALUE config) {
106
106
  }
107
107
 
108
108
  /* :nodoc: */
109
- static VALUE duckdb_database_connect(VALUE self) {
109
+ static VALUE database__connect(VALUE self) {
110
110
  return rbduckdb_create_connection(self);
111
111
  }
112
112
 
@@ -116,7 +116,7 @@ static VALUE duckdb_database_connect(VALUE self) {
116
116
  *
117
117
  * closes DuckDB database.
118
118
  */
119
- static VALUE duckdb_database_close(VALUE self) {
119
+ static VALUE database_close(VALUE self) {
120
120
  rubyDuckDB *ctx;
121
121
  TypedData_Get_Struct(self, rubyDuckDB, &database_data_type, ctx);
122
122
  close_database(ctx);
@@ -131,13 +131,13 @@ VALUE rbduckdb_create_database_obj(duckdb_database db) {
131
131
  return obj;
132
132
  }
133
133
 
134
- void rbduckdb_init_duckdb_database(void) {
134
+ void rbduckdb_init_database(void) {
135
135
  #if 0
136
136
  VALUE mDuckDB = rb_define_module("DuckDB");
137
137
  #endif
138
138
  cDuckDBDatabase = rb_define_class_under(mDuckDB, "Database", rb_cObject);
139
139
  rb_define_alloc_func(cDuckDBDatabase, allocate);
140
- rb_define_private_method(cDuckDBDatabase, "_initialize", duckdb_database__initialize, 2);
141
- rb_define_private_method(cDuckDBDatabase, "_connect", duckdb_database_connect, 0);
142
- rb_define_method(cDuckDBDatabase, "close", duckdb_database_close, 0);
140
+ rb_define_private_method(cDuckDBDatabase, "_initialize", database__initialize, 2);
141
+ rb_define_private_method(cDuckDBDatabase, "_connect", database__connect, 0);
142
+ rb_define_method(cDuckDBDatabase, "close", database_close, 0);
143
143
  }
@@ -9,6 +9,6 @@ typedef struct _rubyDuckDB rubyDuckDB;
9
9
 
10
10
  rubyDuckDB *rbduckdb_get_struct_database(VALUE obj);
11
11
  VALUE rbduckdb_create_database_obj(duckdb_database db);
12
- void rbduckdb_init_duckdb_database(void);
12
+ void rbduckdb_init_database(void);
13
13
 
14
14
  #endif
data/ext/duckdb/duckdb.c CHANGED
@@ -42,28 +42,29 @@ Init_duckdb_native(void) {
42
42
  rb_define_singleton_method(mDuckDB, "vector_size", duckdb_s_vector_size, 0);
43
43
 
44
44
  rbduckdb_init_duckdb_error();
45
- rbduckdb_init_duckdb_database();
46
- rbduckdb_init_duckdb_connection();
47
- rbduckdb_init_duckdb_result();
48
- rbduckdb_init_duckdb_column();
49
- rbduckdb_init_duckdb_logical_type();
50
- rbduckdb_init_duckdb_prepared_statement();
51
- rbduckdb_init_duckdb_pending_result();
45
+ rbduckdb_init_database();
46
+ rbduckdb_init_connection();
47
+ rbduckdb_init_result();
48
+ rbduckdb_init_column();
49
+ rbduckdb_init_logical_type();
50
+ rbduckdb_init_prepared_statement();
51
+ rbduckdb_init_pending_result();
52
52
  rbduckdb_init_duckdb_blob();
53
- rbduckdb_init_duckdb_appender();
53
+ rbduckdb_init_appender();
54
54
  rbduckdb_init_duckdb_config();
55
- rbduckdb_init_duckdb_converter();
56
- rbduckdb_init_duckdb_extracted_statements();
57
- rbduckdb_init_duckdb_instance_cache();
58
- rbduckdb_init_duckdb_value();
55
+ rbduckdb_init_converter();
56
+ rbduckdb_init_extracted_statements();
57
+ rbduckdb_init_instance_cache();
58
+ rbduckdb_init_value();
59
59
  rbduckdb_init_duckdb_scalar_function();
60
60
  rbduckdb_init_duckdb_scalar_function_set();
61
- rbduckdb_init_duckdb_aggregate_function();
62
- rbduckdb_init_duckdb_expression();
63
- rbduckdb_init_duckdb_client_context();
61
+ rbduckdb_init_aggregate_function();
62
+ rbduckdb_init_aggregate_function_set();
63
+ rbduckdb_init_expression();
64
+ rbduckdb_init_client_context();
64
65
  rbduckdb_init_duckdb_scalar_function_bind_info();
65
- rbduckdb_init_duckdb_vector();
66
- rbduckdb_init_duckdb_data_chunk();
66
+ rbduckdb_init_vector();
67
+ rbduckdb_init_data_chunk();
67
68
  rbduckdb_init_memory_helper();
68
69
  rbduckdb_init_duckdb_table_function();
69
70
  rbduckdb_init_duckdb_table_function_bind_info();
@@ -5,8 +5,8 @@ VALUE cDuckDBExpression;
5
5
  static void deallocate(void *ctx);
6
6
  static VALUE allocate(VALUE klass);
7
7
  static size_t memsize(const void *p);
8
- static VALUE rbduckdb_expression_foldable_p(VALUE self);
9
- static VALUE rbduckdb_expression_fold(VALUE self, VALUE client_context);
8
+ static VALUE expression_foldable_p(VALUE self);
9
+ static VALUE expression__fold(VALUE self, VALUE client_context);
10
10
 
11
11
  static const rb_data_type_t expression_data_type = {
12
12
  "DuckDB/Expression",
@@ -51,7 +51,7 @@ VALUE rbduckdb_expression_new(duckdb_expression expression) {
51
51
  * planning time (e.g. literals, constant arithmetic), +false+ otherwise
52
52
  * (e.g. column references, non-deterministic functions).
53
53
  */
54
- static VALUE rbduckdb_expression_foldable_p(VALUE self) {
54
+ static VALUE expression_foldable_p(VALUE self) {
55
55
  rubyDuckDBExpression *ctx;
56
56
  TypedData_Get_Struct(self, rubyDuckDBExpression, &expression_data_type, ctx);
57
57
  return duckdb_expression_is_foldable(ctx->expression) ? Qtrue : Qfalse;
@@ -66,7 +66,7 @@ static VALUE rbduckdb_expression_foldable_p(VALUE self) {
66
66
  * Use the public Expression#fold instead, which guards against non-foldable
67
67
  * expressions before calling this method.
68
68
  */
69
- static VALUE rbduckdb_expression_fold(VALUE self, VALUE client_context) {
69
+ static VALUE expression__fold(VALUE self, VALUE client_context) {
70
70
  rubyDuckDBExpression *expr_ctx;
71
71
  rubyDuckDBClientContext *cc_ctx;
72
72
  duckdb_value out_value = NULL;
@@ -74,7 +74,7 @@ static VALUE rbduckdb_expression_fold(VALUE self, VALUE client_context) {
74
74
  VALUE result;
75
75
 
76
76
  TypedData_Get_Struct(self, rubyDuckDBExpression, &expression_data_type, expr_ctx);
77
- cc_ctx = get_struct_client_context(client_context);
77
+ cc_ctx = rbduckdb_get_struct_client_context(client_context);
78
78
 
79
79
  error_data = duckdb_expression_fold(cc_ctx->client_context, expr_ctx->expression, &out_value);
80
80
 
@@ -93,12 +93,12 @@ static VALUE rbduckdb_expression_fold(VALUE self, VALUE client_context) {
93
93
  return result;
94
94
  }
95
95
 
96
- void rbduckdb_init_duckdb_expression(void) {
96
+ void rbduckdb_init_expression(void) {
97
97
  #if 0
98
98
  VALUE mDuckDB = rb_define_module("DuckDB");
99
99
  #endif
100
100
  cDuckDBExpression = rb_define_class_under(mDuckDB, "Expression", rb_cObject);
101
101
  rb_define_alloc_func(cDuckDBExpression, allocate);
102
- rb_define_method(cDuckDBExpression, "foldable?", rbduckdb_expression_foldable_p, 0);
103
- rb_define_private_method(cDuckDBExpression, "_fold", rbduckdb_expression_fold, 1);
102
+ rb_define_method(cDuckDBExpression, "foldable?", expression_foldable_p, 0);
103
+ rb_define_private_method(cDuckDBExpression, "_fold", expression__fold, 1);
104
104
  }
@@ -7,7 +7,7 @@ struct _rubyDuckDBExpression {
7
7
 
8
8
  typedef struct _rubyDuckDBExpression rubyDuckDBExpression;
9
9
 
10
- void rbduckdb_init_duckdb_expression(void);
10
+ void rbduckdb_init_expression(void);
11
11
  VALUE rbduckdb_expression_new(duckdb_expression expression);
12
12
 
13
13
  #endif