rroonga 7.0.2 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/doc/text/news.md +46 -7
- data/ext/groonga/rb-grn-array.c +1 -272
- data/ext/groonga/rb-grn-column-cache.c +240 -0
- data/ext/groonga/rb-grn-column.c +1 -1
- data/ext/groonga/rb-grn-context.c +28 -4
- data/ext/groonga/rb-grn-expression.c +23 -1
- data/ext/groonga/rb-grn-object.c +44 -1
- data/ext/groonga/rb-grn-procedure.c +16 -1
- data/ext/groonga/rb-grn-query-logger.c +55 -6
- data/ext/groonga/rb-grn-table.c +170 -1
- data/ext/groonga/rb-grn-utils.c +21 -2
- data/ext/groonga/rb-grn.h +18 -3
- data/ext/groonga/rb-groonga.c +2 -1
- data/lib/groonga.rb +8 -5
- data/lib/groonga/column.rb +0 -5
- data/lib/groonga/database.rb +0 -10
- data/lib/groonga/index-column.rb +0 -10
- data/lib/groonga/query-logger.rb +1 -1
- data/rroonga-build.rb +6 -6
- data/rroonga.gemspec +1 -1
- data/test/groonga-test-utils.rb +5 -8
- data/test/test-array.rb +1 -131
- data/test/test-column-cache.rb +46 -0
- data/test/test-command-select.rb +36 -1
- data/test/test-context.rb +1 -2
- data/test/test-database.rb +16 -2
- data/test/test-logger.rb +13 -1
- data/test/test-procedure.rb +7 -1
- data/test/test-query-logger.rb +12 -1
- data/test/test-table-arrow.rb +193 -0
- data/test/test-table-offset-and-limit.rb +3 -1
- metadata +65 -64
- data/lib/groonga/statistic-measurer.rb +0 -37
- data/lib/groonga/table.rb +0 -25
- data/test/test-statistic-measurer.rb +0 -55
data/ext/groonga/rb-grn-column.c
CHANGED
@@ -54,7 +54,7 @@ grn_obj *
|
|
54
54
|
rb_grn_column_from_ruby_object (VALUE object, grn_ctx **context)
|
55
55
|
{
|
56
56
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnColumn))) {
|
57
|
-
rb_raise(rb_eTypeError, "not a
|
57
|
+
rb_raise(rb_eTypeError, "not a Groonga column");
|
58
58
|
}
|
59
59
|
|
60
60
|
return RVAL2GRNOBJECT(object, context);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2010-
|
3
|
+
Copyright (C) 2010-2018 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -700,10 +700,10 @@ rb_grn_context_support_lz4_p (VALUE self)
|
|
700
700
|
}
|
701
701
|
|
702
702
|
/*
|
703
|
-
* If Groonga supports Zstandard compression, it returns `true`,
|
704
|
-
* otherwise it returns `false`.
|
705
|
-
*
|
706
703
|
* @overload support_zstd?
|
704
|
+
*
|
705
|
+
* @return [Boolean] `true` if Groonga supports Zstandard compression,
|
706
|
+
* `false` otherwise.
|
707
707
|
*/
|
708
708
|
static VALUE
|
709
709
|
rb_grn_context_support_zstd_p (VALUE self)
|
@@ -721,6 +721,28 @@ rb_grn_context_support_zstd_p (VALUE self)
|
|
721
721
|
return rb_support_p;
|
722
722
|
}
|
723
723
|
|
724
|
+
/*
|
725
|
+
* @overload support_arrow?
|
726
|
+
*
|
727
|
+
* @return [Boolean] `true` if Groonga supports Apache Arrow,
|
728
|
+
* `false` otherwise.
|
729
|
+
*/
|
730
|
+
static VALUE
|
731
|
+
rb_grn_context_support_arrow_p (VALUE self)
|
732
|
+
{
|
733
|
+
VALUE rb_support_p;
|
734
|
+
grn_ctx *context;
|
735
|
+
grn_obj support_p;
|
736
|
+
|
737
|
+
context = SELF(self);
|
738
|
+
GRN_BOOL_INIT(&support_p, 0);
|
739
|
+
grn_obj_get_info(context, NULL, GRN_INFO_SUPPORT_ARROW, &support_p);
|
740
|
+
rb_support_p = CBOOL2RVAL(GRN_BOOL_VALUE(&support_p));
|
741
|
+
GRN_OBJ_FIN(context, &support_p);
|
742
|
+
|
743
|
+
return rb_support_p;
|
744
|
+
}
|
745
|
+
|
724
746
|
/*
|
725
747
|
* コンテキストが使うデータベースを返す。
|
726
748
|
*
|
@@ -1030,6 +1052,8 @@ rb_grn_init_context (VALUE mGrn)
|
|
1030
1052
|
rb_grn_context_support_lz4_p, 0);
|
1031
1053
|
rb_define_method(cGrnContext, "support_zstd?",
|
1032
1054
|
rb_grn_context_support_zstd_p, 0);
|
1055
|
+
rb_define_method(cGrnContext, "support_arrow?",
|
1056
|
+
rb_grn_context_support_arrow_p, 0);
|
1033
1057
|
|
1034
1058
|
rb_define_method(cGrnContext, "database", rb_grn_context_get_database, 0);
|
1035
1059
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2018 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -424,6 +424,18 @@ rb_grn_expression_append_operation (VALUE self, VALUE rb_operation,
|
|
424
424
|
* デフォルトでは更新操作を利用できる。
|
425
425
|
*
|
426
426
|
* 参考: "Groongaのクエリ構文のドキュメント":http://groonga.org/ja/docs/reference/grn_expr/query_syntax.html
|
427
|
+
* @option options :no_syntax_error
|
428
|
+
* Specifies whether preventing syntax error in query syntax.
|
429
|
+
*
|
430
|
+
* If it's `true`, special characters are treated as normal
|
431
|
+
* characters on syntax error.
|
432
|
+
*
|
433
|
+
* If it's `false`, syntax error is reported on syntax error.
|
434
|
+
* It's the default.
|
435
|
+
*
|
436
|
+
* You can't use this option in script syntax.
|
437
|
+
*
|
438
|
+
* @see [Query syntax document in Groonga](http://groonga.org/docs/reference/grn_expr/query_syntax.html)
|
427
439
|
*/
|
428
440
|
static VALUE
|
429
441
|
rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
|
@@ -440,6 +452,7 @@ rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
|
|
440
452
|
VALUE options, rb_query, rb_default_column, rb_default_operator;
|
441
453
|
VALUE rb_default_mode, rb_syntax;
|
442
454
|
VALUE rb_allow_pragma, rb_allow_column, rb_allow_update, rb_allow_leading_not;
|
455
|
+
VALUE rb_no_syntax_error;
|
443
456
|
VALUE exception = Qnil;
|
444
457
|
|
445
458
|
rb_scan_args(argc, argv, "11", &rb_query, &options);
|
@@ -452,6 +465,7 @@ rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
|
|
452
465
|
"allow_column", &rb_allow_column,
|
453
466
|
"allow_update", &rb_allow_update,
|
454
467
|
"allow_leading_not", &rb_allow_leading_not,
|
468
|
+
"no_syntax_error", &rb_no_syntax_error,
|
455
469
|
NULL);
|
456
470
|
|
457
471
|
query = StringValuePtr(rb_query);
|
@@ -521,6 +535,14 @@ rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
|
|
521
535
|
flags |= GRN_EXPR_ALLOW_LEADING_NOT;
|
522
536
|
}
|
523
537
|
|
538
|
+
if (!NIL_P(rb_no_syntax_error)) {
|
539
|
+
if ((flags & GRN_EXPR_SYNTAX_SCRIPT))
|
540
|
+
rb_raise(rb_eArgError,
|
541
|
+
":no_syntax_error isn't allowed in script syntax");
|
542
|
+
if (RVAL2CBOOL(rb_no_syntax_error))
|
543
|
+
flags |= GRN_EXPR_QUERY_NO_SYNTAX_ERROR;
|
544
|
+
}
|
545
|
+
|
524
546
|
rc = grn_expr_parse(context, expression, query, query_size,
|
525
547
|
default_column, default_mode, default_operator,
|
526
548
|
flags);
|
data/ext/groonga/rb-grn-object.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2018 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -1970,6 +1970,44 @@ rb_grn_object_dirty_p (VALUE self)
|
|
1970
1970
|
return CBOOL2RVAL(is_dirty);
|
1971
1971
|
}
|
1972
1972
|
|
1973
|
+
/*
|
1974
|
+
* @overload corrupt?
|
1975
|
+
* @return [Boolean] `true` if the object is corrupt, `false` otherwise.
|
1976
|
+
*
|
1977
|
+
* @since 7.1.1
|
1978
|
+
*/
|
1979
|
+
static VALUE
|
1980
|
+
rb_grn_object_corrupt_p (VALUE self)
|
1981
|
+
{
|
1982
|
+
grn_ctx *context;
|
1983
|
+
grn_obj *object;
|
1984
|
+
grn_bool is_corrupt;
|
1985
|
+
|
1986
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1987
|
+
NULL, NULL, NULL, NULL);
|
1988
|
+
is_corrupt = grn_obj_is_corrupt(context, object);
|
1989
|
+
return CBOOL2RVAL(is_corrupt);
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
/*
|
1993
|
+
* @overload disk_usage
|
1994
|
+
* @return [Integer] The number of bytes used by this object in disk.
|
1995
|
+
*
|
1996
|
+
* @since 7.1.1
|
1997
|
+
*/
|
1998
|
+
static VALUE
|
1999
|
+
rb_grn_object_get_disk_usage (VALUE self)
|
2000
|
+
{
|
2001
|
+
grn_ctx *context;
|
2002
|
+
grn_obj *object;
|
2003
|
+
size_t disk_usage;
|
2004
|
+
|
2005
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
2006
|
+
NULL, NULL, NULL, NULL);
|
2007
|
+
disk_usage = grn_obj_get_disk_usage(context, object);
|
2008
|
+
return UINT2NUM(disk_usage);
|
2009
|
+
}
|
2010
|
+
|
1973
2011
|
void
|
1974
2012
|
rb_grn_init_object (VALUE mGrn)
|
1975
2013
|
{
|
@@ -2032,4 +2070,9 @@ rb_grn_init_object (VALUE mGrn)
|
|
2032
2070
|
rb_grn_object_get_last_modified, 0);
|
2033
2071
|
rb_define_method(rb_cGrnObject, "dirty?",
|
2034
2072
|
rb_grn_object_dirty_p, 0);
|
2073
|
+
rb_define_method(rb_cGrnObject, "corrupt?",
|
2074
|
+
rb_grn_object_corrupt_p, 0);
|
2075
|
+
|
2076
|
+
rb_define_method(rb_cGrnObject, "disk_usage",
|
2077
|
+
rb_grn_object_get_disk_usage, 0);
|
2035
2078
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2018 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -50,6 +50,19 @@ rb_grn_procedure_get_type (VALUE self)
|
|
50
50
|
return INT2NUM(type);
|
51
51
|
}
|
52
52
|
|
53
|
+
static VALUE
|
54
|
+
rb_grn_procedure_stable_p (VALUE self)
|
55
|
+
{
|
56
|
+
grn_ctx *context;
|
57
|
+
grn_obj *procedure;
|
58
|
+
grn_bool is_stable;
|
59
|
+
|
60
|
+
procedure = RVAL2GRNOBJECT(self, &context);
|
61
|
+
is_stable = grn_proc_is_stable(context, procedure);
|
62
|
+
|
63
|
+
return CBOOL2RVAL(is_stable);
|
64
|
+
}
|
65
|
+
|
53
66
|
void
|
54
67
|
rb_grn_init_procedure (VALUE mGrn)
|
55
68
|
{
|
@@ -62,4 +75,6 @@ rb_grn_init_procedure (VALUE mGrn)
|
|
62
75
|
rb_define_const(rb_cGrnProcedure, "MECAB", INT2NUM(GRN_DB_MECAB));
|
63
76
|
|
64
77
|
rb_define_method(rb_cGrnProcedure, "type", rb_grn_procedure_get_type, 0);
|
78
|
+
|
79
|
+
rb_define_method(rb_cGrnProcedure, "stable?", rb_grn_procedure_stable_p, 0);
|
65
80
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2012-
|
3
|
+
Copyright (C) 2012-2018 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
|
5
5
|
This library is free software; you can redistribute it and/or
|
6
6
|
modify it under the terms of the GNU Lesser General Public
|
@@ -390,10 +390,11 @@ rb_grn_query_logger_s_get_rotate_threshold_size (VALUE klass)
|
|
390
390
|
* Groonga::QueryLogger.rotate_threshold_size = 0
|
391
391
|
*
|
392
392
|
* @overload rotate_threshold_size=(size)
|
393
|
-
* @param size [Integer] The
|
394
|
-
* If nil is specified, log rotate by the default
|
395
|
-
* disabled.
|
396
|
-
*
|
393
|
+
* @param size [Integer] The rotate threshold size for the default
|
394
|
+
* query logger. If `nil` is specified, log rotate by the default
|
395
|
+
* query logger is disabled.
|
396
|
+
*
|
397
|
+
* @return `size` itself.
|
397
398
|
*
|
398
399
|
* @since 5.0.2
|
399
400
|
*/
|
@@ -402,7 +403,49 @@ rb_grn_query_logger_s_set_rotate_threshold_size (VALUE klass, VALUE rb_size)
|
|
402
403
|
{
|
403
404
|
grn_default_query_logger_set_rotate_threshold_size(NUM2OFFT(rb_size));
|
404
405
|
|
405
|
-
return
|
406
|
+
return rb_size;
|
407
|
+
}
|
408
|
+
|
409
|
+
/*
|
410
|
+
* Gets the current flags that are used by the default query logger.
|
411
|
+
*
|
412
|
+
* @overload flags
|
413
|
+
* @return [Integer] The current flags
|
414
|
+
*
|
415
|
+
* @since 7.1.1
|
416
|
+
*/
|
417
|
+
static VALUE
|
418
|
+
rb_grn_query_logger_s_get_flags (VALUE klass)
|
419
|
+
{
|
420
|
+
return UINT2NUM(grn_default_query_logger_get_flags());
|
421
|
+
}
|
422
|
+
|
423
|
+
/*
|
424
|
+
* Sets the flags that are used by the default query logger. If you're
|
425
|
+
* using custom query logger by {.register}, the flags aren't
|
426
|
+
* used. Because it is for the default query logger.
|
427
|
+
*
|
428
|
+
* @example Changes the rotate threshold size for the default query logger
|
429
|
+
* Groonga::QueryLogger.rotate_threshold_size = 1 * 1024 * 1024 # 1MiB
|
430
|
+
*
|
431
|
+
* @example Disables log ration by the default query logger
|
432
|
+
* Groonga::QueryLogger.rotate_threshold_size = 0
|
433
|
+
*
|
434
|
+
* @overload flags=(flags)
|
435
|
+
* @param flags [Integer] The flags for the default query logger.
|
436
|
+
* @return void
|
437
|
+
*
|
438
|
+
* @since 7.1.1
|
439
|
+
*/
|
440
|
+
static VALUE
|
441
|
+
rb_grn_query_logger_s_set_flags (VALUE klass, VALUE rb_flags)
|
442
|
+
{
|
443
|
+
VALUE rb_parsed_flags;
|
444
|
+
|
445
|
+
rb_parsed_flags = rb_funcall(mGrnQueryLoggerFlags, id_parse, 1, rb_flags);
|
446
|
+
grn_default_query_logger_set_flags(NUM2UINT(rb_parsed_flags));
|
447
|
+
|
448
|
+
return rb_flags;
|
406
449
|
}
|
407
450
|
|
408
451
|
void
|
@@ -441,6 +484,12 @@ rb_grn_init_query_logger (VALUE mGrn)
|
|
441
484
|
rb_define_singleton_method(cGrnQueryLogger, "rotate_threshold_size=",
|
442
485
|
rb_grn_query_logger_s_set_rotate_threshold_size,
|
443
486
|
1);
|
487
|
+
rb_define_singleton_method(cGrnQueryLogger, "flags",
|
488
|
+
rb_grn_query_logger_s_get_flags,
|
489
|
+
0);
|
490
|
+
rb_define_singleton_method(cGrnQueryLogger, "flags=",
|
491
|
+
rb_grn_query_logger_s_set_flags,
|
492
|
+
1);
|
444
493
|
|
445
494
|
mGrnQueryLoggerFlags = rb_define_module_under(cGrnQueryLogger, "Flags");
|
446
495
|
#define DEFINE_FLAG(NAME) \
|
data/ext/groonga/rb-grn-table.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2009-
|
3
|
+
Copyright (C) 2009-2017 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
5
|
|
6
6
|
This library is free software; you can redistribute it and/or
|
@@ -2646,6 +2646,172 @@ rb_grn_table_rename (VALUE self, VALUE rb_name)
|
|
2646
2646
|
return self;
|
2647
2647
|
}
|
2648
2648
|
|
2649
|
+
/*
|
2650
|
+
* @overload load_arrow(path)
|
2651
|
+
*
|
2652
|
+
* Loads records from Apache Arrow file format file.
|
2653
|
+
*
|
2654
|
+
* @param path [String, #to_path] the path of file in Apache Arrow
|
2655
|
+
* file format.
|
2656
|
+
*
|
2657
|
+
* @return [void]
|
2658
|
+
*
|
2659
|
+
* @since 7.0.3
|
2660
|
+
*/
|
2661
|
+
static VALUE
|
2662
|
+
rb_grn_table_load_arrow (VALUE self, VALUE rb_path)
|
2663
|
+
{
|
2664
|
+
int rc;
|
2665
|
+
grn_ctx *context;
|
2666
|
+
grn_obj *table;
|
2667
|
+
|
2668
|
+
rb_grn_table_deconstruct(SELF(self), &table, &context,
|
2669
|
+
NULL, NULL, NULL,
|
2670
|
+
NULL, NULL,
|
2671
|
+
NULL);
|
2672
|
+
|
2673
|
+
{
|
2674
|
+
VALUE rb_path_string;
|
2675
|
+
rb_path_string = rb_grn_check_convert_to_string(rb_path);
|
2676
|
+
if (NIL_P(rb_path_string)) {
|
2677
|
+
ID to_path;
|
2678
|
+
CONST_ID(to_path, "to_path");
|
2679
|
+
rb_path_string = rb_check_funcall(rb_path, to_path, 0, 0);
|
2680
|
+
if (rb_path_string == Qundef) {
|
2681
|
+
rb_path_string = rb_path;
|
2682
|
+
}
|
2683
|
+
rb_path = rb_grn_convert_to_string(rb_path_string);
|
2684
|
+
}
|
2685
|
+
}
|
2686
|
+
|
2687
|
+
rc = grn_arrow_load(context, table, StringValueCStr(rb_path));
|
2688
|
+
rb_grn_context_check(context, self);
|
2689
|
+
rb_grn_rc_check(rc, self);
|
2690
|
+
|
2691
|
+
return self;
|
2692
|
+
}
|
2693
|
+
|
2694
|
+
/*
|
2695
|
+
* @overload dump_arrow(path, options)
|
2696
|
+
*
|
2697
|
+
* Dump records to file in Apache Arrow file format.
|
2698
|
+
*
|
2699
|
+
* @param path [String, #to_path] the output file path.
|
2700
|
+
*
|
2701
|
+
* @param options [::Hash] the options.
|
2702
|
+
*
|
2703
|
+
* @option options :columns [::Array<Groonga::Column>] (nil) the
|
2704
|
+
* columns to be dumped.
|
2705
|
+
*
|
2706
|
+
* If you don't specify neither `:columns` and `:column_names`,
|
2707
|
+
* all columns are dumped. It's the default.
|
2708
|
+
*
|
2709
|
+
* @option options :column_names [::Array<Groonga::Column>] (nil)
|
2710
|
+
* the column names to be dumped. If `:columns` is specified,
|
2711
|
+
* `:column_names` is ignored.
|
2712
|
+
*
|
2713
|
+
* If you don't specify neither `:columns` and `:column_names`,
|
2714
|
+
* all columns are dumped. It's the default.
|
2715
|
+
*
|
2716
|
+
* @return [void]
|
2717
|
+
*
|
2718
|
+
* @since 7.0.3
|
2719
|
+
*/
|
2720
|
+
static VALUE
|
2721
|
+
rb_grn_table_dump_arrow (int argc, VALUE *argv, VALUE self)
|
2722
|
+
{
|
2723
|
+
int rc;
|
2724
|
+
grn_ctx *context;
|
2725
|
+
grn_obj *table;
|
2726
|
+
const char *path;
|
2727
|
+
VALUE rb_path;
|
2728
|
+
VALUE rb_options;
|
2729
|
+
VALUE rb_columns = Qnil;
|
2730
|
+
VALUE rb_column_names = Qnil;
|
2731
|
+
|
2732
|
+
rb_scan_args(argc, argv, "11", &rb_path, &rb_options);
|
2733
|
+
rb_grn_scan_options(rb_options,
|
2734
|
+
"columns", &rb_columns,
|
2735
|
+
"column_names", &rb_column_names,
|
2736
|
+
NULL);
|
2737
|
+
|
2738
|
+
rb_grn_table_deconstruct(SELF(self), &table, &context,
|
2739
|
+
NULL, NULL, NULL,
|
2740
|
+
NULL, NULL,
|
2741
|
+
NULL);
|
2742
|
+
|
2743
|
+
{
|
2744
|
+
VALUE rb_path_string;
|
2745
|
+
rb_path_string = rb_grn_check_convert_to_string(rb_path);
|
2746
|
+
if (NIL_P(rb_path_string)) {
|
2747
|
+
ID to_path;
|
2748
|
+
CONST_ID(to_path, "to_path");
|
2749
|
+
rb_path_string = rb_check_funcall(rb_path, to_path, 0, 0);
|
2750
|
+
if (rb_path_string == Qundef) {
|
2751
|
+
rb_path_string = rb_path;
|
2752
|
+
}
|
2753
|
+
rb_path = rb_grn_convert_to_string(rb_path_string);
|
2754
|
+
}
|
2755
|
+
}
|
2756
|
+
path = StringValueCStr(rb_path);
|
2757
|
+
|
2758
|
+
if (NIL_P(rb_columns) && NIL_P(rb_column_names)) {
|
2759
|
+
rc = grn_arrow_dump(context, table, path);
|
2760
|
+
} else if (!NIL_P(rb_columns)) {
|
2761
|
+
grn_obj columns;
|
2762
|
+
int i, n;
|
2763
|
+
|
2764
|
+
rb_columns = rb_grn_convert_to_array(rb_columns);
|
2765
|
+
|
2766
|
+
GRN_PTR_INIT(&columns, GRN_OBJ_VECTOR, GRN_ID_NIL);
|
2767
|
+
n = RARRAY_LEN(rb_columns);
|
2768
|
+
for (i = 0; i < n; i++) {
|
2769
|
+
VALUE rb_column = RARRAY_PTR(rb_columns)[i];
|
2770
|
+
grn_obj *column;
|
2771
|
+
|
2772
|
+
column = RVAL2GRNOBJECT(rb_column, &context);
|
2773
|
+
GRN_PTR_PUT(context, &columns, column);
|
2774
|
+
}
|
2775
|
+
rc = grn_arrow_dump_columns(context, table, &columns, path);
|
2776
|
+
GRN_OBJ_FIN(context, &columns);
|
2777
|
+
} else if (!NIL_P(rb_column_names)) {
|
2778
|
+
grn_obj columns;
|
2779
|
+
int i, n;
|
2780
|
+
|
2781
|
+
rb_column_names = rb_grn_convert_to_array(rb_column_names);
|
2782
|
+
|
2783
|
+
GRN_PTR_INIT(&columns, GRN_OBJ_VECTOR, GRN_ID_NIL);
|
2784
|
+
n = RARRAY_LEN(rb_column_names);
|
2785
|
+
for (i = 0; i < n; i++) {
|
2786
|
+
VALUE rb_column_name = RARRAY_PTR(rb_column_names)[i];
|
2787
|
+
grn_obj *column;
|
2788
|
+
|
2789
|
+
column = grn_obj_column(context, table,
|
2790
|
+
RSTRING_PTR(rb_column_name),
|
2791
|
+
RSTRING_LEN(rb_column_name));
|
2792
|
+
if (!column) {
|
2793
|
+
continue;
|
2794
|
+
}
|
2795
|
+
GRN_PTR_PUT(context, &columns, column);
|
2796
|
+
}
|
2797
|
+
rc = grn_arrow_dump_columns(context, table, &columns, path);
|
2798
|
+
n = GRN_BULK_VSIZE(&columns) / sizeof(grn_obj *);
|
2799
|
+
for (i = 0; i < n; i++) {
|
2800
|
+
grn_obj *column;
|
2801
|
+
|
2802
|
+
column = GRN_PTR_VALUE_AT(&columns, i);
|
2803
|
+
if (column->header.type == GRN_ACCESSOR) {
|
2804
|
+
grn_obj_unlink(context, column);
|
2805
|
+
}
|
2806
|
+
}
|
2807
|
+
GRN_OBJ_FIN(context, &columns);
|
2808
|
+
}
|
2809
|
+
rb_grn_context_check(context, self);
|
2810
|
+
rb_grn_rc_check(rc, self);
|
2811
|
+
|
2812
|
+
return self;
|
2813
|
+
}
|
2814
|
+
|
2649
2815
|
void
|
2650
2816
|
rb_grn_init_table (VALUE mGrn)
|
2651
2817
|
{
|
@@ -2733,6 +2899,9 @@ rb_grn_init_table (VALUE mGrn)
|
|
2733
2899
|
|
2734
2900
|
rb_define_method(rb_cGrnTable, "rename", rb_grn_table_rename, 1);
|
2735
2901
|
|
2902
|
+
rb_define_method(rb_cGrnTable, "load_arrow", rb_grn_table_load_arrow, 1);
|
2903
|
+
rb_define_method(rb_cGrnTable, "dump_arrow", rb_grn_table_dump_arrow, -1);
|
2904
|
+
|
2736
2905
|
rb_grn_init_table_key_support(mGrn);
|
2737
2906
|
rb_grn_init_array(mGrn);
|
2738
2907
|
rb_grn_init_hash(mGrn);
|