rroonga 9.0.3 → 11.0.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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/Rakefile +26 -135
- data/doc/text/news.md +79 -1
- data/doc/text/tutorial.md +1 -1
- data/ext/groonga/extconf.rb +19 -74
- data/ext/groonga/rb-grn-accessor.c +2 -2
- data/ext/groonga/rb-grn-column-cache.c +3 -3
- data/ext/groonga/rb-grn-column.c +4 -4
- data/ext/groonga/rb-grn-context.c +109 -58
- data/ext/groonga/rb-grn-data-column.c +4 -4
- data/ext/groonga/rb-grn-database.c +45 -26
- data/ext/groonga/rb-grn-double-array-trie.c +2 -2
- data/ext/groonga/rb-grn-encoding-support.c +2 -2
- data/ext/groonga/rb-grn-exception.c +14 -0
- data/ext/groonga/rb-grn-expression-builder.c +3 -3
- data/ext/groonga/rb-grn-expression.c +3 -3
- data/ext/groonga/rb-grn-fix-size-column.c +2 -2
- data/ext/groonga/rb-grn-flushable.c +9 -1
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +30 -2
- data/ext/groonga/rb-grn-index-cursor.c +21 -2
- data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
- data/ext/groonga/rb-grn-logger.c +17 -3
- data/ext/groonga/rb-grn-object.c +266 -31
- data/ext/groonga/rb-grn-operator.c +100 -259
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-plugin.c +34 -22
- data/ext/groonga/rb-grn-request-timer-id.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +3 -3
- data/ext/groonga/rb-grn-table-cursor-key-support.c +2 -2
- data/ext/groonga/rb-grn-table-cursor.c +3 -3
- data/ext/groonga/rb-grn-table-key-support.c +28 -9
- data/ext/groonga/rb-grn-table.c +180 -130
- data/ext/groonga/rb-grn-type.c +5 -1
- data/ext/groonga/rb-grn-utils.c +17 -1
- data/ext/groonga/rb-grn-variable-size-column.c +2 -2
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +11 -14
- data/ext/groonga/rb-groonga.c +6 -2
- data/lib/groonga.rb +3 -7
- data/lib/groonga/context.rb +32 -0
- data/lib/groonga/dumper.rb +3 -0
- data/lib/groonga/record.rb +2 -2
- data/rroonga-build.rb +5 -4
- data/rroonga.gemspec +8 -6
- data/test/groonga-test-utils.rb +37 -5
- data/test/run-test.rb +1 -3
- data/test/test-accessor.rb +63 -7
- data/test/test-column.rb +12 -1
- data/test/test-context.rb +25 -0
- data/test/test-exception.rb +5 -0
- data/test/test-flushable.rb +51 -6
- data/test/test-index-column.rb +70 -9
- data/test/test-index-cursor.rb +26 -0
- data/test/test-logger.rb +56 -11
- data/test/test-plugin.rb +1 -0
- data/test/test-query-logger.rb +4 -3
- data/test/test-ractor.rb +65 -0
- data/test/test-record.rb +2 -1
- data/test/test-remote.rb +58 -10
- data/test/test-schema-dumper.rb +13 -0
- data/test/test-schema.rb +9 -1
- data/test/test-table-arrow.rb +22 -10
- data/test/test-table.rb +21 -1
- data/test/test-variable.rb +23 -7
- metadata +72 -97
@@ -1,8 +1,8 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/* vim: set sts=4 sw=4 ts=8 noet: */
|
3
3
|
/*
|
4
|
+
Copyright (C) 2011-2021 Sutou Kouhei <kou@clear-code.com>
|
4
5
|
Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
|
5
|
-
Copyright (C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
|
6
6
|
|
7
7
|
This library is free software; you can redistribute it and/or
|
8
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
#include "rb-grn.h"
|
22
22
|
|
23
|
-
#define SELF(object) ((RbGrnDoubleArrayTrie *)
|
23
|
+
#define SELF(object) ((RbGrnDoubleArrayTrie *)RTYPEDDATA_DATA(object))
|
24
24
|
|
25
25
|
VALUE rb_cGrnDoubleArrayTrie;
|
26
26
|
|
@@ -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-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) (RB_GRN_OBJECT(
|
21
|
+
#define SELF(object) (RB_GRN_OBJECT(RTYPEDDATA_DATA(object)))
|
22
22
|
|
23
23
|
VALUE rb_mGrnEncodingSupport;
|
24
24
|
|
@@ -103,6 +103,7 @@ static VALUE eGrnScorerError;
|
|
103
103
|
static VALUE eGrnCancel;
|
104
104
|
static VALUE eGrnWindowFunctionError;
|
105
105
|
static VALUE eGrnZstdError;
|
106
|
+
static VALUE eGrnConnectionReset;
|
106
107
|
|
107
108
|
VALUE
|
108
109
|
rb_grn_rc_to_exception (grn_rc rc)
|
@@ -353,6 +354,9 @@ rb_grn_rc_to_exception (grn_rc rc)
|
|
353
354
|
case GRN_ZSTD_ERROR:
|
354
355
|
exception = eGrnZstdError;
|
355
356
|
break;
|
357
|
+
case GRN_CONNECTION_RESET:
|
358
|
+
exception = eGrnConnectionReset;
|
359
|
+
break;
|
356
360
|
}
|
357
361
|
|
358
362
|
if (NIL_P(exception))
|
@@ -1072,4 +1076,14 @@ rb_grn_init_exception (VALUE mGrn)
|
|
1072
1076
|
*/
|
1073
1077
|
eGrnZstdError =
|
1074
1078
|
rb_define_class_under(mGrn, "ZstdError", rb_eGrnError);
|
1079
|
+
|
1080
|
+
/*
|
1081
|
+
* Document-class: Groonga::ConnectionReset
|
1082
|
+
*
|
1083
|
+
* It is used when connection is reset.
|
1084
|
+
*
|
1085
|
+
* @since 10.1.1
|
1086
|
+
*/
|
1087
|
+
eGrnConnectionReset =
|
1088
|
+
rb_define_class_under(mGrn, "ConnectionReset", rb_eGrnError);
|
1075
1089
|
}
|
@@ -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 Kouhei
|
3
|
+
Copyright (C) 2009-2020 Sutou Kouhei <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
|
@@ -42,9 +42,9 @@ build (VALUE self)
|
|
42
42
|
}
|
43
43
|
|
44
44
|
static VALUE
|
45
|
-
build_block (
|
45
|
+
build_block (RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
|
46
46
|
{
|
47
|
-
return rb_funcall(rb_block_proc(), rb_intern("call"), 1,
|
47
|
+
return rb_funcall(rb_block_proc(), rb_intern("call"), 1, yielded_arg);
|
48
48
|
}
|
49
49
|
|
50
50
|
VALUE
|
@@ -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-2021 Sutou Kouhei <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
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include "rb-grn.h"
|
21
21
|
|
22
|
-
#define SELF(object) ((RbGrnExpression *)
|
22
|
+
#define SELF(object) ((RbGrnExpression *)RTYPEDDATA_DATA(object))
|
23
23
|
|
24
24
|
VALUE rb_cGrnExpression;
|
25
25
|
|
@@ -100,7 +100,7 @@ rb_grn_expression_initialize (int argc, VALUE *argv, VALUE self)
|
|
100
100
|
expression = grn_expr_create(context, name, name_size);
|
101
101
|
rb_grn_context_check(context, self);
|
102
102
|
rb_grn_object_assign(Qnil, self, rb_context, context, expression);
|
103
|
-
rb_grn_context_register_floating_object(
|
103
|
+
rb_grn_context_register_floating_object(RTYPEDDATA_DATA(self));
|
104
104
|
|
105
105
|
rb_iv_set(self, "@objects", rb_ary_new());
|
106
106
|
|
@@ -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-2021 Sutou Kouhei <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
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
#include "rb-grn.h"
|
21
21
|
|
22
|
-
#define SELF(object) ((RbGrnColumn *)
|
22
|
+
#define SELF(object) ((RbGrnColumn *)RTYPEDDATA_DATA(object))
|
23
23
|
|
24
24
|
VALUE rb_cGrnFixSizeColumn;
|
25
25
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
3
|
Copyright (C) 2015 Masafumi Yokoyama <yokoyama@clear-code.com>
|
4
|
+
Copyright (C) 2021 Sutou Kouhei <kou@clear-code.com>
|
4
5
|
|
5
6
|
This library is free software; you can redistribute it and/or
|
6
7
|
modify it under the terms of the GNU Lesser General Public
|
@@ -18,7 +19,7 @@
|
|
18
19
|
|
19
20
|
#include "rb-grn.h"
|
20
21
|
|
21
|
-
#define SELF(object) (RB_GRN_OBJECT(
|
22
|
+
#define SELF(object) (RB_GRN_OBJECT(RTYPEDDATA_DATA(object)))
|
22
23
|
|
23
24
|
VALUE rb_mGrnFlushable;
|
24
25
|
|
@@ -43,15 +44,20 @@ rb_grn_flushable_flush (int argc, VALUE *argv, VALUE self)
|
|
43
44
|
grn_ctx *context = NULL;
|
44
45
|
grn_obj *object = NULL;
|
45
46
|
VALUE rb_recursive_p;
|
47
|
+
VALUE rb_dependent_p;
|
46
48
|
VALUE rb_options;
|
47
49
|
|
48
50
|
rb_scan_args(argc, argv, "01", &rb_options);
|
49
51
|
rb_grn_scan_options(rb_options,
|
50
52
|
"recursive", &rb_recursive_p,
|
53
|
+
"dependent", &rb_dependent_p,
|
51
54
|
NULL);
|
52
55
|
if (NIL_P(rb_recursive_p)) {
|
53
56
|
rb_recursive_p = Qtrue;
|
54
57
|
}
|
58
|
+
if (NIL_P(rb_dependent_p)) {
|
59
|
+
rb_dependent_p = Qfalse;
|
60
|
+
}
|
55
61
|
|
56
62
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
57
63
|
NULL, NULL, NULL, NULL);
|
@@ -63,6 +69,8 @@ rb_grn_flushable_flush (int argc, VALUE *argv, VALUE self)
|
|
63
69
|
|
64
70
|
if (RVAL2CBOOL(rb_recursive_p)) {
|
65
71
|
grn_obj_flush_recursive(context, object);
|
72
|
+
} else if (RVAL2CBOOL(rb_dependent_p)) {
|
73
|
+
grn_obj_flush_recursive_dependent(context, object);
|
66
74
|
} else {
|
67
75
|
grn_obj_flush(context, object);
|
68
76
|
}
|
data/ext/groonga/rb-grn-hash.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-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) ((RbGrnTableKeySupport *)
|
21
|
+
#define SELF(object) ((RbGrnTableKeySupport *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
VALUE rb_cGrnHash;
|
24
24
|
|
@@ -1,7 +1,8 @@
|
|
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-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
|
+
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -21,7 +22,7 @@
|
|
21
22
|
|
22
23
|
#include <string.h>
|
23
24
|
|
24
|
-
#define SELF(object) ((RbGrnIndexColumn *)
|
25
|
+
#define SELF(object) ((RbGrnIndexColumn *)RTYPEDDATA_DATA(object))
|
25
26
|
|
26
27
|
VALUE rb_cGrnIndexColumn;
|
27
28
|
|
@@ -972,6 +973,31 @@ rb_grn_index_column_medium_p (VALUE self)
|
|
972
973
|
return CBOOL2RVAL(flags & GRN_OBJ_INDEX_MEDIUM);
|
973
974
|
}
|
974
975
|
|
976
|
+
/*
|
977
|
+
* Checks whether the index column is large or not.
|
978
|
+
*
|
979
|
+
* @overload large?
|
980
|
+
* @return [Boolean] `true` if the index column size is large,
|
981
|
+
* `false` otherwise.
|
982
|
+
*
|
983
|
+
* @since 9.0.4
|
984
|
+
*/
|
985
|
+
static VALUE
|
986
|
+
rb_grn_index_column_large_p (VALUE self)
|
987
|
+
{
|
988
|
+
grn_obj *column;
|
989
|
+
grn_ctx *context;
|
990
|
+
grn_column_flags flags;
|
991
|
+
|
992
|
+
rb_grn_index_column_deconstruct(SELF(self), &column, &context,
|
993
|
+
NULL, NULL,
|
994
|
+
NULL, NULL, NULL, NULL, NULL,
|
995
|
+
NULL, NULL);
|
996
|
+
|
997
|
+
flags = grn_column_get_flags(context, column);
|
998
|
+
return CBOOL2RVAL(flags & GRN_OBJ_INDEX_LARGE);
|
999
|
+
}
|
1000
|
+
|
975
1001
|
static VALUE
|
976
1002
|
call_close (VALUE object)
|
977
1003
|
{
|
@@ -1442,6 +1468,8 @@ rb_grn_init_index_column (VALUE mGrn)
|
|
1442
1468
|
rb_grn_index_column_small_p, 0);
|
1443
1469
|
rb_define_method(rb_cGrnIndexColumn, "medium?",
|
1444
1470
|
rb_grn_index_column_medium_p, 0);
|
1471
|
+
rb_define_method(rb_cGrnIndexColumn, "large?",
|
1472
|
+
rb_grn_index_column_large_p, 0);
|
1445
1473
|
|
1446
1474
|
rb_define_method(rb_cGrnIndexColumn, "open_cursor",
|
1447
1475
|
rb_grn_index_column_open_cursor, -1);
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
3
|
Copyright (C) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
|
4
|
-
Copyright (C) 2012 Kouhei
|
4
|
+
Copyright (C) 2012-2021 Sutou Kouhei <kou@clear-code.com>
|
5
|
+
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -19,7 +20,7 @@
|
|
19
20
|
|
20
21
|
#include "rb-grn.h"
|
21
22
|
|
22
|
-
#define SELF(object) ((RbGrnIndexCursor *)
|
23
|
+
#define SELF(object) ((RbGrnIndexCursor *)RTYPEDDATA_DATA(object))
|
23
24
|
|
24
25
|
VALUE rb_cGrnIndexCursor;
|
25
26
|
|
@@ -56,6 +57,19 @@ rb_grn_index_cursor_deconstruct (RbGrnIndexCursor *rb_grn_index_cursor,
|
|
56
57
|
range_id, range);
|
57
58
|
}
|
58
59
|
|
60
|
+
static VALUE
|
61
|
+
rb_grn_index_cursor_s_set_min_p (VALUE klass)
|
62
|
+
{
|
63
|
+
return CBOOL2RVAL(grn_ii_cursor_set_min_enable_get());
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
rb_grn_index_cursor_s_set_min_set (VALUE klass, VALUE enable)
|
68
|
+
{
|
69
|
+
grn_ii_cursor_set_min_enable_set(RVAL2CBOOL(enable));
|
70
|
+
return enable;
|
71
|
+
}
|
72
|
+
|
59
73
|
static VALUE
|
60
74
|
next_value (VALUE rb_posting,
|
61
75
|
grn_ctx *context, grn_obj *cursor, VALUE rb_table, VALUE rb_lexicon)
|
@@ -158,6 +172,11 @@ rb_grn_init_index_cursor (VALUE mGrn)
|
|
158
172
|
rb_define_alloc_func(rb_cGrnIndexCursor, rb_grn_object_alloc);
|
159
173
|
rb_include_module(rb_cGrnIndexCursor, rb_mEnumerable);
|
160
174
|
|
175
|
+
rb_define_singleton_method(rb_cGrnIndexCursor, "set_min?",
|
176
|
+
rb_grn_index_cursor_s_set_min_p, 0);
|
177
|
+
rb_define_singleton_method(rb_cGrnIndexCursor, "set_min=",
|
178
|
+
rb_grn_index_cursor_s_set_min_set, 1);
|
179
|
+
|
161
180
|
rb_define_method(rb_cGrnIndexCursor, "next", rb_grn_index_cursor_next, 0);
|
162
181
|
rb_define_method(rb_cGrnIndexCursor, "each", rb_grn_index_cursor_each, -1);
|
163
182
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2
2
|
/*
|
3
|
-
Copyright (C) 2017 Kouhei
|
3
|
+
Copyright (C) 2017-2021 Sutou Kouhei <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
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "rb-grn.h"
|
20
20
|
|
21
|
-
#define SELF(object) ((RbGrnInvertedIndexCursor *)
|
21
|
+
#define SELF(object) ((RbGrnInvertedIndexCursor *)RTYPEDDATA_DATA(object))
|
22
22
|
|
23
23
|
typedef struct _RbGrnInvertedIndexCursor RbGrnInvertedIndexCursor;
|
24
24
|
struct _RbGrnInvertedIndexCursor
|
@@ -255,7 +255,7 @@ void
|
|
255
255
|
rb_grn_init_inverted_index_cursor (VALUE mGrn)
|
256
256
|
{
|
257
257
|
rb_cGrnInvertedIndexCursor =
|
258
|
-
rb_define_class_under(mGrn, "InvertedIndexCursor",
|
258
|
+
rb_define_class_under(mGrn, "InvertedIndexCursor", rb_cObject);
|
259
259
|
rb_include_module(rb_cGrnInvertedIndexCursor, rb_mEnumerable);
|
260
260
|
|
261
261
|
rb_define_method(rb_cGrnInvertedIndexCursor, "next",
|
data/ext/groonga/rb-grn-logger.c
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
Copyright (C) 2016-2017 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
|
+
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -315,15 +316,23 @@ rb_grn_logger_fin (grn_ctx *ctx, void *user_data)
|
|
315
316
|
* ログの発生元のプロセスIDとgroongaのソースコードのファイ
|
316
317
|
* ル名、行番号、関数名をブロックに渡したいなら +true+ を指
|
317
318
|
* 定する。デフォルトでは渡す。
|
319
|
+
* @option options [Bool] :thread_id (true)
|
320
|
+
* Specifies whether `location` includes thread ID or not.
|
318
321
|
*/
|
319
322
|
static VALUE
|
320
323
|
rb_grn_logger_s_register (int argc, VALUE *argv, VALUE klass)
|
321
324
|
{
|
322
325
|
VALUE rb_context = Qnil;
|
323
326
|
grn_ctx *context;
|
324
|
-
VALUE rb_logger
|
325
|
-
VALUE
|
326
|
-
VALUE
|
327
|
+
VALUE rb_logger;
|
328
|
+
VALUE rb_callback;
|
329
|
+
VALUE rb_options;
|
330
|
+
VALUE rb_max_level;
|
331
|
+
VALUE rb_time;
|
332
|
+
VALUE rb_title;
|
333
|
+
VALUE rb_message;
|
334
|
+
VALUE rb_location;
|
335
|
+
VALUE rb_thread_id;
|
327
336
|
VALUE rb_flags;
|
328
337
|
grn_log_level max_level = GRN_LOG_DEFAULT_LEVEL;
|
329
338
|
int flags = 0;
|
@@ -343,6 +352,7 @@ rb_grn_logger_s_register (int argc, VALUE *argv, VALUE klass)
|
|
343
352
|
"title", &rb_title,
|
344
353
|
"message", &rb_message,
|
345
354
|
"location", &rb_location,
|
355
|
+
"thread_id", &rb_thread_id,
|
346
356
|
"flags", &rb_flags,
|
347
357
|
NULL);
|
348
358
|
if (!NIL_P(rb_max_level)) {
|
@@ -361,6 +371,9 @@ rb_grn_logger_s_register (int argc, VALUE *argv, VALUE klass)
|
|
361
371
|
if (NIL_P(rb_location) || CBOOL2RVAL(rb_location)) {
|
362
372
|
flags |= GRN_LOG_LOCATION;
|
363
373
|
}
|
374
|
+
if (NIL_P(rb_thread_id) || CBOOL2RVAL(rb_thread_id)) {
|
375
|
+
flags |= GRN_LOG_THREAD_ID;
|
376
|
+
}
|
364
377
|
if (!NIL_P(rb_flags)) {
|
365
378
|
flags = rb_funcall(rb_mGrnLoggerFlags, id_parse, 2,
|
366
379
|
INT2NUM(flags), rb_flags);
|
@@ -693,6 +706,7 @@ rb_grn_init_logger (VALUE mGrn)
|
|
693
706
|
DEFINE_FLAG(MESSAGE);
|
694
707
|
DEFINE_FLAG(LOCATION);
|
695
708
|
DEFINE_FLAG(PID);
|
709
|
+
DEFINE_FLAG(THREAD_ID);
|
696
710
|
#undef DEFINE_FLAG
|
697
711
|
|
698
712
|
rb_cGrnCallbackLogger =
|
data/ext/groonga/rb-grn-object.c
CHANGED
@@ -1,7 +1,8 @@
|
|
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-2021 Sutou Kouhei <kou@clear-code.com>
|
4
4
|
Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
|
+
Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
5
6
|
|
6
7
|
This library is free software; you can redistribute it and/or
|
7
8
|
modify it under the terms of the GNU Lesser General Public
|
@@ -27,10 +28,28 @@
|
|
27
28
|
|
28
29
|
#include "rb-grn.h"
|
29
30
|
|
30
|
-
#define SELF(object) ((RbGrnObject *)
|
31
|
+
#define SELF(object) ((RbGrnObject *)RTYPEDDATA_DATA(object))
|
31
32
|
|
32
33
|
VALUE rb_cGrnObject;
|
33
34
|
|
35
|
+
static void
|
36
|
+
rb_grn_object_dfree (void *pointer)
|
37
|
+
{
|
38
|
+
rb_grn_object_free(pointer);
|
39
|
+
}
|
40
|
+
|
41
|
+
rb_data_type_t rb_grn_object_data_type = {
|
42
|
+
"Groonga::Object",
|
43
|
+
{
|
44
|
+
NULL,
|
45
|
+
rb_grn_object_dfree,
|
46
|
+
NULL,
|
47
|
+
},
|
48
|
+
NULL,
|
49
|
+
NULL,
|
50
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
51
|
+
};
|
52
|
+
|
34
53
|
grn_obj *
|
35
54
|
rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context)
|
36
55
|
{
|
@@ -72,7 +91,10 @@ rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context)
|
|
72
91
|
rb_grn_inspect(object));
|
73
92
|
}
|
74
93
|
|
75
|
-
|
94
|
+
TypedData_Get_Struct(object,
|
95
|
+
RbGrnObject,
|
96
|
+
&rb_grn_object_data_type,
|
97
|
+
rb_grn_object);
|
76
98
|
if (!rb_grn_object)
|
77
99
|
rb_raise(rb_eGrnError, "Groonga object is NULL");
|
78
100
|
|
@@ -349,7 +371,9 @@ rb_grn_object_to_ruby_object (VALUE klass, grn_ctx *context, grn_obj *object,
|
|
349
371
|
VALUE
|
350
372
|
rb_grn_object_alloc (VALUE klass)
|
351
373
|
{
|
352
|
-
return
|
374
|
+
return TypedData_Wrap_Struct(klass,
|
375
|
+
&rb_grn_object_data_type,
|
376
|
+
NULL);
|
353
377
|
}
|
354
378
|
|
355
379
|
static void
|
@@ -358,15 +382,13 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
|
|
358
382
|
grn_ctx *context, grn_obj *object)
|
359
383
|
{
|
360
384
|
grn_user_data *user_data;
|
361
|
-
RbGrnContext *rb_grn_context;
|
362
385
|
|
363
386
|
debug("bind: %p:%p:%p %s(%#x)\n",
|
364
387
|
context, object, rb_grn_object,
|
365
388
|
grn_obj_type_to_string(object->header.type),
|
366
389
|
object->header.type);
|
367
390
|
|
368
|
-
|
369
|
-
rb_grn_object->rb_grn_context = rb_grn_context;
|
391
|
+
rb_grn_object->rb_grn_context = rb_grn_context_get_struct(rb_context);
|
370
392
|
rb_grn_object->context = context;
|
371
393
|
rb_grn_object->object = object;
|
372
394
|
rb_grn_object->self = self;
|
@@ -418,7 +440,7 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
|
|
418
440
|
else
|
419
441
|
rb_grn_object->range = grn_ctx_at(context, rb_grn_object->range_id);
|
420
442
|
|
421
|
-
|
443
|
+
RTYPEDDATA_DATA(self) = rb_grn_object;
|
422
444
|
}
|
423
445
|
|
424
446
|
void
|
@@ -939,6 +961,8 @@ rb_grn_object_inspect_content_flags_with_label (VALUE inspected,
|
|
939
961
|
rb_ary_push(inspected_flags, rb_str_new_cstr("SMALL"));
|
940
962
|
if (column_flags & GRN_OBJ_INDEX_MEDIUM)
|
941
963
|
rb_ary_push(inspected_flags, rb_str_new_cstr("MEDIUM"));
|
964
|
+
if (column_flags & GRN_OBJ_INDEX_LARGE)
|
965
|
+
rb_ary_push(inspected_flags, rb_str_new_cstr("LARGE"));
|
942
966
|
break;
|
943
967
|
default:
|
944
968
|
break;
|
@@ -1355,7 +1379,7 @@ rb_grn_object_array_reference (VALUE self, VALUE rb_id)
|
|
1355
1379
|
return rb_value;
|
1356
1380
|
}
|
1357
1381
|
|
1358
|
-
static
|
1382
|
+
static bool
|
1359
1383
|
rb_uvector_value_p (RbGrnObject *rb_grn_object, VALUE rb_value)
|
1360
1384
|
{
|
1361
1385
|
VALUE first_element;
|
@@ -1363,7 +1387,7 @@ rb_uvector_value_p (RbGrnObject *rb_grn_object, VALUE rb_value)
|
|
1363
1387
|
switch (rb_grn_object->range->header.type) {
|
1364
1388
|
case GRN_TYPE:
|
1365
1389
|
if (!(rb_grn_object->range->header.flags & GRN_OBJ_KEY_VAR_SIZE)) {
|
1366
|
-
return
|
1390
|
+
return true;
|
1367
1391
|
}
|
1368
1392
|
break;
|
1369
1393
|
case GRN_TABLE_HASH_KEY:
|
@@ -1379,7 +1403,7 @@ rb_uvector_value_p (RbGrnObject *rb_grn_object, VALUE rb_value)
|
|
1379
1403
|
break;
|
1380
1404
|
}
|
1381
1405
|
|
1382
|
-
return
|
1406
|
+
return false;
|
1383
1407
|
}
|
1384
1408
|
|
1385
1409
|
typedef struct {
|
@@ -1527,7 +1551,7 @@ rb_grn_object_remove (int argc, VALUE *argv, VALUE self)
|
|
1527
1551
|
grn_ctx *context;
|
1528
1552
|
VALUE rb_options;
|
1529
1553
|
VALUE rb_dependent_p;
|
1530
|
-
|
1554
|
+
bool dependent_p = false;
|
1531
1555
|
|
1532
1556
|
rb_grn_object = SELF(self);
|
1533
1557
|
if (!rb_grn_object->object)
|
@@ -1560,7 +1584,7 @@ rb_grn_object_builtin_p (VALUE self)
|
|
1560
1584
|
{
|
1561
1585
|
grn_ctx *context;
|
1562
1586
|
grn_obj *object;
|
1563
|
-
|
1587
|
+
bool builtin = false;
|
1564
1588
|
|
1565
1589
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1566
1590
|
NULL, NULL, NULL, NULL);
|
@@ -1585,7 +1609,7 @@ rb_grn_object_table_p (VALUE self)
|
|
1585
1609
|
{
|
1586
1610
|
grn_ctx *context;
|
1587
1611
|
grn_obj *object;
|
1588
|
-
|
1612
|
+
bool table_p = false;
|
1589
1613
|
|
1590
1614
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1591
1615
|
NULL, NULL, NULL, NULL);
|
@@ -1610,7 +1634,7 @@ rb_grn_object_column_p (VALUE self)
|
|
1610
1634
|
{
|
1611
1635
|
grn_ctx *context;
|
1612
1636
|
grn_obj *object;
|
1613
|
-
|
1637
|
+
bool column_p = false;
|
1614
1638
|
|
1615
1639
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1616
1640
|
NULL, NULL, NULL, NULL);
|
@@ -1636,7 +1660,7 @@ rb_grn_object_reference_column_p (VALUE self)
|
|
1636
1660
|
{
|
1637
1661
|
grn_ctx *context;
|
1638
1662
|
grn_obj *object;
|
1639
|
-
|
1663
|
+
bool reference_column_p = false;
|
1640
1664
|
|
1641
1665
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1642
1666
|
NULL, NULL, NULL, NULL);
|
@@ -1662,7 +1686,7 @@ rb_grn_object_index_column_p (VALUE self)
|
|
1662
1686
|
{
|
1663
1687
|
grn_ctx *context;
|
1664
1688
|
grn_obj *object;
|
1665
|
-
|
1689
|
+
bool index_column_p = false;
|
1666
1690
|
|
1667
1691
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1668
1692
|
NULL, NULL, NULL, NULL);
|
@@ -1687,7 +1711,7 @@ rb_grn_object_procedure_p (VALUE self)
|
|
1687
1711
|
{
|
1688
1712
|
grn_ctx *context;
|
1689
1713
|
grn_obj *object;
|
1690
|
-
|
1714
|
+
bool procedure_p = false;
|
1691
1715
|
|
1692
1716
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1693
1717
|
NULL, NULL, NULL, NULL);
|
@@ -1713,7 +1737,7 @@ rb_grn_object_function_procedure_p (VALUE self)
|
|
1713
1737
|
{
|
1714
1738
|
grn_ctx *context;
|
1715
1739
|
grn_obj *object;
|
1716
|
-
|
1740
|
+
bool function_procedure_p = false;
|
1717
1741
|
|
1718
1742
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1719
1743
|
NULL, NULL, NULL, NULL);
|
@@ -1739,7 +1763,7 @@ rb_grn_object_selector_procedure_p (VALUE self)
|
|
1739
1763
|
{
|
1740
1764
|
grn_ctx *context;
|
1741
1765
|
grn_obj *object;
|
1742
|
-
|
1766
|
+
bool selector_procedure_p = false;
|
1743
1767
|
|
1744
1768
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1745
1769
|
NULL, NULL, NULL, NULL);
|
@@ -1765,7 +1789,7 @@ rb_grn_object_selector_only_procedure_p (VALUE self)
|
|
1765
1789
|
{
|
1766
1790
|
grn_ctx *context;
|
1767
1791
|
grn_obj *object;
|
1768
|
-
|
1792
|
+
bool selector_only_procedure_p = false;
|
1769
1793
|
|
1770
1794
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1771
1795
|
NULL, NULL, NULL, NULL);
|
@@ -1791,7 +1815,7 @@ rb_grn_object_scorer_procedure_p (VALUE self)
|
|
1791
1815
|
{
|
1792
1816
|
grn_ctx *context;
|
1793
1817
|
grn_obj *object;
|
1794
|
-
|
1818
|
+
bool scorer_procedure_p = false;
|
1795
1819
|
|
1796
1820
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1797
1821
|
NULL, NULL, NULL, NULL);
|
@@ -1817,7 +1841,7 @@ rb_grn_object_window_function_procedure_p (VALUE self)
|
|
1817
1841
|
{
|
1818
1842
|
grn_ctx *context;
|
1819
1843
|
grn_obj *object;
|
1820
|
-
|
1844
|
+
bool window_function_procedure_p = false;
|
1821
1845
|
|
1822
1846
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1823
1847
|
NULL, NULL, NULL, NULL);
|
@@ -1844,7 +1868,7 @@ rb_grn_object_accessor_p (VALUE self)
|
|
1844
1868
|
{
|
1845
1869
|
grn_ctx *context;
|
1846
1870
|
grn_obj *object;
|
1847
|
-
|
1871
|
+
bool accessor_p = false;
|
1848
1872
|
|
1849
1873
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1850
1874
|
NULL, NULL, NULL, NULL);
|
@@ -1857,7 +1881,7 @@ rb_grn_object_accessor_p (VALUE self)
|
|
1857
1881
|
}
|
1858
1882
|
|
1859
1883
|
/*
|
1860
|
-
* Checks whether the object is
|
1884
|
+
* Checks whether the object is an accessor for `_key` or not.
|
1861
1885
|
*
|
1862
1886
|
* @example `true` case: `column("_key")` is an accessor and it's an accessor for `_key`
|
1863
1887
|
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
@@ -1880,7 +1904,7 @@ rb_grn_object_key_accessor_p (VALUE self)
|
|
1880
1904
|
{
|
1881
1905
|
grn_ctx *context;
|
1882
1906
|
grn_obj *object;
|
1883
|
-
|
1907
|
+
bool key_accessor_p = false;
|
1884
1908
|
|
1885
1909
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1886
1910
|
NULL, NULL, NULL, NULL);
|
@@ -1892,6 +1916,153 @@ rb_grn_object_key_accessor_p (VALUE self)
|
|
1892
1916
|
return CBOOL2RVAL(key_accessor_p);
|
1893
1917
|
}
|
1894
1918
|
|
1919
|
+
/*
|
1920
|
+
* Checks whether the object is an accessor for `_id` or not.
|
1921
|
+
*
|
1922
|
+
* @example `true` case: `column("_id")` is an accessor and it's an accessor for `_id`
|
1923
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
1924
|
+
* users = Groonga["Users"]
|
1925
|
+
* users.column("_id").id_accessor? # => true
|
1926
|
+
*
|
1927
|
+
* @example `false` case: `column("_key")` is an accessor but it's not an accessor for `_id`
|
1928
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
1929
|
+
* users = Groonga["Users"]
|
1930
|
+
* users.column("_key").id_accessor? # => false
|
1931
|
+
*
|
1932
|
+
* @overload id_accessor?
|
1933
|
+
* @return [Boolean] `true` if the object is an accessor for `_id`,
|
1934
|
+
* `false` otherwise.
|
1935
|
+
*
|
1936
|
+
* @since 9.0.4
|
1937
|
+
*/
|
1938
|
+
static VALUE
|
1939
|
+
rb_grn_object_id_accessor_p (VALUE self)
|
1940
|
+
{
|
1941
|
+
grn_ctx *context;
|
1942
|
+
grn_obj *object;
|
1943
|
+
bool id_accessor_p = false;
|
1944
|
+
|
1945
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1946
|
+
NULL, NULL, NULL, NULL);
|
1947
|
+
|
1948
|
+
if (context && object) {
|
1949
|
+
id_accessor_p = grn_obj_is_id_accessor(context, object);
|
1950
|
+
}
|
1951
|
+
|
1952
|
+
return CBOOL2RVAL(id_accessor_p);
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
/*
|
1956
|
+
* Checks whether the object is an accessor for `_value` or not.
|
1957
|
+
*
|
1958
|
+
* @example `true` case: `column("_value")` is an accessor and it's an accessor for `_value`
|
1959
|
+
* Groonga::Schema.create_table("Users",
|
1960
|
+
* :key_type => :short_text,
|
1961
|
+
* :value_type => "UInt32")
|
1962
|
+
* users = Groonga["Users"]
|
1963
|
+
* users.column("_value").value_accessor? # => true
|
1964
|
+
*
|
1965
|
+
* @example `false` case: `column("_key")` is an accessor but it's not an accessor for `_value`
|
1966
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
1967
|
+
* users = Groonga["Users"]
|
1968
|
+
* users.column("_key").value_accessor? # => false
|
1969
|
+
*
|
1970
|
+
* @overload value_accessor?
|
1971
|
+
* @return [Boolean] `true` if the object is an accessor for `_value`,
|
1972
|
+
* `false` otherwise.
|
1973
|
+
*
|
1974
|
+
* @since 9.0.4
|
1975
|
+
*/
|
1976
|
+
static VALUE
|
1977
|
+
rb_grn_object_value_accessor_p (VALUE self)
|
1978
|
+
{
|
1979
|
+
grn_ctx *context;
|
1980
|
+
grn_obj *object;
|
1981
|
+
bool value_accessor_p = false;
|
1982
|
+
|
1983
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1984
|
+
NULL, NULL, NULL, NULL);
|
1985
|
+
|
1986
|
+
if (context && object) {
|
1987
|
+
value_accessor_p = grn_obj_is_value_accessor(context, object);
|
1988
|
+
}
|
1989
|
+
|
1990
|
+
return CBOOL2RVAL(value_accessor_p);
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
/*
|
1994
|
+
* Checks whether the object is an accessor for `_socre` or not.
|
1995
|
+
*
|
1996
|
+
* @example `true` case: `column("_score")` is an accessor and it's an accessor for `_score`
|
1997
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
1998
|
+
* users = Groonga["Users"]
|
1999
|
+
* users.select.column("_score").socre_accessor? # => true
|
2000
|
+
*
|
2001
|
+
* @example `false` case: `column("_key")` is an accessor but it's not an accessor for `_score`
|
2002
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
2003
|
+
* users = Groonga["Users"]
|
2004
|
+
* users.column("_key").score_accessor? # => false
|
2005
|
+
*
|
2006
|
+
* @overload score_accessor?
|
2007
|
+
* @return [Boolean] `true` if the object is an accessor for `_score`,
|
2008
|
+
* `false` otherwise.
|
2009
|
+
*
|
2010
|
+
* @since 9.0.4
|
2011
|
+
*/
|
2012
|
+
static VALUE
|
2013
|
+
rb_grn_object_score_accessor_p (VALUE self)
|
2014
|
+
{
|
2015
|
+
grn_ctx *context;
|
2016
|
+
grn_obj *object;
|
2017
|
+
bool score_accessor_p = false;
|
2018
|
+
|
2019
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
2020
|
+
NULL, NULL, NULL, NULL);
|
2021
|
+
|
2022
|
+
if (context && object) {
|
2023
|
+
score_accessor_p = grn_obj_is_score_accessor(context, object);
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
return CBOOL2RVAL(score_accessor_p);
|
2027
|
+
}
|
2028
|
+
|
2029
|
+
/*
|
2030
|
+
* Checks whether the object is an accessor for `_nsubrecs` or not.
|
2031
|
+
*
|
2032
|
+
* @example `true` case: `column("_nsubrecs")` is an accessor and it's an accessor for `_nsubrecs`
|
2033
|
+
* users = Groonga::Hash.create(:name => "Users",
|
2034
|
+
* :key_type => "ShortText")
|
2035
|
+
* grouped_users = users.group("_key")
|
2036
|
+
* grouped_users.column("_nsubrecs").n_sub_records_accessor? # => true
|
2037
|
+
*
|
2038
|
+
* @example `false` case: `column("_key")` is an accessor but it's not an accessor for `_nsubrecs`
|
2039
|
+
* Groonga::Schema.create_table("Users", :key_type => :short_text)
|
2040
|
+
* users = Groonga["Users"]
|
2041
|
+
* users.column("_key").n_sub_records_accessor? # => false
|
2042
|
+
*
|
2043
|
+
* @overload n_sub_records_accessor?
|
2044
|
+
* @return [Boolean] `true` if the object is an accessor for `_nsubrecs`,
|
2045
|
+
* `false` otherwise.
|
2046
|
+
*
|
2047
|
+
* @since 9.0.4
|
2048
|
+
*/
|
2049
|
+
VALUE
|
2050
|
+
rb_grn_object_n_sub_records_accessor_p (VALUE self)
|
2051
|
+
{
|
2052
|
+
grn_ctx *context;
|
2053
|
+
grn_obj *object;
|
2054
|
+
bool n_sub_records_accessor_p = false;
|
2055
|
+
|
2056
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
2057
|
+
NULL, NULL, NULL, NULL);
|
2058
|
+
|
2059
|
+
if (context && object) {
|
2060
|
+
n_sub_records_accessor_p = grn_obj_is_nsubrecs_accessor(context, object);
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
return CBOOL2RVAL(n_sub_records_accessor_p);
|
2064
|
+
}
|
2065
|
+
|
1895
2066
|
/*
|
1896
2067
|
* Update the last modified time of the `object`. It's meaningful only
|
1897
2068
|
* for persistent database, table and column.
|
@@ -1962,11 +2133,15 @@ rb_grn_object_dirty_p (VALUE self)
|
|
1962
2133
|
{
|
1963
2134
|
grn_ctx *context;
|
1964
2135
|
grn_obj *object;
|
1965
|
-
|
2136
|
+
bool is_dirty = false;
|
1966
2137
|
|
1967
2138
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1968
2139
|
NULL, NULL, NULL, NULL);
|
1969
|
-
|
2140
|
+
|
2141
|
+
if (context && object) {
|
2142
|
+
is_dirty = grn_obj_is_dirty(context, object);
|
2143
|
+
}
|
2144
|
+
|
1970
2145
|
return CBOOL2RVAL(is_dirty);
|
1971
2146
|
}
|
1972
2147
|
|
@@ -1981,14 +2156,62 @@ rb_grn_object_corrupt_p (VALUE self)
|
|
1981
2156
|
{
|
1982
2157
|
grn_ctx *context;
|
1983
2158
|
grn_obj *object;
|
1984
|
-
|
2159
|
+
bool is_corrupt = false;
|
1985
2160
|
|
1986
2161
|
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
1987
2162
|
NULL, NULL, NULL, NULL);
|
1988
|
-
|
2163
|
+
|
2164
|
+
if (context && object) {
|
2165
|
+
is_corrupt = grn_obj_is_corrupt(context, object);
|
2166
|
+
}
|
2167
|
+
|
1989
2168
|
return CBOOL2RVAL(is_corrupt);
|
1990
2169
|
}
|
1991
2170
|
|
2171
|
+
/*
|
2172
|
+
* @overload lexicon?
|
2173
|
+
* @return [Boolean] `true` if the object is lexicon, `false` otherwise.
|
2174
|
+
*
|
2175
|
+
* @since 9.0.4
|
2176
|
+
*/
|
2177
|
+
static VALUE
|
2178
|
+
rb_grn_object_lexicon_p (VALUE self)
|
2179
|
+
{
|
2180
|
+
grn_ctx *context;
|
2181
|
+
grn_obj *object;
|
2182
|
+
bool is_lexicon = false;
|
2183
|
+
|
2184
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
2185
|
+
NULL, NULL, NULL, NULL);
|
2186
|
+
|
2187
|
+
if (context && object) {
|
2188
|
+
is_lexicon = grn_obj_is_lexicon(context, object);
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
return CBOOL2RVAL(is_lexicon);
|
2192
|
+
}
|
2193
|
+
|
2194
|
+
/*
|
2195
|
+
* @overload bulk?
|
2196
|
+
* @return [Boolean] `true` if the object is bulk, `false` otherwise.
|
2197
|
+
*
|
2198
|
+
* @since 9.0.4
|
2199
|
+
*/
|
2200
|
+
static VALUE
|
2201
|
+
rb_grn_object_bulk_p (VALUE self)
|
2202
|
+
{
|
2203
|
+
grn_ctx *context;
|
2204
|
+
grn_obj *object;
|
2205
|
+
bool is_bulk = false;
|
2206
|
+
|
2207
|
+
rb_grn_object_deconstruct(SELF(self), &object, &context,
|
2208
|
+
NULL, NULL, NULL, NULL);
|
2209
|
+
if (context && object) {
|
2210
|
+
is_bulk = grn_obj_is_bulk(context, object);
|
2211
|
+
}
|
2212
|
+
return CBOOL2RVAL(is_bulk);
|
2213
|
+
}
|
2214
|
+
|
1992
2215
|
/*
|
1993
2216
|
* @overload disk_usage
|
1994
2217
|
* @return [Integer] The number of bytes used by this object in disk.
|
@@ -2011,7 +2234,7 @@ rb_grn_object_get_disk_usage (VALUE self)
|
|
2011
2234
|
void
|
2012
2235
|
rb_grn_init_object (VALUE mGrn)
|
2013
2236
|
{
|
2014
|
-
rb_cGrnObject = rb_define_class_under(mGrn, "Object",
|
2237
|
+
rb_cGrnObject = rb_define_class_under(mGrn, "Object", rb_cObject);
|
2015
2238
|
rb_define_alloc_func(rb_cGrnObject, rb_grn_object_alloc);
|
2016
2239
|
|
2017
2240
|
rb_define_attr(rb_cGrnObject, "context", GRN_TRUE, GRN_FALSE);
|
@@ -2064,6 +2287,14 @@ rb_grn_init_object (VALUE mGrn)
|
|
2064
2287
|
rb_grn_object_accessor_p, 0);
|
2065
2288
|
rb_define_method(rb_cGrnObject, "key_accessor?",
|
2066
2289
|
rb_grn_object_key_accessor_p, 0);
|
2290
|
+
rb_define_method(rb_cGrnObject, "id_accessor?",
|
2291
|
+
rb_grn_object_id_accessor_p, 0);
|
2292
|
+
rb_define_method(rb_cGrnObject, "value_accessor?",
|
2293
|
+
rb_grn_object_value_accessor_p, 0);
|
2294
|
+
rb_define_method(rb_cGrnObject, "score_accessor?",
|
2295
|
+
rb_grn_object_score_accessor_p, 0);
|
2296
|
+
rb_define_method(rb_cGrnObject, "n_sub_records_accessor?",
|
2297
|
+
rb_grn_object_n_sub_records_accessor_p, 0);
|
2067
2298
|
|
2068
2299
|
rb_define_method(rb_cGrnObject, "touch", rb_grn_object_touch, -1);
|
2069
2300
|
rb_define_method(rb_cGrnObject, "last_modified",
|
@@ -2072,6 +2303,10 @@ rb_grn_init_object (VALUE mGrn)
|
|
2072
2303
|
rb_grn_object_dirty_p, 0);
|
2073
2304
|
rb_define_method(rb_cGrnObject, "corrupt?",
|
2074
2305
|
rb_grn_object_corrupt_p, 0);
|
2306
|
+
rb_define_method(rb_cGrnObject, "lexicon?",
|
2307
|
+
rb_grn_object_lexicon_p, 0);
|
2308
|
+
rb_define_method(rb_cGrnObject, "bulk?",
|
2309
|
+
rb_grn_object_bulk_p, 0);
|
2075
2310
|
|
2076
2311
|
rb_define_method(rb_cGrnObject, "disk_usage",
|
2077
2312
|
rb_grn_object_get_disk_usage, 0);
|