groonga 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +18 -3
- data/NEWS.rdoc +18 -3
- data/README.ja.rdoc +2 -0
- data/README.rdoc +2 -0
- data/Rakefile +14 -5
- data/TUTORIAL.ja.rdoc +82 -16
- data/benchmark/{read-write-small-many-items.rb → read-write-many-small-items.rb} +26 -23
- data/benchmark/{write-small-many-items.rb → write-many-small-items.rb} +26 -23
- data/example/bookmark.rb +49 -5
- data/ext/rb-grn-array.c +11 -1
- data/ext/rb-grn-column.c +132 -5
- data/ext/rb-grn-context.c +85 -80
- data/ext/rb-grn-database.c +182 -9
- data/ext/rb-grn-expression-builder.c +69 -0
- data/ext/rb-grn-expression.c +314 -0
- data/ext/rb-grn-fix-size-column.c +68 -89
- data/ext/rb-grn-hash.c +14 -5
- data/ext/rb-grn-index-column.c +14 -55
- data/ext/rb-grn-object.c +206 -75
- data/ext/rb-grn-operation.c +92 -0
- data/ext/rb-grn-patricia-trie.c +10 -32
- data/ext/rb-grn-query.c +9 -9
- data/ext/rb-grn-table-cursor.c +19 -80
- data/ext/rb-grn-table-key-support.c +33 -39
- data/ext/rb-grn-table.c +436 -79
- data/ext/rb-grn-type.c +10 -3
- data/ext/rb-grn-utils.c +131 -4
- data/ext/rb-grn-variable-size-column.c +36 -0
- data/ext/rb-grn-variable.c +90 -0
- data/ext/rb-grn.h +109 -56
- data/ext/rb-groonga.c +4 -0
- data/extconf.rb +39 -13
- data/html/index.html +2 -2
- data/lib/groonga.rb +22 -0
- data/lib/groonga/expression-builder.rb +141 -0
- data/lib/groonga/record.rb +25 -1
- data/lib/groonga/schema.rb +418 -0
- data/test/test-column.rb +11 -23
- data/test/test-context.rb +1 -1
- data/test/test-database.rb +60 -19
- data/test/test-expression-builder.rb +114 -0
- data/test/test-expression.rb +55 -0
- data/test/test-fix-size-column.rb +53 -0
- data/test/test-hash.rb +10 -3
- data/test/test-index-column.rb +24 -0
- data/test/test-patricia-trie.rb +9 -0
- data/test/test-procedure.rb +5 -5
- data/test/test-record.rb +71 -4
- data/test/test-schema.rb +207 -0
- data/test/test-table.rb +94 -12
- data/test/test-type.rb +18 -11
- data/test/test-variable-size-column.rb +53 -0
- data/test/test-variable.rb +28 -0
- metadata +18 -5
data/ext/rb-grn-type.c
CHANGED
@@ -85,7 +85,7 @@ rb_grn_type_initialize (int argc, VALUE *argv, VALUE self)
|
|
85
85
|
}
|
86
86
|
|
87
87
|
type = grn_type_create(context, name, name_size, flags, size);
|
88
|
-
rb_grn_object_assign(self, rb_context, context, type
|
88
|
+
rb_grn_object_assign(Qnil, self, rb_context, context, type);
|
89
89
|
rb_grn_context_check(context, rb_ary_new4(argc, argv));
|
90
90
|
|
91
91
|
return Qnil;
|
@@ -98,15 +98,22 @@ rb_grn_init_type (VALUE mGrn)
|
|
98
98
|
|
99
99
|
rb_define_method(rb_cGrnType, "initialize", rb_grn_type_initialize, -1);
|
100
100
|
|
101
|
+
rb_define_const(rb_cGrnType, "OBJECT", INT2NUM(GRN_DB_OBJECT));
|
102
|
+
rb_define_const(rb_cGrnType, "BOOLEAN", INT2NUM(GRN_DB_BOOL));
|
103
|
+
rb_define_const(rb_cGrnType, "BOOL", INT2NUM(GRN_DB_BOOL));
|
104
|
+
rb_define_const(rb_cGrnType, "INT8", INT2NUM(GRN_DB_INT8));
|
105
|
+
rb_define_const(rb_cGrnType, "UINT8", INT2NUM(GRN_DB_UINT8));
|
106
|
+
rb_define_const(rb_cGrnType, "INT16", INT2NUM(GRN_DB_INT16));
|
107
|
+
rb_define_const(rb_cGrnType, "UINT16", INT2NUM(GRN_DB_UINT16));
|
101
108
|
rb_define_const(rb_cGrnType, "INT32", INT2NUM(GRN_DB_INT32));
|
102
109
|
rb_define_const(rb_cGrnType, "UINT32", INT2NUM(GRN_DB_UINT32));
|
103
110
|
rb_define_const(rb_cGrnType, "INT64", INT2NUM(GRN_DB_INT64));
|
104
111
|
rb_define_const(rb_cGrnType, "UINT64", INT2NUM(GRN_DB_UINT64));
|
105
112
|
rb_define_const(rb_cGrnType, "FLOAT", INT2NUM(GRN_DB_FLOAT));
|
106
113
|
rb_define_const(rb_cGrnType, "TIME", INT2NUM(GRN_DB_TIME));
|
107
|
-
rb_define_const(rb_cGrnType, "SHORT_TEXT", INT2NUM(
|
114
|
+
rb_define_const(rb_cGrnType, "SHORT_TEXT", INT2NUM(GRN_DB_SHORT_TEXT));
|
108
115
|
rb_define_const(rb_cGrnType, "TEXT", INT2NUM(GRN_DB_TEXT));
|
109
|
-
rb_define_const(rb_cGrnType, "LONG_TEXT", INT2NUM(
|
116
|
+
rb_define_const(rb_cGrnType, "LONG_TEXT", INT2NUM(GRN_DB_LONG_TEXT));
|
110
117
|
rb_define_const(rb_cGrnType, "DELIMIT", INT2NUM(GRN_DB_DELIMIT));
|
111
118
|
rb_define_const(rb_cGrnType, "UNIGRAM", INT2NUM(GRN_DB_UNIGRAM));
|
112
119
|
rb_define_const(rb_cGrnType, "BIGRAM", INT2NUM(GRN_DB_BIGRAM));
|
data/ext/rb-grn-utils.c
CHANGED
@@ -116,9 +116,9 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
|
|
116
116
|
INT2NUM(time_value->tv_usec));
|
117
117
|
}
|
118
118
|
break;
|
119
|
-
case
|
119
|
+
case GRN_DB_SHORT_TEXT:
|
120
120
|
case GRN_DB_TEXT:
|
121
|
-
case
|
121
|
+
case GRN_DB_LONG_TEXT:
|
122
122
|
*rb_value = rb_str_new(GRN_BULK_HEAD(bulk), GRN_BULK_VSIZE(bulk));
|
123
123
|
break;
|
124
124
|
default:
|
@@ -307,9 +307,9 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
|
|
307
307
|
string = (const char *)&time_value;
|
308
308
|
size = sizeof(time_value);
|
309
309
|
break;
|
310
|
-
case
|
310
|
+
case GRN_DB_SHORT_TEXT:
|
311
311
|
case GRN_DB_TEXT:
|
312
|
-
case
|
312
|
+
case GRN_DB_LONG_TEXT:
|
313
313
|
string = StringValuePtr(object);
|
314
314
|
size = RSTRING_LEN(object);
|
315
315
|
range = grn_obj_get_range(context, type);
|
@@ -571,6 +571,133 @@ rb_grn_key_from_ruby_object (VALUE rb_key, grn_ctx *context,
|
|
571
571
|
return key;
|
572
572
|
}
|
573
573
|
|
574
|
+
grn_obj *
|
575
|
+
rb_grn_obj_from_ruby_object (VALUE rb_object, grn_ctx *context, grn_obj **_obj)
|
576
|
+
{
|
577
|
+
grn_obj *obj;
|
578
|
+
|
579
|
+
if (*_obj) {
|
580
|
+
obj = *_obj;
|
581
|
+
grn_obj_close(context, obj); /* FIXME: grn_obj_reinit() */
|
582
|
+
} else {
|
583
|
+
*_obj = grn_obj_open(context, GRN_VOID, 0, GRN_ID_NIL);
|
584
|
+
obj = *_obj;
|
585
|
+
}
|
586
|
+
|
587
|
+
switch (TYPE(rb_object)) {
|
588
|
+
case T_NIL:
|
589
|
+
GRN_VOID_INIT(obj);
|
590
|
+
break;
|
591
|
+
case T_STRING:
|
592
|
+
GRN_TEXT_INIT(obj, 0);
|
593
|
+
GRN_TEXT_SET(context, obj,
|
594
|
+
RSTRING_PTR(rb_object), RSTRING_LEN(rb_object));
|
595
|
+
break;
|
596
|
+
case T_FIXNUM:
|
597
|
+
GRN_INT32_INIT(obj, 0);
|
598
|
+
GRN_INT32_SET(context, obj, NUM2INT(rb_object));
|
599
|
+
break;
|
600
|
+
case T_BIGNUM:
|
601
|
+
GRN_INT64_INIT(obj, 0);
|
602
|
+
GRN_INT64_SET(context, obj, NUM2LL(rb_object));
|
603
|
+
break;
|
604
|
+
case T_FLOAT:
|
605
|
+
GRN_FLOAT_INIT(obj, 0);
|
606
|
+
GRN_FLOAT_SET(context, obj, NUM2DBL(rb_object));
|
607
|
+
break;
|
608
|
+
default:
|
609
|
+
if (RVAL2CBOOL(rb_obj_is_kind_of(rb_object, rb_cTime))) {
|
610
|
+
VALUE sec, usec;
|
611
|
+
unsigned long long time_value;
|
612
|
+
|
613
|
+
sec = rb_funcall(rb_object, rb_intern("to_i"), 0);
|
614
|
+
usec = rb_funcall(rb_object, rb_intern("usec"), 0);
|
615
|
+
time_value = NUM2INT(sec);
|
616
|
+
time_value <<= 32;
|
617
|
+
time_value += NUM2INT(usec);
|
618
|
+
GRN_TIME_INIT(obj, 0);
|
619
|
+
GRN_TIME_SET(context, obj, time_value);
|
620
|
+
} else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_object, rb_cGrnObject))) {
|
621
|
+
grn_obj_close(context, obj); /* TODO: reduce memory allocation */
|
622
|
+
*_obj = RVAL2GRNOBJECT(rb_object, &context);
|
623
|
+
obj = *_obj;
|
624
|
+
} else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_object, rb_cGrnRecord))) {
|
625
|
+
grn_id id, table_id;
|
626
|
+
VALUE rb_table;
|
627
|
+
grn_obj *table = NULL;
|
628
|
+
|
629
|
+
id = NUM2UINT(rb_funcall(rb_object, rb_intern("id"), 0));
|
630
|
+
rb_table = rb_funcall(rb_object, rb_intern("table"), 0);
|
631
|
+
rb_grn_table_deconstruct(RB_GRN_TABLE(DATA_PTR(rb_table)),
|
632
|
+
&table, NULL,
|
633
|
+
NULL, NULL, NULL, NULL, NULL);
|
634
|
+
table_id = grn_obj_id(context, table);
|
635
|
+
GRN_RECORD_INIT(obj, 0, table_id);
|
636
|
+
GRN_RECORD_SET(context, obj, id);
|
637
|
+
} else {
|
638
|
+
rb_raise(rb_eTypeError,
|
639
|
+
"should be one of "
|
640
|
+
"[nil, String, Integer, Float, Time, Groonga::Object, "
|
641
|
+
"Groonga::Record]: <%s>",
|
642
|
+
rb_grn_inspect(rb_object));
|
643
|
+
}
|
644
|
+
break;
|
645
|
+
}
|
646
|
+
|
647
|
+
return obj;
|
648
|
+
}
|
649
|
+
|
650
|
+
VALUE
|
651
|
+
rb_grn_obj_to_ruby_object (VALUE klass, grn_ctx *context,
|
652
|
+
grn_obj *obj, VALUE related_object)
|
653
|
+
{
|
654
|
+
if (!obj)
|
655
|
+
return Qnil;
|
656
|
+
|
657
|
+
/* if (NIL_P(klass)) */
|
658
|
+
/* klass = GRNOBJECT2RCLASS(obj); */
|
659
|
+
|
660
|
+
switch (obj->header.type) {
|
661
|
+
case GRN_VOID:
|
662
|
+
return Qnil;
|
663
|
+
break;
|
664
|
+
case GRN_BULK:
|
665
|
+
return GRNBULK2RVAL(context, obj, related_object);
|
666
|
+
break;
|
667
|
+
/* case GRN_PTR: */
|
668
|
+
/* case GRN_UVECTOR: */
|
669
|
+
/* case GRN_PVECTOR: */
|
670
|
+
/* case GRN_VECTOR: */
|
671
|
+
/* case GRN_MSG: */
|
672
|
+
/* case GRN_QUERY: */
|
673
|
+
/* case GRN_ACCESSOR: */
|
674
|
+
/* case GRN_SNIP: */
|
675
|
+
/* case GRN_PATSNIP: */
|
676
|
+
/* case GRN_CURSOR_TABLE_HASH_KEY: */
|
677
|
+
/* case GRN_CURSOR_TABLE_PAT_KEY: */
|
678
|
+
/* case GRN_CURSOR_TABLE_NO_KEY: */
|
679
|
+
/* case GRN_CURSOR_COLUMN_INDEX: */
|
680
|
+
/* case GRN_TYPE: */
|
681
|
+
/* case GRN_PROC: */
|
682
|
+
/* case GRN_EXPR: */
|
683
|
+
/* case GRN_TABLE_HASH_KEY: */
|
684
|
+
/* case GRN_TABLE_PAT_KEY: */
|
685
|
+
/* case GRN_TABLE_NO_KEY: */
|
686
|
+
/* case GRN_DB: */
|
687
|
+
/* case GRN_COLUMN_FIX_SIZE: */
|
688
|
+
/* case GRN_COLUMN_VAR_SIZE: */
|
689
|
+
/* case GRN_COLUMN_INDEX: */
|
690
|
+
default:
|
691
|
+
rb_raise(rb_eTypeError,
|
692
|
+
"unsupported groonga object: 0x%x: <%s>",
|
693
|
+
obj->header.type,
|
694
|
+
rb_grn_inspect(related_object));
|
695
|
+
break;
|
696
|
+
}
|
697
|
+
|
698
|
+
return Qnil;
|
699
|
+
}
|
700
|
+
|
574
701
|
void
|
575
702
|
rb_grn_init_utils (VALUE mGrn)
|
576
703
|
{
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License version 2.1 as published by the Free Software Foundation.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rb-grn.h"
|
20
|
+
|
21
|
+
#define SELF(object) ((RbGrnVariableSizeColumn *)DATA_PTR(object))
|
22
|
+
|
23
|
+
VALUE rb_cGrnVariableSizeColumn;
|
24
|
+
|
25
|
+
/*
|
26
|
+
* Document-class: Groonga::FixSizeColumn < Groonga::Column
|
27
|
+
*
|
28
|
+
* 可変長データ用のカラム。
|
29
|
+
*/
|
30
|
+
|
31
|
+
void
|
32
|
+
rb_grn_init_variable_size_column (VALUE mGrn)
|
33
|
+
{
|
34
|
+
rb_cGrnVariableSizeColumn =
|
35
|
+
rb_define_class_under(mGrn, "VariableSizeColumn", rb_cGrnColumn);
|
36
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License version 2.1 as published by the Free Software Foundation.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rb-grn.h"
|
20
|
+
|
21
|
+
#define SELF(object) ((RbGrnVariable *)DATA_PTR(object))
|
22
|
+
|
23
|
+
VALUE rb_cGrnVariable;
|
24
|
+
|
25
|
+
grn_obj *
|
26
|
+
rb_grn_variable_from_ruby_object (VALUE variable, grn_ctx **context)
|
27
|
+
{
|
28
|
+
return rb_grn_object_from_ruby_object(variable, context);
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
rb_grn_variable_to_ruby_object (grn_ctx *context, grn_obj *variable)
|
33
|
+
{
|
34
|
+
return rb_grn_object_to_ruby_object(rb_cGrnVariable, context, variable,
|
35
|
+
RB_GRN_TRUE);
|
36
|
+
}
|
37
|
+
|
38
|
+
void
|
39
|
+
rb_grn_variable_deconstruct (RbGrnVariable *rb_grn_variable,
|
40
|
+
grn_obj **variable,
|
41
|
+
grn_ctx **context,
|
42
|
+
grn_id *domain_id,
|
43
|
+
grn_obj **domain,
|
44
|
+
grn_id *range_id,
|
45
|
+
grn_obj **range)
|
46
|
+
{
|
47
|
+
RbGrnObject *rb_grn_object;
|
48
|
+
|
49
|
+
rb_grn_object = RB_GRN_OBJECT(rb_grn_variable);
|
50
|
+
rb_grn_object_deconstruct(rb_grn_object, variable, context,
|
51
|
+
domain_id, domain,
|
52
|
+
range_id, range);
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
rb_grn_variable_get_value (VALUE self)
|
57
|
+
{
|
58
|
+
grn_ctx *context = NULL;
|
59
|
+
grn_obj *variable;
|
60
|
+
|
61
|
+
rb_grn_variable_deconstruct(SELF(self), &variable, &context,
|
62
|
+
NULL, NULL,
|
63
|
+
NULL, NULL);
|
64
|
+
|
65
|
+
return GRNOBJ2RVAL(Qnil, context, variable, self);
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
rb_grn_variable_set_value (VALUE self, VALUE value)
|
70
|
+
{
|
71
|
+
grn_ctx *context = NULL;
|
72
|
+
grn_obj *variable;
|
73
|
+
|
74
|
+
rb_grn_variable_deconstruct(SELF(self), &variable, &context,
|
75
|
+
NULL, NULL,
|
76
|
+
NULL, NULL);
|
77
|
+
RVAL2GRNOBJ(value, context, &variable);
|
78
|
+
return Qnil;
|
79
|
+
}
|
80
|
+
|
81
|
+
void
|
82
|
+
rb_grn_init_variable (VALUE mGrn)
|
83
|
+
{
|
84
|
+
rb_cGrnVariable = rb_define_class_under(mGrn, "Variable", rb_cGrnObject);
|
85
|
+
|
86
|
+
rb_define_method(rb_cGrnVariable, "value",
|
87
|
+
rb_grn_variable_get_value, 0);
|
88
|
+
rb_define_method(rb_cGrnVariable, "value=",
|
89
|
+
rb_grn_variable_set_value, 1);
|
90
|
+
}
|
data/ext/rb-grn.h
CHANGED
@@ -57,9 +57,15 @@ RB_GRN_BEGIN_DECLS
|
|
57
57
|
# define RB_GRN_VAR extern
|
58
58
|
#endif
|
59
59
|
|
60
|
+
#ifdef RB_GRN_DEBUG
|
61
|
+
# define debug(...) printf(__VA_ARGS__)
|
62
|
+
#else
|
63
|
+
# define debug(...)
|
64
|
+
#endif
|
65
|
+
|
60
66
|
#define RB_GRN_MAJOR_VERSION 0
|
61
67
|
#define RB_GRN_MINOR_VERSION 0
|
62
|
-
#define RB_GRN_MICRO_VERSION
|
68
|
+
#define RB_GRN_MICRO_VERSION 3
|
63
69
|
|
64
70
|
typedef int rb_grn_boolean;
|
65
71
|
#define RB_GRN_FALSE (0)
|
@@ -76,8 +82,11 @@ typedef struct {
|
|
76
82
|
|
77
83
|
#define RB_GRN_OBJECT(object) ((RbGrnObject *)(object))
|
78
84
|
#define RB_GRN_TABLE(object) ((RbGrnTable *)(object))
|
85
|
+
#define RB_GRN_TABLE_KEY_SUPPORT(object) ((RbGrnTableKeySupport *)(object))
|
79
86
|
#define RB_GRN_TABLE_CURSOR(object) ((RbGrnTableCursort *)(object))
|
87
|
+
#define RB_GRN_COLUMN(object) ((RbGrnColumn *)(object))
|
80
88
|
#define RB_GRN_INDEX_COLUMN(object) ((RbGrnIndexColumn *)(object))
|
89
|
+
#define RB_GRN_EXPRESSION(object) ((RbGrnExpression *)(object))
|
81
90
|
#define RB_GRN_UNBIND_FUNCTION(function) ((RbGrnUnbindFunction)(function))
|
82
91
|
|
83
92
|
typedef void (*RbGrnUnbindFunction) (void *object);
|
@@ -85,14 +94,14 @@ typedef void (*RbGrnUnbindFunction) (void *object);
|
|
85
94
|
typedef struct _RbGrnObject RbGrnObject;
|
86
95
|
struct _RbGrnObject
|
87
96
|
{
|
97
|
+
VALUE self;
|
88
98
|
grn_ctx *context;
|
89
99
|
grn_obj *object;
|
90
100
|
grn_obj *domain;
|
91
101
|
grn_id domain_id;
|
92
102
|
grn_obj *range;
|
93
103
|
grn_id range_id;
|
94
|
-
rb_grn_boolean
|
95
|
-
RbGrnUnbindFunction unbind;
|
104
|
+
rb_grn_boolean need_close;
|
96
105
|
};
|
97
106
|
|
98
107
|
typedef struct _RbGrnTable RbGrnTable;
|
@@ -116,18 +125,10 @@ struct _RbGrnColumn
|
|
116
125
|
grn_obj *value;
|
117
126
|
};
|
118
127
|
|
119
|
-
typedef struct _RbGrnFixSizeColumn RbGrnFixSizeColumn;
|
120
|
-
struct _RbGrnFixSizeColumn
|
121
|
-
{
|
122
|
-
RbGrnObject parent;
|
123
|
-
grn_obj *value;
|
124
|
-
};
|
125
|
-
|
126
128
|
typedef struct _RbGrnIndexColumn RbGrnIndexColumn;
|
127
129
|
struct _RbGrnIndexColumn
|
128
130
|
{
|
129
|
-
|
130
|
-
grn_obj *value;
|
131
|
+
RbGrnColumn parent;
|
131
132
|
grn_obj *old_value;
|
132
133
|
grn_obj *id_query;
|
133
134
|
grn_obj *string_query;
|
@@ -139,6 +140,19 @@ struct _RbGrnTableCursor
|
|
139
140
|
RbGrnObject parent;
|
140
141
|
};
|
141
142
|
|
143
|
+
typedef struct _RbGrnVariable RbGrnVariable;
|
144
|
+
struct _RbGrnVariable
|
145
|
+
{
|
146
|
+
RbGrnObject parent;
|
147
|
+
};
|
148
|
+
|
149
|
+
typedef struct _RbGrnExpression RbGrnExpression;
|
150
|
+
struct _RbGrnExpression
|
151
|
+
{
|
152
|
+
RbGrnObject parent;
|
153
|
+
grn_obj *value;
|
154
|
+
};
|
155
|
+
|
142
156
|
RB_GRN_VAR VALUE rb_eGrnError;
|
143
157
|
RB_GRN_VAR VALUE rb_cGrnObject;
|
144
158
|
RB_GRN_VAR VALUE rb_mGrnEncodingSupport;
|
@@ -157,13 +171,18 @@ RB_GRN_VAR VALUE rb_cGrnType;
|
|
157
171
|
RB_GRN_VAR VALUE rb_cGrnProcedure;
|
158
172
|
RB_GRN_VAR VALUE rb_cGrnColumn;
|
159
173
|
RB_GRN_VAR VALUE rb_cGrnFixSizeColumn;
|
160
|
-
RB_GRN_VAR VALUE
|
174
|
+
RB_GRN_VAR VALUE rb_cGrnVariableSizeColumn;
|
161
175
|
RB_GRN_VAR VALUE rb_cGrnIndexColumn;
|
162
176
|
RB_GRN_VAR VALUE rb_cGrnAccessor;
|
163
177
|
RB_GRN_VAR VALUE rb_cGrnRecord;
|
164
178
|
RB_GRN_VAR VALUE rb_cGrnQuery;
|
165
179
|
RB_GRN_VAR VALUE rb_cGrnLogger;
|
166
180
|
RB_GRN_VAR VALUE rb_cGrnSnippet;
|
181
|
+
RB_GRN_VAR VALUE rb_cGrnVariable;
|
182
|
+
RB_GRN_VAR VALUE rb_cGrnOperation;
|
183
|
+
RB_GRN_VAR VALUE rb_cGrnExpression;
|
184
|
+
RB_GRN_VAR VALUE rb_cGrnRecordExpressionBuilder;
|
185
|
+
RB_GRN_VAR VALUE rb_cGrnColumnExpressionBuilder;
|
167
186
|
|
168
187
|
void rb_grn_init_utils (VALUE mGrn);
|
169
188
|
void rb_grn_init_exception (VALUE mGrn);
|
@@ -186,10 +205,15 @@ void rb_grn_init_type (VALUE mGrn);
|
|
186
205
|
void rb_grn_init_procedure (VALUE mGrn);
|
187
206
|
void rb_grn_init_column (VALUE mGrn);
|
188
207
|
void rb_grn_init_fix_size_column (VALUE mGrn);
|
208
|
+
void rb_grn_init_variable_size_column (VALUE mGrn);
|
189
209
|
void rb_grn_init_index_column (VALUE mGrn);
|
190
210
|
void rb_grn_init_accessor (VALUE mGrn);
|
191
211
|
void rb_grn_init_record (VALUE mGrn);
|
192
212
|
void rb_grn_init_query (VALUE mGrn);
|
213
|
+
void rb_grn_init_variable (VALUE mGrn);
|
214
|
+
void rb_grn_init_operation (VALUE mGrn);
|
215
|
+
void rb_grn_init_expression (VALUE mGrn);
|
216
|
+
void rb_grn_init_expression_builder (VALUE mGrn);
|
193
217
|
void rb_grn_init_logger (VALUE mGrn);
|
194
218
|
void rb_grn_init_snippet (VALUE mGrn);
|
195
219
|
|
@@ -210,6 +234,10 @@ VALUE rb_grn_context_to_exception (grn_ctx *context,
|
|
210
234
|
VALUE related_object);
|
211
235
|
void rb_grn_context_check (grn_ctx *context,
|
212
236
|
VALUE related_object);
|
237
|
+
grn_obj *rb_grn_context_get_backward_compatibility
|
238
|
+
(grn_ctx *context,
|
239
|
+
const char *name,
|
240
|
+
unsigned int name_size);
|
213
241
|
|
214
242
|
const char *rb_grn_inspect (VALUE object);
|
215
243
|
void rb_grn_scan_options (VALUE options, ...)
|
@@ -218,16 +246,17 @@ rb_grn_boolean rb_grn_equal_option (VALUE option,
|
|
218
246
|
const char *key);
|
219
247
|
|
220
248
|
VALUE rb_grn_object_alloc (VALUE klass);
|
221
|
-
void rb_grn_object_bind (
|
249
|
+
void rb_grn_object_bind (VALUE self,
|
250
|
+
VALUE rb_context,
|
251
|
+
RbGrnObject *rb_grn_object,
|
222
252
|
grn_ctx *context,
|
223
|
-
grn_obj *object
|
224
|
-
|
225
|
-
void
|
226
|
-
|
253
|
+
grn_obj *object);
|
254
|
+
void rb_grn_object_free (RbGrnObject *rb_grn_object);
|
255
|
+
void rb_grn_object_assign (VALUE klass,
|
256
|
+
VALUE self,
|
227
257
|
VALUE rb_context,
|
228
258
|
grn_ctx *context,
|
229
|
-
grn_obj *object
|
230
|
-
rb_grn_boolean owner);
|
259
|
+
grn_obj *object);
|
231
260
|
void rb_grn_object_deconstruct (RbGrnObject *rb_grn_object,
|
232
261
|
grn_obj **object,
|
233
262
|
grn_ctx **context,
|
@@ -252,12 +281,12 @@ VALUE rb_grn_object_inspect_content (VALUE object,
|
|
252
281
|
VALUE rb_grn_object_inspect_footer (VALUE object,
|
253
282
|
VALUE inspected);
|
254
283
|
|
255
|
-
VALUE rb_grn_table_alloc (VALUE klass);
|
256
284
|
void rb_grn_table_bind (RbGrnTable *rb_grn_table,
|
257
285
|
grn_ctx *context,
|
258
|
-
grn_obj *table_key_support
|
259
|
-
|
260
|
-
|
286
|
+
grn_obj *table_key_support);
|
287
|
+
void rb_grn_table_finalizer (grn_ctx *context,
|
288
|
+
grn_obj *grn_object,
|
289
|
+
RbGrnTable *rb_grn_table);
|
261
290
|
void rb_grn_table_assign (VALUE self,
|
262
291
|
VALUE rb_context,
|
263
292
|
grn_ctx *context,
|
@@ -293,17 +322,12 @@ grn_ctx *rb_grn_table_cursor_ensure_context (VALUE cursor,
|
|
293
322
|
VALUE *rb_context);
|
294
323
|
VALUE rb_grn_table_cursor_close (VALUE object);
|
295
324
|
|
296
|
-
VALUE rb_grn_table_key_support_alloc (VALUE klass);
|
297
325
|
void rb_grn_table_key_support_bind (RbGrnTableKeySupport *rb_grn_table_key_support,
|
298
326
|
grn_ctx *context,
|
299
|
-
grn_obj *table_key_support
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
VALUE rb_context,
|
304
|
-
grn_ctx *context,
|
305
|
-
grn_obj *table_key_support,
|
306
|
-
rb_grn_boolean owner);
|
327
|
+
grn_obj *table_key_support);
|
328
|
+
void rb_grn_table_key_support_finalizer (grn_ctx *context,
|
329
|
+
grn_obj *grn_object,
|
330
|
+
RbGrnTableKeySupport *rb_grn_table_key_support);
|
307
331
|
void rb_grn_table_key_support_deconstruct (RbGrnTableKeySupport *rb_grn_table_key_support,
|
308
332
|
grn_obj **table_key_support,
|
309
333
|
grn_ctx **context,
|
@@ -316,18 +340,13 @@ void rb_grn_table_key_support_deconstruct (RbGrnTableKeySupport *rb_gr
|
|
316
340
|
grn_id rb_grn_table_key_support_get (VALUE self,
|
317
341
|
VALUE rb_key);
|
318
342
|
|
319
|
-
|
320
|
-
void rb_grn_fix_size_column_bind (RbGrnFixSizeColumn *rb_grn_fix_size_column,
|
321
|
-
grn_ctx *context,
|
322
|
-
grn_obj *column_key_support,
|
323
|
-
rb_grn_boolean owner);
|
324
|
-
void rb_grn_fix_size_column_unbind (RbGrnFixSizeColumn *rb_grn_fix_size_column);
|
325
|
-
void rb_grn_fix_size_column_assign (VALUE self,
|
326
|
-
VALUE rb_context,
|
343
|
+
void rb_grn_column_bind (RbGrnColumn *rb_grn_column,
|
327
344
|
grn_ctx *context,
|
345
|
+
grn_obj *column);
|
346
|
+
void rb_grn_column_finalizer (grn_ctx *context,
|
328
347
|
grn_obj *column,
|
329
|
-
|
330
|
-
void
|
348
|
+
RbGrnColumn *rb_grn_column);
|
349
|
+
void rb_grn_column_deconstruct (RbGrnColumn *rb_grn_column,
|
331
350
|
grn_obj **column,
|
332
351
|
grn_ctx **context,
|
333
352
|
grn_id *domain_id,
|
@@ -336,17 +355,12 @@ void rb_grn_fix_size_column_deconstruct (RbGrnFixSizeColumn *rb_grn_
|
|
336
355
|
grn_id *range_id,
|
337
356
|
grn_obj **range);
|
338
357
|
|
339
|
-
VALUE rb_grn_index_column_alloc (VALUE klass);
|
340
358
|
void rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
|
341
359
|
grn_ctx *context,
|
342
|
-
grn_obj *
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
VALUE rb_context,
|
347
|
-
grn_ctx *context,
|
348
|
-
grn_obj *column,
|
349
|
-
rb_grn_boolean owner);
|
360
|
+
grn_obj *object);
|
361
|
+
void rb_grn_index_column_finalizer (grn_ctx *context,
|
362
|
+
grn_obj *grn_object,
|
363
|
+
RbGrnIndexColumn *rb_grn_index_column);
|
350
364
|
void rb_grn_index_column_deconstruct (RbGrnIndexColumn *rb_grn_index_column,
|
351
365
|
grn_obj **column,
|
352
366
|
grn_ctx **context,
|
@@ -359,10 +373,27 @@ void rb_grn_index_column_deconstruct (RbGrnIndexColumn *rb_grn_in
|
|
359
373
|
grn_obj **id_query,
|
360
374
|
grn_obj **string_query);
|
361
375
|
|
376
|
+
void rb_grn_expression_bind (RbGrnExpression *rb_grn_expression,
|
377
|
+
grn_ctx *context,
|
378
|
+
grn_obj *expression);
|
379
|
+
void rb_grn_expression_finalizer (grn_ctx *context,
|
380
|
+
grn_obj *grn_object,
|
381
|
+
RbGrnExpression *rb_grn_expression);
|
382
|
+
|
362
383
|
VALUE rb_grn_record_new (VALUE table,
|
363
384
|
grn_id id,
|
364
385
|
VALUE values);
|
365
386
|
|
387
|
+
VALUE rb_grn_record_expression_builder_new (VALUE table,
|
388
|
+
VALUE name);
|
389
|
+
VALUE rb_grn_record_expression_builder_build
|
390
|
+
(VALUE self);
|
391
|
+
VALUE rb_grn_column_expression_builder_new (VALUE column,
|
392
|
+
VALUE name,
|
393
|
+
VALUE query);
|
394
|
+
VALUE rb_grn_column_expression_builder_build
|
395
|
+
(VALUE self);
|
396
|
+
|
366
397
|
|
367
398
|
#define RB_GRN_INTERN(string) (ID2SYM(rb_intern(string)))
|
368
399
|
|
@@ -382,6 +413,12 @@ VALUE rb_grn_record_new (VALUE table,
|
|
382
413
|
(rb_grn_object_to_ruby_object(klass, context, object, owner))
|
383
414
|
#define GRNOBJECT2RCLASS(object) (rb_grn_object_to_ruby_class(object))
|
384
415
|
|
416
|
+
/* TODO: MORE BETTER NAME!!! PLEASE!!! */
|
417
|
+
#define RVAL2GRNOBJ(rb_object, context, object) \
|
418
|
+
(rb_grn_obj_from_ruby_object(rb_object, context, object))
|
419
|
+
#define GRNOBJ2RVAL(klass, context, object, related_object) \
|
420
|
+
(rb_grn_obj_to_ruby_object(klass, context, object, related_object))
|
421
|
+
|
385
422
|
#define RVAL2GRNDB(object) (rb_grn_database_from_ruby_object(object))
|
386
423
|
#define GRNDB2RVAL(context, db, owner) \
|
387
424
|
(rb_grn_database_to_ruby_object(context, db, owner))
|
@@ -403,7 +440,7 @@ VALUE rb_grn_record_new (VALUE table,
|
|
403
440
|
#define RVAL2GRNQUERY(object) (rb_grn_query_from_ruby_object(object))
|
404
441
|
#define GRNQUERY2RVAL(context, column)(rb_grn_query_to_ruby_object(context, column))
|
405
442
|
|
406
|
-
#define
|
443
|
+
#define RVAL2GRNOPERATOR(object) (rb_grn_operator_from_ruby_object(object))
|
407
444
|
|
408
445
|
#define RVAL2GRNLOGGER(object) (rb_grn_logger_from_ruby_object(object))
|
409
446
|
|
@@ -436,6 +473,11 @@ VALUE rb_grn_record_new (VALUE table,
|
|
436
473
|
(rb_grn_key_from_ruby_object(object, context, key, domain_id, \
|
437
474
|
domain, related_object))
|
438
475
|
|
476
|
+
#define GRNVARIABLE2RVAL(context, variable) \
|
477
|
+
(rb_grn_variable_to_ruby_object(context, variable))
|
478
|
+
#define RVAL2GRNVARIABLE(object, context) \
|
479
|
+
(rb_grn_variable_from_ruby_object(object, context))
|
480
|
+
|
439
481
|
|
440
482
|
grn_encoding rb_grn_encoding_from_ruby_object (VALUE object,
|
441
483
|
grn_ctx *context);
|
@@ -490,9 +532,7 @@ grn_query *rb_grn_query_from_ruby_object (VALUE object);
|
|
490
532
|
VALUE rb_grn_query_to_ruby_object (grn_ctx *context,
|
491
533
|
grn_query *query);
|
492
534
|
|
493
|
-
|
494
|
-
rb_grn_select_operator_from_ruby_object
|
495
|
-
(VALUE object);
|
535
|
+
grn_operator rb_grn_operator_from_ruby_object (VALUE object);
|
496
536
|
|
497
537
|
grn_logger_info *
|
498
538
|
rb_grn_logger_from_ruby_object (VALUE object);
|
@@ -542,6 +582,19 @@ grn_obj *rb_grn_key_from_ruby_object (VALUE rb_key,
|
|
542
582
|
grn_obj *domain,
|
543
583
|
VALUE related_object);
|
544
584
|
|
585
|
+
VALUE rb_grn_variable_to_ruby_object (grn_ctx *context,
|
586
|
+
grn_obj *variable);
|
587
|
+
grn_obj *rb_grn_variable_from_ruby_object (VALUE rb_variable,
|
588
|
+
grn_ctx **context);
|
589
|
+
|
590
|
+
grn_obj *rb_grn_obj_from_ruby_object (VALUE rb_object,
|
591
|
+
grn_ctx *context,
|
592
|
+
grn_obj **obj);
|
593
|
+
VALUE rb_grn_obj_to_ruby_object (VALUE klass,
|
594
|
+
grn_ctx *context,
|
595
|
+
grn_obj *obj,
|
596
|
+
VALUE related_object);
|
597
|
+
|
545
598
|
RB_GRN_END_DECLS
|
546
599
|
|
547
600
|
#endif
|