groonga 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. metadata +38 -227
  2. data/AUTHORS +0 -5
  3. data/NEWS.ja.rdoc +0 -114
  4. data/NEWS.rdoc +0 -116
  5. data/README.ja.rdoc +0 -63
  6. data/README.rdoc +0 -64
  7. data/Rakefile +0 -216
  8. data/benchmark/common.rb +0 -49
  9. data/benchmark/read-write-many-small-items.rb +0 -144
  10. data/benchmark/write-many-small-items.rb +0 -135
  11. data/example/bookmark.rb +0 -161
  12. data/example/index-html.rb +0 -89
  13. data/example/search/config.ru +0 -211
  14. data/example/search/public/css/groonga.css +0 -122
  15. data/ext/.gitignore +0 -2
  16. data/ext/rb-grn-accessor.c +0 -52
  17. data/ext/rb-grn-array-cursor.c +0 -36
  18. data/ext/rb-grn-array.c +0 -210
  19. data/ext/rb-grn-column.c +0 -570
  20. data/ext/rb-grn-context.c +0 -655
  21. data/ext/rb-grn-database.c +0 -415
  22. data/ext/rb-grn-encoding-support.c +0 -64
  23. data/ext/rb-grn-encoding.c +0 -257
  24. data/ext/rb-grn-exception.c +0 -1110
  25. data/ext/rb-grn-expression-builder.c +0 -75
  26. data/ext/rb-grn-expression.c +0 -732
  27. data/ext/rb-grn-fix-size-column.c +0 -166
  28. data/ext/rb-grn-hash-cursor.c +0 -38
  29. data/ext/rb-grn-hash.c +0 -294
  30. data/ext/rb-grn-index-column.c +0 -488
  31. data/ext/rb-grn-logger.c +0 -325
  32. data/ext/rb-grn-object.c +0 -1335
  33. data/ext/rb-grn-operation.c +0 -198
  34. data/ext/rb-grn-patricia-trie-cursor.c +0 -39
  35. data/ext/rb-grn-patricia-trie.c +0 -488
  36. data/ext/rb-grn-procedure.c +0 -52
  37. data/ext/rb-grn-query.c +0 -260
  38. data/ext/rb-grn-record.c +0 -40
  39. data/ext/rb-grn-snippet.c +0 -328
  40. data/ext/rb-grn-table-cursor-key-support.c +0 -69
  41. data/ext/rb-grn-table-cursor.c +0 -246
  42. data/ext/rb-grn-table-key-support.c +0 -731
  43. data/ext/rb-grn-table.c +0 -2038
  44. data/ext/rb-grn-type.c +0 -181
  45. data/ext/rb-grn-utils.c +0 -769
  46. data/ext/rb-grn-variable-size-column.c +0 -36
  47. data/ext/rb-grn-variable.c +0 -108
  48. data/ext/rb-grn.h +0 -684
  49. data/ext/rb-groonga.c +0 -113
  50. data/extconf.rb +0 -216
  51. data/html/bar.svg +0 -153
  52. data/html/developer.html +0 -121
  53. data/html/developer.svg +0 -469
  54. data/html/download.svg +0 -253
  55. data/html/favicon.ico +0 -0
  56. data/html/favicon.xcf +0 -0
  57. data/html/footer.html.erb +0 -28
  58. data/html/head.html.erb +0 -4
  59. data/html/header.html.erb +0 -17
  60. data/html/index.html +0 -147
  61. data/html/install.svg +0 -636
  62. data/html/logo.xcf +0 -0
  63. data/html/ranguba.css +0 -248
  64. data/html/tutorial.svg +0 -559
  65. data/lib/groonga.rb +0 -83
  66. data/lib/groonga/expression-builder.rb +0 -285
  67. data/lib/groonga/patricia-trie.rb +0 -53
  68. data/lib/groonga/record.rb +0 -276
  69. data/lib/groonga/schema.rb +0 -916
  70. data/license/GPL +0 -340
  71. data/license/LGPL +0 -504
  72. data/license/RUBY +0 -59
  73. data/misc/grnop2ruby.rb +0 -49
  74. data/pkg-config.rb +0 -333
  75. data/src/rb-grn-table-cursor.c +0 -296
  76. data/test-unit/Rakefile +0 -40
  77. data/test-unit/TODO +0 -5
  78. data/test-unit/bin/testrb +0 -5
  79. data/test-unit/html/classic.html +0 -15
  80. data/test-unit/html/index.html +0 -25
  81. data/test-unit/html/index.html.ja +0 -27
  82. data/test-unit/lib/test/unit.rb +0 -323
  83. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  84. data/test-unit/lib/test/unit/assertions.rb +0 -1230
  85. data/test-unit/lib/test/unit/attribute.rb +0 -125
  86. data/test-unit/lib/test/unit/autorunner.rb +0 -353
  87. data/test-unit/lib/test/unit/collector.rb +0 -36
  88. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  89. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  90. data/test-unit/lib/test/unit/collector/load.rb +0 -136
  91. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  92. data/test-unit/lib/test/unit/color-scheme.rb +0 -102
  93. data/test-unit/lib/test/unit/color.rb +0 -96
  94. data/test-unit/lib/test/unit/diff.rb +0 -724
  95. data/test-unit/lib/test/unit/error.rb +0 -130
  96. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  97. data/test-unit/lib/test/unit/failure.rb +0 -136
  98. data/test-unit/lib/test/unit/fixture.rb +0 -176
  99. data/test-unit/lib/test/unit/notification.rb +0 -129
  100. data/test-unit/lib/test/unit/omission.rb +0 -191
  101. data/test-unit/lib/test/unit/pending.rb +0 -150
  102. data/test-unit/lib/test/unit/priority.rb +0 -181
  103. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  104. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  105. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  106. data/test-unit/lib/test/unit/testcase.rb +0 -476
  107. data/test-unit/lib/test/unit/testresult.rb +0 -89
  108. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  109. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  110. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -464
  111. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  112. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -92
  113. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -28
  114. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  115. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  116. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -41
  117. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  118. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  119. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  120. data/test-unit/lib/test/unit/version.rb +0 -7
  121. data/test-unit/sample/adder.rb +0 -13
  122. data/test-unit/sample/subtracter.rb +0 -12
  123. data/test-unit/sample/test_adder.rb +0 -20
  124. data/test-unit/sample/test_subtracter.rb +0 -20
  125. data/test-unit/sample/test_user.rb +0 -23
  126. data/test-unit/test/collector/test-descendant.rb +0 -133
  127. data/test-unit/test/collector/test-load.rb +0 -329
  128. data/test-unit/test/collector/test_dir.rb +0 -406
  129. data/test-unit/test/collector/test_objectspace.rb +0 -100
  130. data/test-unit/test/run-test.rb +0 -15
  131. data/test-unit/test/test-attribute.rb +0 -86
  132. data/test-unit/test/test-color-scheme.rb +0 -67
  133. data/test-unit/test/test-color.rb +0 -47
  134. data/test-unit/test/test-diff.rb +0 -518
  135. data/test-unit/test/test-emacs-runner.rb +0 -60
  136. data/test-unit/test/test-fixture.rb +0 -287
  137. data/test-unit/test/test-notification.rb +0 -33
  138. data/test-unit/test/test-omission.rb +0 -81
  139. data/test-unit/test/test-pending.rb +0 -70
  140. data/test-unit/test/test-priority.rb +0 -119
  141. data/test-unit/test/test-testcase.rb +0 -554
  142. data/test-unit/test/test_assertions.rb +0 -1151
  143. data/test-unit/test/test_error.rb +0 -26
  144. data/test-unit/test/test_failure.rb +0 -33
  145. data/test-unit/test/test_testresult.rb +0 -113
  146. data/test-unit/test/test_testsuite.rb +0 -129
  147. data/test-unit/test/testunit-test-util.rb +0 -14
  148. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  149. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  150. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  151. data/test-unit/test/util/test_observable.rb +0 -102
  152. data/test-unit/test/util/test_procwrapper.rb +0 -36
  153. data/test/.gitignore +0 -1
  154. data/test/groonga-test-utils.rb +0 -106
  155. data/test/run-test.rb +0 -58
  156. data/test/test-array.rb +0 -97
  157. data/test/test-column.rb +0 -298
  158. data/test/test-context.rb +0 -73
  159. data/test/test-database.rb +0 -113
  160. data/test/test-encoding.rb +0 -33
  161. data/test/test-exception.rb +0 -93
  162. data/test/test-expression-builder.rb +0 -156
  163. data/test/test-expression.rb +0 -133
  164. data/test/test-fix-size-column.rb +0 -65
  165. data/test/test-gqtp.rb +0 -70
  166. data/test/test-hash.rb +0 -312
  167. data/test/test-index-column.rb +0 -81
  168. data/test/test-patricia-trie.rb +0 -189
  169. data/test/test-procedure.rb +0 -37
  170. data/test/test-query.rb +0 -22
  171. data/test/test-record.rb +0 -268
  172. data/test/test-remote.rb +0 -53
  173. data/test/test-schema.rb +0 -416
  174. data/test/test-snippet.rb +0 -121
  175. data/test/test-table-cursor.rb +0 -153
  176. data/test/test-table-offset-and-limit.rb +0 -102
  177. data/test/test-table-select-normalize.rb +0 -48
  178. data/test/test-table-select.rb +0 -145
  179. data/test/test-table.rb +0 -642
  180. data/test/test-type.rb +0 -61
  181. data/test/test-variable-size-column.rb +0 -98
  182. data/test/test-variable.rb +0 -28
  183. data/test/test-vector-column.rb +0 -76
  184. data/test/test-version.rb +0 -31
  185. data/text/TUTORIAL.ja.rdoc +0 -392
  186. data/text/expression.rdoc +0 -284
@@ -1,122 +0,0 @@
1
- body
2
- {
3
- background-color: #fff;
4
- color: #000;
5
- }
6
-
7
- div.header
8
- {
9
- display: none;
10
- }
11
-
12
- div.search-box
13
- {
14
- width: 100%;
15
- text-align: center;
16
- }
17
-
18
- div.re-search
19
- {
20
- }
21
-
22
- div.search-summary
23
- {
24
- font-size: small;
25
- border-top: 1px solid #fc3;
26
- background-color: #ffd;
27
- }
28
-
29
- div.search-summary p
30
- {
31
- padding: 3px;
32
- margin: 0;
33
- }
34
-
35
- div.records
36
- {
37
- font-size: smaller;
38
- padding-top: 10px;
39
- padding-left: 30px;
40
- margin-right: 20%;
41
- margin-bottom: 30px;
42
- }
43
-
44
- div.records h2
45
- {
46
- padding: 0;
47
- margin-bottom: 5px;
48
- }
49
-
50
- div.records p
51
- {
52
- }
53
-
54
- p.snippet
55
- {
56
- padding: 0;
57
- margin: 0;
58
- }
59
-
60
- p.snippet span.separator
61
- {
62
- font-weight: bold;
63
- }
64
-
65
- span.keyword,
66
- span.total-entries,
67
- span.display-range
68
- {
69
- font-weight: bold;
70
- }
71
-
72
- div.pagination
73
- {
74
- text-align: center;
75
- margin-bottom: 20px;
76
- }
77
-
78
- p.metadata
79
- {
80
- padding: 0;
81
- margin: 0;
82
- margin-top: 5px;
83
- }
84
-
85
- span.url
86
- {
87
- color: green;
88
- }
89
-
90
- pre
91
- {
92
- overflow: auto;
93
- margin: 20px 30px;
94
- padding: 10px;
95
- border-top: 1px solid #fc3;
96
- background-color: #ffd;
97
- }
98
-
99
- a img
100
- {
101
- border-style: none;
102
- }
103
-
104
- ul.sources li
105
- {
106
- display: inline;
107
- }
108
-
109
- div.footer
110
- {
111
- border-top: 1px solid #fc3;
112
- background-color: #ffd;
113
- margin-top: 5px;
114
- text-align: right;
115
- }
116
-
117
- div.footer p
118
- {
119
- font-size: small;
120
- padding: 0;
121
- margin: 0;
122
- }
data/ext/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.so
2
- *.o
@@ -1,52 +0,0 @@
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) (RVAL2GRNACCESSOR(object))
22
-
23
- VALUE rb_cGrnAccessor;
24
-
25
- grn_obj *
26
- rb_grn_accessor_from_ruby_object (VALUE object)
27
- {
28
- if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnAccessor))) {
29
- rb_raise(rb_eTypeError, "not a groonga accessor");
30
- }
31
-
32
- return RVAL2GRNOBJECT(object, NULL);
33
- }
34
-
35
- VALUE
36
- rb_grn_accessor_to_ruby_object (grn_ctx *context, grn_obj *table,
37
- rb_grn_boolean owner)
38
- {
39
- return GRNOBJECT2RVAL(rb_cGrnAccessor, context, table, owner);
40
- }
41
-
42
- /*
43
- * Document-class: Groonga::Accessor < Groonga::Object
44
- *
45
- * キー、値、スコアなど種々の値へのアクセスをカプセル化した
46
- * オブジェクト。Groonga::Table#columnで取得できる。
47
- */
48
- void
49
- rb_grn_init_accessor (VALUE mGrn)
50
- {
51
- rb_cGrnAccessor = rb_define_class_under(mGrn, "Accessor", rb_cGrnObject);
52
- }
@@ -1,36 +0,0 @@
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
- VALUE rb_cGrnArrayCursor;
22
-
23
- /*
24
- * Document-class: Groonga::ArrayCursor < Groonga::TableCursor
25
- *
26
- * Groonga::Arrayに登録されているレコードを順番に取り出すため
27
- * のオブジェクト。利用できるメソッドはGroonga::TableCursorを
28
- * 参照。
29
- */
30
-
31
- void
32
- rb_grn_init_array_cursor (VALUE mGrn)
33
- {
34
- rb_cGrnArrayCursor =
35
- rb_define_class_under(mGrn, "ArrayCursor", rb_cGrnTableCursor);
36
- }
data/ext/rb-grn-array.c DELETED
@@ -1,210 +0,0 @@
1
- /* -*- c-file-style: "ruby" -*- */
2
- /*
3
- Copyright (C) 2009-2010 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, context) (RVAL2GRNTABLE(object, context))
22
-
23
- VALUE rb_cGrnArray;
24
-
25
- /*
26
- * Document-class: Groonga::Array < Groonga::Table
27
- *
28
- * 各レコードがキーに関連付けられていないテーブル。レコードは
29
- * IDで識別する。
30
- */
31
-
32
- /*
33
- * call-seq:
34
- * Groonga::Array.create(options={}) -> Groonga::Array
35
- * Groonga::Array.create(options={}) {|table| ... }
36
- *
37
- * キーのないテーブルを生成する。ブロックを指定すると、そのブ
38
- * ロックに生成したテーブルが渡され、ブロックを抜けると自動的
39
- * にテーブルが破棄される。
40
- *
41
- * _options_に指定可能な値は以下の通り。
42
- *
43
- * [+:context+]
44
- * テーブルが利用するGroonga::Context。省略すると
45
- * Groonga::Context.defaultを用いる。
46
- *
47
- * [+:name+]
48
- * テーブルの名前。名前をつけると、Groonga::Context#[]に名
49
- * 前を指定してテーブルを取得することができる。省略すると
50
- * 無名テーブルになり、テーブルIDでのみ取得できる。
51
- *
52
- * [+:path+]
53
- * テーブルを保存するパス。パスを指定すると永続テーブルとな
54
- * り、プロセス終了後もレコードは保持される。次回起動時に
55
- * Groonga::Array.openで保存されたレコードを利用することが
56
- * できる。省略すると一時テーブルになり、プロセスが終了する
57
- * とレコードは破棄される。
58
- *
59
- * [+:persistent+]
60
- * +true+を指定すると永続テーブルとなる。+path+を省略した
61
- * 場合は自動的にパスが付加される。+:context+で指定した
62
- * Groonga::Contextに結びついているデータベースが一時デー
63
- * タベースの場合は例外が発生する。
64
- *
65
- * [+:value_type+]
66
- * 値の型を指定する。省略すると値のための領域を確保しない。
67
- * 値を保存したい場合は必ず指定すること。
68
- *
69
- * 参考: Groonga::Type.new
70
- *
71
- * [+:sub_records+]
72
- * +true+を指定すると#groupでグループ化したときに、
73
- * Groonga::Record#n_sub_recordsでグループに含まれるレコー
74
- * ドの件数を取得できる。
75
- *
76
- * 使用例:
77
- *
78
- * 無名一時テーブルを生成する。
79
- * Groonga::Array.create
80
- *
81
- * 無名永続テーブルを生成する。
82
- * Groonga::Array.create(:path => "/tmp/array.grn")
83
- *
84
- * 名前付き永続テーブルを生成する。ただし、ファイル名は気に
85
- * しない。
86
- * Groonga::Array.create(:name => "<bookmarks>",
87
- * :persistent => true)
88
- *
89
- * それぞれのレコードに512バイトの値を格納できる無名一時テー
90
- * ブルを生成する。
91
- * Groonga::Array.create(:value => 512)
92
- */
93
- static VALUE
94
- rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass)
95
- {
96
- grn_ctx *context = NULL;
97
- grn_obj *value_type = NULL, *table;
98
- const char *name = NULL, *path = NULL;
99
- unsigned name_size = 0;
100
- grn_obj_flags flags = GRN_TABLE_NO_KEY;
101
- VALUE rb_table;
102
- VALUE options, rb_context, rb_name, rb_path, rb_persistent;
103
- VALUE rb_value_type, rb_sub_records;
104
-
105
- rb_scan_args(argc, argv, "01", &options);
106
-
107
- rb_grn_scan_options(options,
108
- "context", &rb_context,
109
- "name", &rb_name,
110
- "path", &rb_path,
111
- "persistent", &rb_persistent,
112
- "value_type", &rb_value_type,
113
- "sub_records", &rb_sub_records,
114
- NULL);
115
-
116
- context = rb_grn_context_ensure(&rb_context);
117
-
118
- if (!NIL_P(rb_name)) {
119
- name = StringValuePtr(rb_name);
120
- name_size = RSTRING_LEN(rb_name);
121
- flags |= GRN_OBJ_PERSISTENT;
122
- }
123
-
124
- if (!NIL_P(rb_path)) {
125
- path = StringValueCStr(rb_path);
126
- flags |= GRN_OBJ_PERSISTENT;
127
- }
128
-
129
- if (RVAL2CBOOL(rb_persistent))
130
- flags |= GRN_OBJ_PERSISTENT;
131
-
132
- if (!NIL_P(rb_value_type))
133
- value_type = RVAL2GRNOBJECT(rb_value_type, &context);
134
-
135
- if (RVAL2CBOOL(rb_sub_records))
136
- flags |= GRN_OBJ_WITH_SUBREC;
137
-
138
- table = grn_table_create(context, name, name_size, path,
139
- flags, NULL, value_type);
140
- if (!table)
141
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
142
- rb_table = GRNOBJECT2RVAL(klass, context, table, RB_GRN_TRUE);
143
- rb_grn_context_check(context, rb_table);
144
- rb_iv_set(rb_table, "@context", rb_context);
145
-
146
- if (rb_block_given_p())
147
- return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
148
- else
149
- return rb_table;
150
- }
151
-
152
- /*
153
- * call-seq:
154
- * array.add(values=nil) -> Groonga::Recordまたはnil
155
- *
156
- * レコード追加し、追加したレコードを返す。レコードの追加に失
157
- * 敗した場合は+nil+を返す。
158
- *
159
- * _values_にはレコードのカラムに設定する値を指定する。省略
160
- * した場合または+nil+を指定した場合はカラムは設定しない。カ
161
- * ラムの値は<tt>{:カラム名1 => 値1, :カラム名2 => 値2,
162
- * ...}</tt>と指定する。
163
- *
164
- * 使用例では、以下のようなユーザを格納するGroonga::Arrayが
165
- * 定義されているものとする。
166
- * users = Groonga::Array.create(:name => "Users")
167
- * users.define_column("name", "ShortText")
168
- * users.define_column("uri", "ShortText")
169
- *
170
- * ユーザを追加する。
171
- * user = users.add
172
- *
173
- * daijiroユーザを追加する。
174
- * daijiro = users.add(:name => "daijiro")
175
- *
176
- * gunyara-kunユーザを追加する。
177
- * gunyara_kun = users.add(:name => "gunyara-kun",
178
- * :uri => "http://d.hatena.ne.jp/tasukuchan/")
179
- */
180
- static VALUE
181
- rb_grn_array_add (int argc, VALUE *argv, VALUE self)
182
- {
183
- grn_ctx *context = NULL;
184
- grn_obj *table;
185
- grn_id id;
186
- VALUE values;
187
-
188
- rb_scan_args(argc, argv, "01", &values);
189
-
190
- table = SELF(self, &context);
191
-
192
- id = grn_table_add(context, table, NULL, 0, NULL);
193
- rb_grn_context_check(context, self);
194
-
195
- if (GRN_ID_NIL == id)
196
- return Qnil;
197
- else
198
- return rb_grn_record_new(self, id, values);
199
- }
200
-
201
- void
202
- rb_grn_init_array (VALUE mGrn)
203
- {
204
- rb_cGrnArray = rb_define_class_under(mGrn, "Array", rb_cGrnTable);
205
-
206
- rb_define_singleton_method(rb_cGrnArray, "create",
207
- rb_grn_array_s_create, -1);
208
-
209
- rb_define_method(rb_cGrnArray, "add", rb_grn_array_add, -1);
210
- }
data/ext/rb-grn-column.c DELETED
@@ -1,570 +0,0 @@
1
- /* -*- c-file-style: "ruby" -*- */
2
- /* vim: set sts=4 sw=4 ts=8 noet: */
3
- /*
4
- Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
5
-
6
- This library is free software; you can redistribute it and/or
7
- modify it under the terms of the GNU Lesser General Public
8
- License version 2.1 as published by the Free Software Foundation.
9
-
10
- This library is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- Lesser General Public License for more details.
14
-
15
- You should have received a copy of the GNU Lesser General Public
16
- License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- */
19
-
20
- #include "rb-grn.h"
21
-
22
- #define SELF(object) ((RbGrnColumn *)DATA_PTR(object))
23
-
24
- VALUE rb_cGrnColumn;
25
-
26
- /*
27
- * Document-class: Groonga::Column < Groonga::Object
28
- *
29
- * テーブルに情報を付加するためのオブジェクト。テーブルに複
30
- * 数のカラムを定義することによりレコード毎に複数の情報を付
31
- * 加することができる。
32
- *
33
- * カラムには大きく分けて3種類ある。
34
- * [Groonga::FixSizeColumn]
35
- * 固定長のデータを格納するカラム。
36
- * [Groonga::VariableSizeColumn]
37
- * 可変長のデータを格納するカラム。
38
- * [Groonga::IndexColumn]
39
- * 転置インデックスを格納するカラム。全文検索や参照元レコー
40
- * ドの検索を行う場合はこのカラムを使用する。
41
- *
42
- * 固定長データ用カラム・可変長データ用カラムは1つのデータだ
43
- * けを格納するか複数のデータを格納するかを選ぶことができる。
44
- * 1つのデータの場合はスカラ値、複数のデータの場合はスカラー
45
- * 値を格納するという。
46
- *
47
- * カラムは名前を持ち、1つのテーブルでは同じカラム名を持つカ
48
- * ラムを複数定義することはできない。
49
- */
50
-
51
- grn_obj *
52
- rb_grn_column_from_ruby_object (VALUE object, grn_ctx **context)
53
- {
54
- if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnColumn))) {
55
- rb_raise(rb_eTypeError, "not a groonga column");
56
- }
57
-
58
- return RVAL2GRNOBJECT(object, context);
59
- }
60
-
61
- VALUE
62
- rb_grn_column_to_ruby_object (VALUE klass, grn_ctx *context, grn_obj *column,
63
- rb_grn_boolean owner)
64
- {
65
- return GRNOBJECT2RVAL(klass, context, column, owner);
66
- }
67
-
68
- void
69
- rb_grn_column_bind (RbGrnColumn *rb_column,
70
- grn_ctx *context, grn_obj *column)
71
- {
72
- RbGrnObject *rb_grn_object;
73
-
74
- rb_grn_object = RB_GRN_OBJECT(rb_column);
75
- rb_grn_named_object_bind(RB_GRN_NAMED_OBJECT(rb_column), context, column);
76
- rb_column->value = grn_obj_open(context, GRN_BULK, 0,
77
- rb_grn_object->range_id);
78
- }
79
-
80
- void
81
- rb_grn_column_finalizer (grn_ctx *context, grn_obj *grn_object,
82
- RbGrnColumn *rb_column)
83
- {
84
- rb_grn_named_object_finalizer(context, grn_object,
85
- RB_GRN_NAMED_OBJECT(rb_column));
86
- if (context && rb_column->value)
87
- grn_obj_close(context, rb_column->value);
88
- rb_column->value = NULL;
89
- }
90
-
91
- void
92
- rb_grn_column_deconstruct (RbGrnColumn *rb_column,
93
- grn_obj **column,
94
- grn_ctx **context,
95
- grn_id *domain_id,
96
- grn_obj **domain,
97
- grn_obj **value,
98
- grn_id *range_id,
99
- grn_obj **range)
100
- {
101
- RbGrnObject *rb_grn_object;
102
-
103
- rb_grn_object = RB_GRN_OBJECT(rb_column);
104
- rb_grn_object_deconstruct(rb_grn_object, column, context,
105
- domain_id, domain,
106
- range_id, range);
107
-
108
- if (value)
109
- *value = rb_column->value;
110
- }
111
-
112
- /*
113
- * call-seq:
114
- * column.table -> Groonga::Table
115
- *
116
- * カラムが所属するテーブルを返す。
117
- */
118
- static VALUE
119
- rb_grn_column_get_table (VALUE self)
120
- {
121
- grn_ctx *context = NULL;
122
- grn_obj *column;
123
- grn_obj *table;
124
-
125
- rb_grn_object_deconstruct((RbGrnObject *)(SELF(self)), &column, &context,
126
- NULL, NULL,
127
- NULL, NULL);
128
- table = grn_column_table(context, column);
129
- rb_grn_context_check(context, self);
130
-
131
- return GRNOBJECT2RVAL(Qnil, context, table, RB_GRN_FALSE);
132
- }
133
-
134
- /*
135
- * call-seq:
136
- * column.local_name
137
- *
138
- * テーブル名を除いたカラム名を返す。
139
- *
140
- * items = Groonga::Array.create(:name => "Items")
141
- * title = items.define_column("title", "ShortText")
142
- * title.name # => "Items.title"
143
- * title.local_name # => "title"
144
- */
145
- static VALUE
146
- rb_grn_column_get_local_name (VALUE self)
147
- {
148
- RbGrnColumn *rb_grn_column;
149
- grn_ctx *context = NULL;
150
- grn_obj *column;
151
- int name_size;
152
- VALUE rb_name;
153
-
154
- rb_grn_column = SELF(self);
155
- rb_grn_object_deconstruct(RB_GRN_OBJECT(rb_grn_column), &column, &context,
156
- NULL, NULL,
157
- NULL, NULL);
158
- name_size = grn_column_name(context, column, NULL, 0);
159
- if (name_size == 0)
160
- return Qnil;
161
-
162
- rb_name = rb_str_buf_new(name_size);
163
- rb_str_set_len(rb_name, name_size);
164
- grn_column_name(context, column, RSTRING_PTR(rb_name), name_size);
165
- return rb_name;
166
- }
167
-
168
- /*
169
- * call-seq:
170
- * column.select(options) {|record| ...} -> Groonga::Hash
171
- * column.select(query, options) -> Groonga::Hash
172
- * column.select(expression, options) -> Groonga::Hash
173
- *
174
- * カラムが所属するテーブルからブロックまたは文字列で指定し
175
- * た条件にマッチするレコードを返す。返されたテーブルには
176
- * +expression+という特異メソッドがあり、指定した条件を表し
177
- * ているGroonga::Expressionを取得できる。
178
- * Groonga::Expression#snippetを使うことにより、指定した条件
179
- * 用のスニペットを簡単に生成できる。
180
- *
181
- * results = description_column.select do |column|
182
- * column =~ "groonga"
183
- * end
184
- * snippet = results.expression.snippet([["<em>", "</em>"]])
185
- * results.each do |record|
186
- * puts "#{record['name']}の説明文の中で「groonga」が含まれる部分"
187
- * snippet.execute(record["description"].each do |snippet|
188
- * puts "---"
189
- * puts "#{snippet}..."
190
- * puts "---"
191
- * end
192
- * end
193
- *
194
- * 出力例
195
- * Ruby/groongaの説明文の中で「groonga」が含まれる部分
196
- * ---
197
- * Ruby/<em>groonga</em>は<em>groonga</em>のいわゆるDB-APIの層の...
198
- * ---
199
- *
200
- * _query_には「[カラム名]:[演算子][値]」という書式で条件を
201
- * 指定する。演算子は以下の通り。
202
- *
203
- * [なし]
204
- * [カラム値] == [値]
205
- * [<tt>!</tt>]
206
- * [カラム値] != [値]
207
- * [<tt><</tt>]
208
- * [カラム値] < [値]
209
- * [<tt>></tt>]
210
- * [カラム値] > [値]
211
- * [<tt><=</tt>]
212
- * [カラム値] <= [値]
213
- * [<tt>>=</tt>]
214
- * [カラム値] >= [値]
215
- * [<tt>@</tt>]
216
- * [カラム値]が[値]を含んでいるかどうか
217
- *
218
- * 例:
219
- * "groonga" # _column_カラムの値が"groonga"のレコードにマッチ
220
- * "name:daijiro" # _column_カラムが属しているテーブルの
221
- * # "name"カラムの値が"daijiro"のレコードにマッチ
222
- * "description:@groonga" # _column_カラムが属しているテーブルの
223
- * # "description"カラムが
224
- * # "groonga"を含んでいるレコードにマッチ
225
- *
226
- * _expression_には既に作成済みのGroonga::Expressionを渡す
227
- *
228
- * ブロックで条件を指定する場合は
229
- * Groonga::ColumnExpressionBuilderを参照。
230
- *
231
- * _options_に指定可能な値は以下の通り。
232
- *
233
- * [+:operator+]
234
- * マッチしたレコードをどのように扱うか。指定可能な値は以
235
- * 下の通り。省略した場合はGroonga::Operation::OR。
236
- *
237
- * [Groonga::Operation::OR]
238
- * マッチしたレコードを追加。すでにレコードが追加され
239
- * ている場合は何もしない。
240
- * [Groonga::Operation::AND]
241
- * マッチしたレコードのスコアを増加。マッチしなかった
242
- * レコードを削除。
243
- * [Groonga::Operation::BUT]
244
- * マッチしたレコードを削除。
245
- * [Groonga::Operation::ADJUST]
246
- * マッチしたレコードのスコアを増加。
247
- *
248
- * [+:result+]
249
- * 検索結果を格納するテーブル。マッチしたレコードが追加さ
250
- * れていく。省略した場合は新しくテーブルを作成して返す。
251
- *
252
- * [+:name+]
253
- * 条件の名前。省略した場合は名前を付けない。
254
- *
255
- * [+:syntax+]
256
- * _query_の構文。省略した場合は+:query+。
257
- *
258
- * 参考: Groonga::Expression#parse.
259
- *
260
- * [+:allow_pragma+]
261
- * query構文時にプラグマを利用するかどうか。省略した場合は
262
- * 利用する。
263
- *
264
- * 参考: Groonga::Expression#parse.
265
- *
266
- * [+:allow_column+]
267
- * query構文時にカラム指定を利用するかどうか。省略した場合
268
- * は利用する。
269
- *
270
- * 参考: Groonga::Expression#parse.
271
- *
272
- * [+:allow_update+]
273
- * script構文時に更新操作を利用するかどうか。省略した場合
274
- * は利用する。
275
- *
276
- * 参考: Groonga::Expression#parse.
277
- */
278
- static VALUE
279
- rb_grn_column_select (int argc, VALUE *argv, VALUE self)
280
- {
281
- grn_ctx *context;
282
- grn_obj *table, *column, *result, *expression;
283
- grn_operator operator = GRN_OP_OR;
284
- VALUE options;
285
- VALUE rb_query, condition_or_options;
286
- VALUE rb_name, rb_operator, rb_result, rb_syntax;
287
- VALUE rb_allow_pragma, rb_allow_column, rb_allow_update;
288
- VALUE builder;
289
- VALUE rb_expression = Qnil;
290
-
291
- rb_query = Qnil;
292
-
293
- rb_scan_args(argc, argv, "02", &condition_or_options, &options);
294
-
295
- rb_grn_column_deconstruct(SELF(self), &column, &context,
296
- NULL, NULL,
297
- NULL, NULL, NULL);
298
- table = grn_column_table(context, column);
299
-
300
- if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options, rb_cString))) {
301
- rb_query = condition_or_options;
302
- } else if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options,
303
- rb_cGrnExpression))) {
304
- rb_expression = condition_or_options;
305
- } else {
306
- if (!NIL_P(options))
307
- rb_raise(rb_eArgError,
308
- "should be [query_string, option_hash], "
309
- "[expression, opion_hash] "
310
- "or [option_hash]: %s",
311
- rb_grn_inspect(rb_ary_new4(argc, argv)));
312
- options = condition_or_options;
313
- }
314
-
315
- rb_grn_scan_options(options,
316
- "operator", &rb_operator,
317
- "result", &rb_result,
318
- "name", &rb_name,
319
- "syntax", &rb_syntax,
320
- "allow_pragma", &rb_allow_pragma,
321
- "allow_column", &rb_allow_column,
322
- "allow_update", &rb_allow_update,
323
- NULL);
324
-
325
- if (!NIL_P(rb_operator))
326
- operator = NUM2INT(rb_operator);
327
-
328
- if (NIL_P(rb_result)) {
329
- result = grn_table_create(context, NULL, 0, NULL,
330
- GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
331
- table,
332
- 0);
333
- rb_result = GRNTABLE2RVAL(context, result, RB_GRN_TRUE);
334
- } else {
335
- result = RVAL2GRNTABLE(rb_result, &context);
336
- }
337
-
338
- if (NIL_P(rb_expression)) {
339
- builder = rb_grn_column_expression_builder_new(self, rb_name, rb_query);
340
- rb_funcall(builder, rb_intern("syntax="), 1, rb_syntax);
341
- rb_funcall(builder, rb_intern("allow_pragma="), 1, rb_allow_pragma);
342
- rb_funcall(builder, rb_intern("allow_column="), 1, rb_allow_column);
343
- rb_funcall(builder, rb_intern("allow_update="), 1, rb_allow_update);
344
- rb_expression = rb_grn_column_expression_builder_build(builder);
345
- }
346
- rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
347
- &expression, NULL,
348
- NULL, NULL, NULL, NULL);
349
-
350
- grn_table_select(context, table, expression, result, operator);
351
- rb_grn_context_check(context, self);
352
-
353
- rb_attr(rb_singleton_class(rb_result),
354
- rb_intern("expression"),
355
- RB_GRN_TRUE, RB_GRN_FALSE, RB_GRN_FALSE);
356
- rb_iv_set(rb_result, "@expression", rb_expression);
357
-
358
- return rb_result;
359
- }
360
-
361
- /*
362
- * Document-method: unlock
363
- *
364
- * call-seq:
365
- * column.unlock(options={})
366
- *
367
- * _column_のロックを解除する。
368
- *
369
- * 利用可能なオプションは以下の通り。
370
- *
371
- * [_:id_]
372
- * _:id_で指定したレコードのロックを解除する。(注:
373
- * groonga側が未実装のため、現在は無視される)
374
- */
375
- static VALUE
376
- rb_grn_column_unlock (int argc, VALUE *argv, VALUE self)
377
- {
378
- grn_id id = GRN_ID_NIL;
379
- grn_ctx *context;
380
- grn_obj *column;
381
- grn_rc rc;
382
- VALUE options, rb_id;
383
-
384
- rb_scan_args(argc, argv, "01", &options);
385
-
386
- rb_grn_column_deconstruct(SELF(self), &column, &context,
387
- NULL, NULL,
388
- NULL, NULL, NULL);
389
-
390
- rb_grn_scan_options(options,
391
- "id", &rb_id,
392
- NULL);
393
-
394
- if (!NIL_P(rb_id))
395
- id = NUM2UINT(rb_id);
396
-
397
- rc = grn_obj_unlock(context, column, id);
398
- rb_grn_context_check(context, self);
399
- rb_grn_rc_check(rc, self);
400
-
401
- return Qnil;
402
- }
403
-
404
- static VALUE
405
- rb_grn_column_unlock_ensure (VALUE self)
406
- {
407
- return rb_grn_column_unlock(0, NULL, self);
408
- }
409
-
410
- /*
411
- * Document-method: lock
412
- *
413
- * call-seq:
414
- * column.lock(options={})
415
- * column.lock(options={}) {...}
416
- *
417
- * _column_をロックする。ロックに失敗した場合は
418
- * Groonga::ResourceDeadlockAvoided例外が発生する。
419
- *
420
- * ブロックを指定した場合はブロックを抜けたときにunlockする。
421
- *
422
- * 利用可能なオプションは以下の通り。
423
- *
424
- * [_:timeout_]
425
- * ロックを獲得できなかった場合は_:timeout_秒間ロックの獲
426
- * 得を試みる。_:timeout_秒以内にロックを獲得できなかった
427
- * 場合は例外が発生する。
428
- * [_:id_]
429
- * _:id_で指定したレコードをロックする。(注: groonga側が
430
- * 未実装のため、現在は無視される)
431
- */
432
- static VALUE
433
- rb_grn_column_lock (int argc, VALUE *argv, VALUE self)
434
- {
435
- grn_id id = GRN_ID_NIL;
436
- grn_ctx *context;
437
- grn_obj *column;
438
- int timeout = 0;
439
- grn_rc rc;
440
- VALUE options, rb_timeout, rb_id;
441
-
442
- rb_scan_args(argc, argv, "01", &options);
443
-
444
- rb_grn_column_deconstruct(SELF(self), &column, &context,
445
- NULL, NULL,
446
- NULL, NULL, NULL);
447
-
448
- rb_grn_scan_options(options,
449
- "timeout", &rb_timeout,
450
- "id", &rb_id,
451
- NULL);
452
-
453
- if (!NIL_P(rb_timeout))
454
- timeout = NUM2UINT(rb_timeout);
455
-
456
- if (!NIL_P(rb_id))
457
- id = NUM2UINT(rb_id);
458
-
459
- rc = grn_obj_lock(context, column, id, timeout);
460
- rb_grn_context_check(context, self);
461
- rb_grn_rc_check(rc, self);
462
-
463
- if (rb_block_given_p()) {
464
- return rb_ensure(rb_yield, Qnil, rb_grn_column_unlock_ensure, self);
465
- } else {
466
- return Qnil;
467
- }
468
- }
469
-
470
- /*
471
- * Document-method: clear_lock
472
- *
473
- * call-seq:
474
- * column.clear_lock(options={})
475
- *
476
- * _column_のロックを強制的に解除する。
477
- *
478
- * 利用可能なオプションは以下の通り。
479
- *
480
- * [_:id_]
481
- * _:id_で指定したレコードのロックを強制的に解除する。
482
- * (注: groonga側が未実装のため、現在は無視される。実装さ
483
- * れるのではないかと思っているが、実装されないかもしれな
484
- * い。)
485
- */
486
- static VALUE
487
- rb_grn_column_clear_lock (int argc, VALUE *argv, VALUE self)
488
- {
489
- grn_id id = GRN_ID_NIL;
490
- grn_ctx *context;
491
- grn_obj *column;
492
- VALUE options, rb_id;
493
-
494
- rb_scan_args(argc, argv, "01", &options);
495
-
496
- rb_grn_column_deconstruct(SELF(self), &column, &context,
497
- NULL, NULL,
498
- NULL, NULL, NULL);
499
-
500
- rb_grn_scan_options(options,
501
- "id", &rb_id,
502
- NULL);
503
-
504
- if (!NIL_P(rb_id))
505
- id = NUM2UINT(rb_id);
506
-
507
- grn_obj_clear_lock(context, column);
508
-
509
- return Qnil;
510
- }
511
-
512
- /*
513
- * Document-method: locked?
514
- *
515
- * call-seq:
516
- * column.locked?(options={})
517
- *
518
- * _column_がロックされていれば+true+を返す。
519
- *
520
- * 利用可能なオプションは以下の通り。
521
- *
522
- * [_:id_]
523
- * _:id_で指定したレコードがロックされていれば+true+を返す。
524
- * (注: groonga側が未実装のため、現在は無視される。実装さ
525
- * れるのではないかと思っているが、実装されないかもしれな
526
- * い。)
527
- */
528
- static VALUE
529
- rb_grn_column_is_locked (int argc, VALUE *argv, VALUE self)
530
- {
531
- grn_id id = GRN_ID_NIL;
532
- grn_ctx *context;
533
- grn_obj *column;
534
- VALUE options, rb_id;
535
-
536
- rb_scan_args(argc, argv, "01", &options);
537
-
538
- rb_grn_column_deconstruct(SELF(self), &column, &context,
539
- NULL, NULL,
540
- NULL, NULL, NULL);
541
-
542
- rb_grn_scan_options(options,
543
- "id", &rb_id,
544
- NULL);
545
-
546
- if (!NIL_P(rb_id))
547
- id = NUM2UINT(rb_id);
548
-
549
- return CBOOL2RVAL(grn_obj_is_locked(context, column));
550
- }
551
-
552
- void
553
- rb_grn_init_column (VALUE mGrn)
554
- {
555
- rb_cGrnColumn = rb_define_class_under(mGrn, "Column", rb_cGrnObject);
556
-
557
- rb_define_method(rb_cGrnColumn, "table", rb_grn_column_get_table, 0);
558
- rb_define_method(rb_cGrnColumn, "local_name",
559
- rb_grn_column_get_local_name, 0);
560
-
561
- rb_define_method(rb_cGrnColumn, "select", rb_grn_column_select, -1);
562
- rb_define_method(rb_cGrnColumn, "lock", rb_grn_column_lock, -1);
563
- rb_define_method(rb_cGrnColumn, "unlock", rb_grn_column_unlock, -1);
564
- rb_define_method(rb_cGrnColumn, "clear_lock", rb_grn_column_clear_lock, -1);
565
- rb_define_method(rb_cGrnColumn, "locked?", rb_grn_column_is_locked, -1);
566
-
567
- rb_grn_init_fix_size_column(mGrn);
568
- rb_grn_init_variable_size_column(mGrn);
569
- rb_grn_init_index_column(mGrn);
570
- }