duckdb 1.5.2.0 → 1.5.2.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/duckdb.gemspec +37 -0
- data/ext/duckdb/aggregate_function.c +61 -100
- data/ext/duckdb/aggregate_function.h +2 -2
- data/ext/duckdb/appender.c +76 -35
- data/ext/duckdb/appender.h +1 -1
- data/ext/duckdb/client_context.c +5 -5
- data/ext/duckdb/client_context.h +2 -2
- data/ext/duckdb/column.c +13 -13
- data/ext/duckdb/column.h +1 -1
- data/ext/duckdb/connection.c +40 -41
- data/ext/duckdb/connection.h +2 -2
- data/ext/duckdb/converter.h +1 -7
- data/ext/duckdb/conveter.c +6 -6
- data/ext/duckdb/data_chunk.c +22 -22
- data/ext/duckdb/data_chunk.h +2 -2
- data/ext/duckdb/database.c +10 -10
- data/ext/duckdb/database.h +1 -1
- data/ext/duckdb/duckdb.c +17 -17
- data/ext/duckdb/expression.c +8 -8
- data/ext/duckdb/expression.h +1 -1
- data/ext/duckdb/extconf.rb +4 -3
- data/ext/duckdb/extracted_statements.c +15 -15
- data/ext/duckdb/extracted_statements.h +1 -1
- data/ext/duckdb/instance_cache.c +10 -10
- data/ext/duckdb/instance_cache.h +1 -1
- data/ext/duckdb/logical_type.c +94 -133
- data/ext/duckdb/logical_type.h +2 -2
- data/ext/duckdb/memory_helper.c +28 -28
- data/ext/duckdb/pending_result.c +27 -27
- data/ext/duckdb/pending_result.h +2 -2
- data/ext/duckdb/prepared_statement.c +103 -103
- data/ext/duckdb/prepared_statement.h +2 -2
- data/ext/duckdb/result.c +33 -33
- data/ext/duckdb/result.h +2 -3
- data/ext/duckdb/ruby-duckdb.h +4 -0
- data/ext/duckdb/scalar_function.c +3 -3
- data/ext/duckdb/table_description.c +1 -1
- data/ext/duckdb/table_function.c +3 -3
- data/ext/duckdb/table_function_bind_info.c +1 -1
- data/ext/duckdb/value.c +62 -50
- data/ext/duckdb/value.h +2 -2
- data/ext/duckdb/vector.c +20 -20
- data/ext/duckdb/vector.h +2 -2
- data/lib/duckdb/aggregate_function.rb +202 -3
- data/lib/duckdb/appender.rb +74 -0
- data/lib/duckdb/connection.rb +1 -16
- data/lib/duckdb/converter.rb +5 -0
- data/lib/duckdb/logical_type.rb +1 -3
- data/lib/duckdb/prepared_statement.rb +1 -1
- data/lib/duckdb/table_function.rb +0 -1
- data/lib/duckdb/value.rb +19 -0
- data/lib/duckdb/version.rb +1 -1
- metadata +2 -2
- data/lib/duckdb/duckdb_native.so +0 -0
data/ext/duckdb/connection.c
CHANGED
|
@@ -6,16 +6,16 @@ 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
|
|
10
|
-
static VALUE
|
|
11
|
-
static VALUE
|
|
12
|
-
static VALUE
|
|
13
|
-
static VALUE
|
|
14
|
-
static VALUE
|
|
15
|
-
static VALUE
|
|
16
|
-
static VALUE
|
|
17
|
-
static VALUE
|
|
18
|
-
static VALUE
|
|
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_table_function(VALUE self, VALUE table_function);
|
|
19
19
|
|
|
20
20
|
static const rb_data_type_t connection_data_type = {
|
|
21
21
|
"DuckDB/Connection",
|
|
@@ -48,7 +48,7 @@ static size_t memsize(const void *p) {
|
|
|
48
48
|
return sizeof(rubyDuckDBConnection);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
rubyDuckDBConnection *
|
|
51
|
+
rubyDuckDBConnection *rbduckdb_get_struct_connection(VALUE obj) {
|
|
52
52
|
rubyDuckDBConnection *ctx;
|
|
53
53
|
TypedData_Get_Struct(obj, rubyDuckDBConnection, &connection_data_type, ctx);
|
|
54
54
|
return ctx;
|
|
@@ -71,7 +71,7 @@ VALUE rbduckdb_create_connection(VALUE oDuckDBDatabase) {
|
|
|
71
71
|
return obj;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
static VALUE
|
|
74
|
+
static VALUE connection_disconnect(VALUE self) {
|
|
75
75
|
rubyDuckDBConnection *ctx;
|
|
76
76
|
|
|
77
77
|
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
|
@@ -98,7 +98,7 @@ static VALUE duckdb_connection_disconnect(VALUE self) {
|
|
|
98
98
|
* pending_result.execute_task
|
|
99
99
|
* con.interrupt # => nil
|
|
100
100
|
*/
|
|
101
|
-
static VALUE
|
|
101
|
+
static VALUE connection_interrupt(VALUE self) {
|
|
102
102
|
rubyDuckDBConnection *ctx;
|
|
103
103
|
|
|
104
104
|
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
|
@@ -122,7 +122,7 @@ static VALUE duckdb_connection_interrupt(VALUE self) {
|
|
|
122
122
|
* pending_result.execute_task
|
|
123
123
|
* con.query_progress # => Float
|
|
124
124
|
*/
|
|
125
|
-
static VALUE
|
|
125
|
+
static VALUE connection_query_progress(VALUE self) {
|
|
126
126
|
rubyDuckDBConnection *ctx;
|
|
127
127
|
duckdb_query_progress_type progress;
|
|
128
128
|
|
|
@@ -133,7 +133,7 @@ static VALUE duckdb_connection_query_progress(VALUE self) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/* :nodoc: */
|
|
136
|
-
static VALUE
|
|
136
|
+
static VALUE connection__connect(VALUE self, VALUE oDuckDBDatabase) {
|
|
137
137
|
rubyDuckDBConnection *ctx;
|
|
138
138
|
rubyDuckDB *ctxdb;
|
|
139
139
|
|
|
@@ -169,14 +169,14 @@ static void *duckdb_query_nogvl(void *arg) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/* :nodoc: */
|
|
172
|
-
static VALUE
|
|
172
|
+
static VALUE connection__query_sql(VALUE self, VALUE str) {
|
|
173
173
|
rubyDuckDBConnection *ctx;
|
|
174
174
|
rubyDuckDBResult *ctxr;
|
|
175
175
|
|
|
176
176
|
VALUE result = rbduckdb_create_result();
|
|
177
177
|
|
|
178
178
|
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
|
179
|
-
ctxr =
|
|
179
|
+
ctxr = rbduckdb_get_struct_result(result);
|
|
180
180
|
|
|
181
181
|
if (!(ctx->con)) {
|
|
182
182
|
rb_raise(eDuckDBError, "Database connection closed");
|
|
@@ -203,13 +203,13 @@ static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/* :nodoc: */
|
|
206
|
-
static VALUE
|
|
206
|
+
static VALUE connection__register_logical_type(VALUE self, VALUE logical_type) {
|
|
207
207
|
rubyDuckDBConnection *ctxcon;
|
|
208
208
|
rubyDuckDBLogicalType *ctxlt;
|
|
209
209
|
duckdb_state state;
|
|
210
210
|
|
|
211
|
-
ctxcon =
|
|
212
|
-
ctxlt =
|
|
211
|
+
ctxcon = rbduckdb_get_struct_connection(self);
|
|
212
|
+
ctxlt = rbduckdb_get_struct_logical_type(logical_type);
|
|
213
213
|
|
|
214
214
|
state = duckdb_register_logical_type(ctxcon->con, ctxlt->logical_type, NULL);
|
|
215
215
|
|
|
@@ -224,12 +224,12 @@ static VALUE duckdb_connection_register_logical_type(VALUE self, VALUE logical_t
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/* :nodoc: */
|
|
227
|
-
static VALUE
|
|
227
|
+
static VALUE connection__register_scalar_function(VALUE self, VALUE scalar_function) {
|
|
228
228
|
rubyDuckDBConnection *ctxcon;
|
|
229
229
|
rubyDuckDBScalarFunction *ctxsf;
|
|
230
230
|
duckdb_state state;
|
|
231
231
|
|
|
232
|
-
ctxcon =
|
|
232
|
+
ctxcon = rbduckdb_get_struct_connection(self);
|
|
233
233
|
ctxsf = get_struct_scalar_function(scalar_function);
|
|
234
234
|
|
|
235
235
|
state = duckdb_register_scalar_function(ctxcon->con, ctxsf->scalar_function);
|
|
@@ -245,12 +245,12 @@ static VALUE duckdb_connection_register_scalar_function(VALUE self, VALUE scalar
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
/* :nodoc: */
|
|
248
|
-
static VALUE
|
|
248
|
+
static VALUE connection__register_scalar_function_set(VALUE self, VALUE scalar_function_set) {
|
|
249
249
|
rubyDuckDBConnection *ctxcon;
|
|
250
250
|
rubyDuckDBScalarFunctionSet *ctxsfs;
|
|
251
251
|
duckdb_state state;
|
|
252
252
|
|
|
253
|
-
ctxcon =
|
|
253
|
+
ctxcon = rbduckdb_get_struct_connection(self);
|
|
254
254
|
ctxsfs = get_struct_scalar_function_set(scalar_function_set);
|
|
255
255
|
|
|
256
256
|
state = duckdb_register_scalar_function_set(ctxcon->con, ctxsfs->scalar_function_set);
|
|
@@ -266,13 +266,13 @@ static VALUE duckdb_connection_register_scalar_function_set(VALUE self, VALUE sc
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/* :nodoc: */
|
|
269
|
-
static VALUE
|
|
269
|
+
static VALUE connection__register_aggregate_function(VALUE self, VALUE aggregate_function) {
|
|
270
270
|
rubyDuckDBConnection *ctxcon;
|
|
271
271
|
rubyDuckDBAggregateFunction *ctxaf;
|
|
272
272
|
duckdb_state state;
|
|
273
273
|
|
|
274
|
-
ctxcon =
|
|
275
|
-
ctxaf =
|
|
274
|
+
ctxcon = rbduckdb_get_struct_connection(self);
|
|
275
|
+
ctxaf = rbduckdb_get_struct_aggregate_function(aggregate_function);
|
|
276
276
|
|
|
277
277
|
state = duckdb_register_aggregate_function(ctxcon->con, ctxaf->aggregate_function);
|
|
278
278
|
|
|
@@ -286,12 +286,12 @@ static VALUE duckdb_connection_register_aggregate_function(VALUE self, VALUE agg
|
|
|
286
286
|
return self;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
static VALUE
|
|
289
|
+
static VALUE connection__register_table_function(VALUE self, VALUE table_function) {
|
|
290
290
|
rubyDuckDBConnection *ctxcon;
|
|
291
291
|
rubyDuckDBTableFunction *ctxtf;
|
|
292
292
|
duckdb_state state;
|
|
293
293
|
|
|
294
|
-
ctxcon =
|
|
294
|
+
ctxcon = rbduckdb_get_struct_connection(self);
|
|
295
295
|
ctxtf = get_struct_table_function(table_function);
|
|
296
296
|
|
|
297
297
|
state = duckdb_register_table_function(ctxcon->con, ctxtf->table_function);
|
|
@@ -306,22 +306,21 @@ static VALUE duckdb_connection_register_table_function(VALUE self, VALUE table_f
|
|
|
306
306
|
return self;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
void
|
|
309
|
+
void rbduckdb_init_connection(void) {
|
|
310
310
|
#if 0
|
|
311
311
|
VALUE mDuckDB = rb_define_module("DuckDB");
|
|
312
312
|
#endif
|
|
313
313
|
cDuckDBConnection = rb_define_class_under(mDuckDB, "Connection", rb_cObject);
|
|
314
314
|
rb_define_alloc_func(cDuckDBConnection, allocate);
|
|
315
315
|
|
|
316
|
-
rb_define_method(cDuckDBConnection, "disconnect",
|
|
317
|
-
rb_define_method(cDuckDBConnection, "interrupt",
|
|
318
|
-
rb_define_method(cDuckDBConnection, "query_progress",
|
|
319
|
-
rb_define_private_method(cDuckDBConnection, "_register_logical_type",
|
|
320
|
-
rb_define_private_method(cDuckDBConnection, "_register_scalar_function",
|
|
321
|
-
rb_define_private_method(cDuckDBConnection, "_register_scalar_function_set",
|
|
322
|
-
rb_define_private_method(cDuckDBConnection, "_register_aggregate_function",
|
|
323
|
-
rb_define_private_method(cDuckDBConnection, "_register_table_function",
|
|
324
|
-
rb_define_private_method(cDuckDBConnection, "_connect",
|
|
325
|
-
|
|
326
|
-
rb_define_private_method(cDuckDBConnection, "query_sql", duckdb_connection_query_sql, 1);
|
|
316
|
+
rb_define_method(cDuckDBConnection, "disconnect", connection_disconnect, 0);
|
|
317
|
+
rb_define_method(cDuckDBConnection, "interrupt", connection_interrupt, 0);
|
|
318
|
+
rb_define_method(cDuckDBConnection, "query_progress", connection_query_progress, 0);
|
|
319
|
+
rb_define_private_method(cDuckDBConnection, "_register_logical_type", connection__register_logical_type, 1);
|
|
320
|
+
rb_define_private_method(cDuckDBConnection, "_register_scalar_function", connection__register_scalar_function, 1);
|
|
321
|
+
rb_define_private_method(cDuckDBConnection, "_register_scalar_function_set", connection__register_scalar_function_set, 1);
|
|
322
|
+
rb_define_private_method(cDuckDBConnection, "_register_aggregate_function", connection__register_aggregate_function, 1);
|
|
323
|
+
rb_define_private_method(cDuckDBConnection, "_register_table_function", connection__register_table_function, 1);
|
|
324
|
+
rb_define_private_method(cDuckDBConnection, "_connect", connection__connect, 1);
|
|
325
|
+
rb_define_private_method(cDuckDBConnection, "_query_sql", connection__query_sql, 1);
|
|
327
326
|
}
|
data/ext/duckdb/connection.h
CHANGED
|
@@ -8,8 +8,8 @@ struct _rubyDuckDBConnection {
|
|
|
8
8
|
|
|
9
9
|
typedef struct _rubyDuckDBConnection rubyDuckDBConnection;
|
|
10
10
|
|
|
11
|
-
rubyDuckDBConnection *
|
|
12
|
-
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
|
data/ext/duckdb/converter.h
CHANGED
|
@@ -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
|
-
|
|
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
|
data/ext/duckdb/conveter.c
CHANGED
|
@@ -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
|
|
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");
|
data/ext/duckdb/data_chunk.c
CHANGED
|
@@ -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
|
|
10
|
-
static VALUE
|
|
11
|
-
static VALUE
|
|
12
|
-
static VALUE
|
|
13
|
-
static VALUE
|
|
14
|
-
static VALUE
|
|
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 *
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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",
|
|
201
|
-
rb_define_method(cDuckDBDataChunk, "column_count",
|
|
202
|
-
rb_define_method(cDuckDBDataChunk, "size",
|
|
203
|
-
rb_define_method(cDuckDBDataChunk, "size=",
|
|
204
|
-
rb_define_method(cDuckDBDataChunk, "get_vector",
|
|
205
|
-
rb_define_private_method(cDuckDBDataChunk, "_reset",
|
|
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
|
}
|
data/ext/duckdb/data_chunk.h
CHANGED
|
@@ -8,7 +8,7 @@ struct _rubyDuckDBDataChunk {
|
|
|
8
8
|
|
|
9
9
|
typedef struct _rubyDuckDBDataChunk rubyDuckDBDataChunk;
|
|
10
10
|
|
|
11
|
-
rubyDuckDBDataChunk *
|
|
12
|
-
void
|
|
11
|
+
rubyDuckDBDataChunk *rbduckdb_get_struct_data_chunk(VALUE obj);
|
|
12
|
+
void rbduckdb_init_data_chunk(void);
|
|
13
13
|
|
|
14
14
|
#endif
|
data/ext/duckdb/database.c
CHANGED
|
@@ -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
|
|
11
|
-
static VALUE
|
|
12
|
-
static VALUE
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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",
|
|
141
|
-
rb_define_private_method(cDuckDBDatabase, "_connect",
|
|
142
|
-
rb_define_method(cDuckDBDatabase, "close",
|
|
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
|
}
|
data/ext/duckdb/database.h
CHANGED
data/ext/duckdb/duckdb.c
CHANGED
|
@@ -42,28 +42,28 @@ 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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
53
|
+
rbduckdb_init_appender();
|
|
54
54
|
rbduckdb_init_duckdb_config();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
rbduckdb_init_aggregate_function();
|
|
62
|
+
rbduckdb_init_expression();
|
|
63
|
+
rbduckdb_init_client_context();
|
|
64
64
|
rbduckdb_init_duckdb_scalar_function_bind_info();
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
rbduckdb_init_vector();
|
|
66
|
+
rbduckdb_init_data_chunk();
|
|
67
67
|
rbduckdb_init_memory_helper();
|
|
68
68
|
rbduckdb_init_duckdb_table_function();
|
|
69
69
|
rbduckdb_init_duckdb_table_function_bind_info();
|
data/ext/duckdb/expression.c
CHANGED
|
@@ -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
|
|
9
|
-
static VALUE
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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?",
|
|
103
|
-
rb_define_private_method(cDuckDBExpression, "_fold",
|
|
102
|
+
rb_define_method(cDuckDBExpression, "foldable?", expression_foldable_p, 0);
|
|
103
|
+
rb_define_private_method(cDuckDBExpression, "_fold", expression__fold, 1);
|
|
104
104
|
}
|
data/ext/duckdb/expression.h
CHANGED
data/ext/duckdb/extconf.rb
CHANGED
|
@@ -58,9 +58,10 @@ dir_config('duckdb')
|
|
|
58
58
|
check_duckdb_header('duckdb.h', DUCKDB_REQUIRED_VERSION)
|
|
59
59
|
check_duckdb_library('duckdb', 'duckdb_appender_create_query', DUCKDB_REQUIRED_VERSION)
|
|
60
60
|
|
|
61
|
-
# check duckdb >= 1.
|
|
62
|
-
have_func('duckdb_appender_create_query', 'duckdb.h')
|
|
63
|
-
|
|
61
|
+
# check duckdb >= 1.5.0
|
|
64
62
|
have_func('duckdb_unsafe_vector_assign_string_element_len', 'duckdb.h')
|
|
65
63
|
|
|
64
|
+
# check duckdb >= 1.5.2
|
|
65
|
+
have_func('duckdb_geometry_type_get_crs', 'duckdb.h')
|
|
66
|
+
|
|
66
67
|
create_makefile('duckdb/duckdb_native')
|