rroonga 2.0.5 → 2.0.6
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.
- data/Rakefile +5 -1
- data/ext/groonga/extconf.rb +36 -4
- data/ext/groonga/rb-grn-accessor.c +8 -10
- data/ext/groonga/rb-grn-array-cursor.c +2 -2
- data/ext/groonga/rb-grn-array.c +35 -59
- data/ext/groonga/rb-grn-column.c +105 -192
- data/ext/groonga/rb-grn-context.c +60 -63
- data/ext/groonga/rb-grn-database.c +27 -37
- data/ext/groonga/rb-grn-double-array-trie-cursor.c +3 -3
- data/ext/groonga/rb-grn-double-array-trie.c +75 -126
- data/ext/groonga/rb-grn-encoding.c +27 -27
- data/ext/groonga/rb-grn-expression.c +29 -24
- data/ext/groonga/rb-grn-fix-size-column.c +7 -9
- data/ext/groonga/rb-grn-hash-cursor.c +3 -3
- data/ext/groonga/rb-grn-hash.c +57 -108
- data/ext/groonga/rb-grn-index-column.c +17 -29
- data/ext/groonga/rb-grn-logger.c +11 -14
- data/ext/groonga/rb-grn-object.c +51 -94
- data/ext/groonga/rb-grn-patricia-trie-cursor.c +2 -2
- data/ext/groonga/rb-grn-patricia-trie.c +161 -276
- data/ext/groonga/rb-grn-plugin.c +6 -10
- data/ext/groonga/rb-grn-table-cursor.c +14 -21
- data/ext/groonga/rb-grn-table-key-support.c +32 -35
- data/ext/groonga/rb-grn-table.c +149 -252
- data/ext/groonga/rb-grn-variable.c +6 -7
- data/ext/groonga/rb-grn-view-accessor.c +1 -1
- data/ext/groonga/rb-grn-view-cursor.c +2 -2
- data/ext/groonga/rb-grn-view.c +28 -45
- data/ext/groonga/rb-grn.h +1 -1
- data/ext/groonga/rb-groonga.c +6 -6
- data/lib/groonga/database.rb +1 -1
- data/lib/groonga/dumper.rb +109 -33
- data/lib/groonga/expression-builder.rb +24 -0
- data/lib/groonga/pagination.rb +30 -24
- data/lib/groonga/record.rb +21 -18
- data/lib/groonga/schema.rb +156 -140
- data/test/test-command-select.rb +66 -1
- data/test/test-database-dumper.rb +50 -10
- data/test/test-expression-builder.rb +41 -0
- metadata +4 -4
data/lib/groonga/pagination.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
module Groonga
|
19
19
|
class TooSmallPage < Error
|
20
|
-
# Table#paginate で小さすぎるページ番号を指定した場合に
|
20
|
+
# {Table#paginate} で小さすぎるページ番号を指定した場合に
|
21
21
|
# 発生する。
|
22
22
|
|
23
23
|
# 指定したページ番号。
|
@@ -33,7 +33,7 @@ module Groonga
|
|
33
33
|
end
|
34
34
|
|
35
35
|
class TooLargePage < Error
|
36
|
-
# Table#paginate で大きすぎるページ番号を指定した場合に
|
36
|
+
# {Table#paginate} で大きすぎるページ番号を指定した場合に
|
37
37
|
# 発生する。
|
38
38
|
|
39
39
|
# 指定したページ番号。
|
@@ -49,7 +49,7 @@ module Groonga
|
|
49
49
|
end
|
50
50
|
|
51
51
|
class TooSmallPageSize < Error
|
52
|
-
# Table#paginate で小さすぎるページサイズを指定した場合
|
52
|
+
# {Table#paginate} で小さすぎるページサイズを指定した場合
|
53
53
|
# に発生する。
|
54
54
|
|
55
55
|
# 指定したページサイズ。
|
@@ -67,42 +67,48 @@ module Groonga
|
|
67
67
|
class Table
|
68
68
|
|
69
69
|
# ページネーション用便利メソッド。ページネーションをした
|
70
|
-
# い場合は #sort よりも #paginate の方が便利。
|
70
|
+
# い場合は {#sort} よりも #paginate の方が便利。
|
71
71
|
#
|
72
72
|
# 説明文(descriptionカラム)を「Ruby」で全文検索し、
|
73
73
|
# 検索結果をスコアの高い順にソートして、10項目ずつ表示する
|
74
74
|
# 場合は以下のようになる。
|
75
75
|
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
76
|
+
# <pre>
|
77
|
+
# !!!ruby
|
78
|
+
# query = "Ruby"
|
79
|
+
# entries = Groonga["entries"]
|
80
|
+
# selected_entries = entries.select do |record|
|
81
|
+
# entry.description =~ query
|
82
|
+
# end
|
83
|
+
# paged_entries = selected_entries.paginate([["_score", :desc]],
|
84
|
+
# :page => 1,
|
85
|
+
# :size => 10)
|
86
|
+
# </pre>
|
84
87
|
#
|
85
|
-
# #sort と違い、返されるTableオブジェクトには
|
86
|
-
# モジュールがextend
|
87
|
-
#
|
88
|
+
# {#sort} と違い、返される {Table} オブジェクトには
|
89
|
+
# {Pagination} モジュールがextendされており、
|
90
|
+
# 以下のようにページネーション情報を取得できる。
|
88
91
|
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
92
|
+
# <pre>
|
93
|
+
# !!!ruby
|
94
|
+
# puts "#{paged_entries.n_records}件ヒット"
|
95
|
+
# puts "#{paged_entries.start_offset}-#{paged_entries.end_offset}件を表示"
|
96
|
+
# paged_entries.each do |entry|
|
97
|
+
# puts entry.description
|
98
|
+
# end
|
99
|
+
# </pre>
|
94
100
|
#
|
95
101
|
# _sort_keys_ には ソートに用いる情報を指定する。
|
96
|
-
# 指定の仕方は #sort と同様なので、詳細は #sort を参照。
|
102
|
+
# 指定の仕方は {#sort} と同様なので、詳細は {#sort} を参照。
|
97
103
|
#
|
98
104
|
# _options_ に指定可能な値は以下の通り。
|
99
105
|
#
|
100
106
|
# @param [::Hash] options The name and value
|
101
107
|
# pairs. Omitted names are initialized as the default value.
|
102
|
-
# @option options [Integer] :size (10)
|
108
|
+
# @option options [Integer] :size (10)
|
103
109
|
#
|
104
110
|
# 1ページあたりに表示する最大項目数。
|
105
|
-
# @option options [Integer] :page (1)
|
111
|
+
# @option options [Integer] :page (1)
|
106
112
|
#
|
107
113
|
# ページ番号。ページ番号は0ベースではなく1ベースであることに注意。
|
108
114
|
def paginate(sort_keys, options={})
|
@@ -220,7 +226,7 @@ module Groonga
|
|
220
226
|
|
221
227
|
# 最初のページから最後のページまでを含んだRangeを返す。
|
222
228
|
#
|
223
|
-
#
|
229
|
+
# @example 10ページある場合は以下を返す。
|
224
230
|
# 1..10
|
225
231
|
def pages
|
226
232
|
first_page..last_page
|
data/lib/groonga/record.rb
CHANGED
@@ -21,14 +21,17 @@ module Groonga
|
|
21
21
|
class Record
|
22
22
|
# レコードが所属するテーブル
|
23
23
|
attr_reader :table
|
24
|
-
# _table_ の _id_ に対応するレコードを作成する。_values_ には各
|
24
|
+
# _table_ の _id_ に対応するレコードを作成する。 _values_ には各
|
25
25
|
# カラムに設定する値を以下のような形式で指定する。
|
26
26
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
27
|
+
# <pre>
|
28
|
+
# !!!ruby
|
29
|
+
# [
|
30
|
+
# ["カラム名", 値],
|
31
|
+
# ["カラム名", 値],
|
32
|
+
# ...,
|
33
|
+
# ]
|
34
|
+
# </pre>
|
32
35
|
def initialize(table, id, values=nil)
|
33
36
|
@table = table
|
34
37
|
@id = id
|
@@ -48,7 +51,7 @@ module Groonga
|
|
48
51
|
[table, id] == [other.table, other.id]
|
49
52
|
end
|
50
53
|
|
51
|
-
# Groonga::Record
|
54
|
+
# {Groonga::Record#==} と同じ。
|
52
55
|
def eql?(other)
|
53
56
|
self == other
|
54
57
|
end
|
@@ -100,35 +103,35 @@ module Groonga
|
|
100
103
|
end
|
101
104
|
|
102
105
|
# 名前が _name_ のカラムが索引カラム
|
103
|
-
# (Groonga::IndexColumn)であるなら +true+ を返す。
|
106
|
+
# ( {Groonga::IndexColumn} )であるなら +true+ を返す。
|
104
107
|
def index_column?(name)
|
105
108
|
column(name).index?
|
106
109
|
end
|
107
110
|
|
108
111
|
# 名前が _name_ のカラムの値がベクターであるなら +true+ を返す。
|
109
112
|
#
|
110
|
-
# @since
|
113
|
+
# @since 1.0.5
|
111
114
|
def vector_column?(name)
|
112
115
|
column(name).vector?
|
113
116
|
end
|
114
117
|
|
115
118
|
# 名前が _name_ のカラムの値がスカラーであるなら +true+ を返す。
|
116
119
|
#
|
117
|
-
# @since
|
120
|
+
# @since 1.0.5
|
118
121
|
def scalar_column?(name)
|
119
122
|
column(name).scalar?
|
120
123
|
end
|
121
124
|
|
122
|
-
# 名前が _name_ のGroonga::IndexColumnの search メソッドを呼ぶ。
|
125
|
+
# 名前が _name_ の {Groonga::IndexColumn} の search メソッドを呼ぶ。
|
123
126
|
# _query_ と _options_ はそのメソッドにそのまま渡される。詳しく
|
124
|
-
# はGroonga::IndexColumn#searchを参照。
|
127
|
+
# は {Groonga::IndexColumn#search} を参照。
|
125
128
|
def search(name, query, options={})
|
126
129
|
column(name).search(query, options)
|
127
130
|
end
|
128
131
|
|
129
132
|
# レコードの主キーを返す。
|
130
133
|
#
|
131
|
-
# _record_ が所属するテーブルがGroonga
|
134
|
+
# _record_ が所属するテーブルが {Groonga::Array} の場合は常
|
132
135
|
# に +nil+ を返す。
|
133
136
|
def key
|
134
137
|
if support_key?
|
@@ -139,7 +142,7 @@ module Groonga
|
|
139
142
|
end
|
140
143
|
# レコードを一意に識別するための情報を返す。
|
141
144
|
#
|
142
|
-
# _record_ が所属するテーブルがGroonga
|
145
|
+
# _record_ が所属するテーブルが {Groonga::Array} の場合はID
|
143
146
|
# を返し、それ以外の場合は主キーを返す。
|
144
147
|
def record_id
|
145
148
|
if support_key?
|
@@ -168,7 +171,7 @@ module Groonga
|
|
168
171
|
self["_score"] = new_score
|
169
172
|
end
|
170
173
|
|
171
|
-
# Groonga::Record#scoreが利用できる場合は +true+ を
|
174
|
+
# {Groonga::Record#score} が利用できる場合は +true+ を
|
172
175
|
# 返す。
|
173
176
|
def support_score?
|
174
177
|
@table.have_column?("_score") # TODO delegate to Table
|
@@ -177,13 +180,13 @@ module Groonga
|
|
177
180
|
# 主キーの値が同一であったレコードの件数を返す。検索結果とし
|
178
181
|
# て生成されたテーブルのみに定義される。
|
179
182
|
#
|
180
|
-
# Groonga::Record#support_sub_records
|
183
|
+
# {Groonga::Record#support_sub_records?} でこの値を利用でき
|
181
184
|
# るかがわかる。
|
182
185
|
def n_sub_records
|
183
186
|
self["_nsubrecs"]
|
184
187
|
end
|
185
188
|
|
186
|
-
# Groonga::Record#n_sub_recordsが利用できる場合は +true+ を
|
189
|
+
# {Groonga::Record#n_sub_records} が利用できる場合は +true+ を
|
187
190
|
# 返す。
|
188
191
|
def support_sub_records?
|
189
192
|
@table.support_sub_records?
|
@@ -232,7 +235,7 @@ module Groonga
|
|
232
235
|
end
|
233
236
|
|
234
237
|
# レコードが所属するテーブルをロックする。ロックに失敗した場
|
235
|
-
# 合はGroonga::ResourceDeadlockAvoided例外が発生する。
|
238
|
+
# 合は {Groonga::ResourceDeadlockAvoided} 例外が発生する。
|
236
239
|
#
|
237
240
|
# ブロックを指定した場合はブロックを抜けたときにunlockする。
|
238
241
|
#
|
data/lib/groonga/schema.rb
CHANGED
@@ -21,7 +21,7 @@ module Groonga
|
|
21
21
|
|
22
22
|
# groongaのスキーマ(データ構造)を管理するクラス。
|
23
23
|
#
|
24
|
-
# Groonga::Schemaを使うことにより簡単にテーブルやカラムを
|
24
|
+
# {Groonga::Schema} を使うことにより簡単にテーブルやカラムを
|
25
25
|
# 追加・削除することができる。
|
26
26
|
#
|
27
27
|
# !http://qwik.jp/senna/senna2.files/rect4605.png!
|
@@ -148,11 +148,12 @@ module Groonga
|
|
148
148
|
|
149
149
|
class << self
|
150
150
|
|
151
|
-
# スキーマを定義する。ブロックにはGroonga::Schemaオブ
|
151
|
+
# スキーマを定義する。ブロックには {Groonga::Schema} オブ
|
152
152
|
# ジェクトがわたるので、そのオブジェクトを利用してスキー
|
153
153
|
# マを定義する。以下の省略形。
|
154
154
|
#
|
155
155
|
# <pre>
|
156
|
+
# !!!ruby
|
156
157
|
# schema = Groonga::Scheme.new(options)
|
157
158
|
# # ...
|
158
159
|
# schema.define
|
@@ -162,20 +163,25 @@ module Groonga
|
|
162
163
|
# pairs. Omitted names are initialized as the default value.
|
163
164
|
# @option options [Groonga::Context] :content (Groonga::Context.default) The context
|
164
165
|
#
|
165
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
166
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
166
167
|
def define(options={})
|
167
168
|
schema = new(options)
|
168
169
|
yield(schema)
|
169
170
|
schema.define
|
170
171
|
end
|
171
172
|
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
173
|
+
# 名前が _name_ のテーブルを作成する。以下の省略形。
|
174
|
+
#
|
175
|
+
# <pre>
|
176
|
+
# !!!ruby
|
177
|
+
# Groonga::Schema.define do |schema|
|
178
|
+
# schema.create_table(name, options) do |table|
|
179
|
+
# # ...
|
180
|
+
# end
|
181
|
+
# end
|
182
|
+
# </pre>
|
183
|
+
#
|
184
|
+
# ブロックには {Groonga::Schema::TableDefinition} オブジェ
|
179
185
|
# クトがわたるので、そのオブジェクトを利用してテーブル
|
180
186
|
# の詳細を定義する。
|
181
187
|
#
|
@@ -195,7 +201,7 @@ module Groonga
|
|
195
201
|
# (:key_typeの項も参照)
|
196
202
|
# @option options [Groonga::Context] :context (Groonga::Context.default) The context
|
197
203
|
#
|
198
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
204
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
199
205
|
# @option options :path The path
|
200
206
|
#
|
201
207
|
# テーブルを保存するパスを指定する。
|
@@ -210,8 +216,8 @@ module Groonga
|
|
210
216
|
# 値を保存したい場合は必ず指定すること。
|
211
217
|
# @option options :sub_records The sub_records
|
212
218
|
#
|
213
|
-
# +true+ を指定するとGroonga::Table#groupで
|
214
|
-
# グループ化したときに、Groonga::Record#n_sub_recordsでグループに
|
219
|
+
# +true+ を指定すると {Groonga::Table#group} で
|
220
|
+
# グループ化したときに、 {Groonga::Record#n_sub_records} でグループに
|
215
221
|
# 含まれるレコードの件数を取得できる。
|
216
222
|
#
|
217
223
|
# @overload create_table(name, options= {:type => :hash}, &block)
|
@@ -229,7 +235,7 @@ module Groonga
|
|
229
235
|
# (:key_typeの項も参照)
|
230
236
|
# @option options [Groonga::Context] :context (Groonga::Context.default) The context
|
231
237
|
#
|
232
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
238
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
233
239
|
# @option options :path The path
|
234
240
|
#
|
235
241
|
# テーブルを保存するパスを指定する。
|
@@ -244,29 +250,29 @@ module Groonga
|
|
244
250
|
# 値を保存したい場合は必ず指定すること。
|
245
251
|
# @option options :sub_records The sub_records
|
246
252
|
#
|
247
|
-
# +true+ を指定するとGroonga::Table#groupで
|
248
|
-
# グループ化したときに、Groonga::Record#n_sub_recordsでグループに
|
253
|
+
# +true+ を指定すると {Groonga::Table#group} で
|
254
|
+
# グループ化したときに、 {Groonga::Record#n_sub_records} でグループに
|
249
255
|
# 含まれるレコードの件数を取得できる。
|
250
256
|
# @option options :key_type The key_type
|
251
257
|
#
|
252
258
|
# キーの種類を示すオブジェクトを指定する。
|
253
|
-
# キーの種類には型名("Int32"や"ShortText"など)またはGroonga::Type
|
254
|
-
# またはテーブル(Groonga::Array、Groonga::Hash、
|
255
|
-
# Groonga::PatriciaTrie、Groonga::DoubleArrayTrieの
|
256
|
-
# どれか)を指定する。Groonga::Typeを指定した場合は、その型が示す範囲の
|
259
|
+
# キーの種類には型名("Int32"や"ShortText"など)または {Groonga::Type}
|
260
|
+
# またはテーブル( {Groonga::Array} 、 {Groonga::Hash} 、
|
261
|
+
# {Groonga::PatriciaTrie} 、 {Groonga::DoubleArrayTrie} の
|
262
|
+
# どれか)を指定する。 {Groonga::Type} を指定した場合は、その型が示す範囲の
|
257
263
|
# 値をキーとして使用する。ただし、キーの最大サイズは4096バイトで
|
258
|
-
# あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXTは使用できない
|
264
|
+
# あるため、 {Groonga::Type::TEXT} や {Groonga::Type::LONG_TEXT} は使用できない
|
259
265
|
# 。テーブルを指定した場合はレコードIDをキーとして使用する。
|
260
|
-
# 指定したテーブルのGroonga::Recordをキーとして使用することもでき、
|
261
|
-
# その場合は自動的にGroonga::RecordからレコードIDを取得する。
|
266
|
+
# 指定したテーブルの {Groonga::Record} をキーとして使用することもでき、
|
267
|
+
# その場合は自動的に {Groonga::Record} からレコードIDを取得する。
|
262
268
|
# 省略した場合は文字列をキーとして使用する。
|
263
269
|
# この場合、4096バイトまで使用可能である。
|
264
270
|
# @option options :default_tokenizer The default_tokenizer
|
265
271
|
#
|
266
|
-
# Groonga::IndexColumnで
|
272
|
+
# {Groonga::IndexColumn} で
|
267
273
|
# 使用するトークナイザを指定する。デフォルトでは
|
268
274
|
# 何も設定されていないので、テーブルに
|
269
|
-
# Groonga::IndexColumn
|
275
|
+
# {Groonga::IndexColumn} を定義する場合は @"TokenBigram"@
|
270
276
|
# などを指定する必要がある。
|
271
277
|
# @option options :key_normalize The key_normalize
|
272
278
|
#
|
@@ -287,7 +293,7 @@ module Groonga
|
|
287
293
|
# (:key_typeの項も参照)
|
288
294
|
# @option options [Groonga::Context] :context (Groonga::Context.default) The context
|
289
295
|
#
|
290
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
296
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
291
297
|
# @option options :path The path
|
292
298
|
#
|
293
299
|
# テーブルを保存するパスを指定する。
|
@@ -302,8 +308,8 @@ module Groonga
|
|
302
308
|
# 値を保存したい場合は必ず指定すること。
|
303
309
|
# @option options :sub_records The sub_records
|
304
310
|
#
|
305
|
-
# +true+ を指定するとGroonga::Table#groupで
|
306
|
-
# グループ化したときに、Groonga::Record#n_sub_recordsでグループに
|
311
|
+
# +true+ を指定すると {Groonga::Table#group} で
|
312
|
+
# グループ化したときに、 {Groonga::Record#n_sub_records} でグループに
|
307
313
|
# 含まれるレコードの件数を取得できる。
|
308
314
|
# @option options :key_normalize The key_normalize
|
309
315
|
#
|
@@ -322,7 +328,7 @@ module Groonga
|
|
322
328
|
# pairs. Omitted names are initialized as the default value.
|
323
329
|
# @option options :context (Groonga::Context.default)
|
324
330
|
#
|
325
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
331
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
326
332
|
def remove_table(name, options={})
|
327
333
|
define do |schema|
|
328
334
|
schema.remove_table(name, options)
|
@@ -332,6 +338,7 @@ module Groonga
|
|
332
338
|
# 名前が _name_ のテーブルを変更する。以下の省略形。
|
333
339
|
#
|
334
340
|
# <pre>
|
341
|
+
# !!!ruby
|
335
342
|
# Groonga::Schema.define do |schema|
|
336
343
|
# schema.change_table(name, options) do |table|
|
337
344
|
# # ...
|
@@ -339,7 +346,7 @@ module Groonga
|
|
339
346
|
# end
|
340
347
|
# </pre>
|
341
348
|
#
|
342
|
-
# ブロックにはGroonga::Schema::TableDefinitionオブジェ
|
349
|
+
# ブロックには {Groonga::Schema::TableDefinition} オブジェ
|
343
350
|
# クトがわたるので、そのオブジェクトを利用してテーブル
|
344
351
|
# の詳細を定義する。
|
345
352
|
#
|
@@ -347,7 +354,7 @@ module Groonga
|
|
347
354
|
# pairs. Omitted names are initialized as the default value.
|
348
355
|
# @option options :context (Groonga::Context.default) The context
|
349
356
|
#
|
350
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
357
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
351
358
|
def change_table(name, options={}, &block)
|
352
359
|
define do |schema|
|
353
360
|
schema.change_table(name, options, &block)
|
@@ -359,6 +366,7 @@ module Groonga
|
|
359
366
|
# This is a syntax sugar of the following code:
|
360
367
|
#
|
361
368
|
# <pre>
|
369
|
+
# !!!ruby
|
362
370
|
# Groonga::Schema.define do |schema|
|
363
371
|
# schema.rename_table(current_name, new_name, options)
|
364
372
|
# end
|
@@ -372,13 +380,14 @@ module Groonga
|
|
372
380
|
# 名前が_name_のビューを作成する。以下の省略形。
|
373
381
|
#
|
374
382
|
# <pre>
|
383
|
+
# !!!ruby
|
375
384
|
# Groonga::Schema.define do |schema|
|
376
385
|
# schema.create_view(name, options) do |view|
|
377
386
|
# # ...
|
378
387
|
# end
|
379
388
|
# end
|
380
389
|
# </pre>
|
381
|
-
# ブロックにはGroonga::Schema::ViewDefinitionオブジェ
|
390
|
+
# ブロックには {Groonga::Schema::ViewDefinition} オブジェ
|
382
391
|
# クトがわたるので、そのオブジェクトを利用してビュー
|
383
392
|
# の詳細を定義する。
|
384
393
|
#
|
@@ -390,7 +399,7 @@ module Groonga
|
|
390
399
|
# 存在していても、強制的にビューを作成する。
|
391
400
|
# @option options :context (Groonga::Context.default) The context
|
392
401
|
#
|
393
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
402
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
394
403
|
# @option options :path The path
|
395
404
|
#
|
396
405
|
# ビューを保存するパスを指定する。
|
@@ -411,16 +420,17 @@ module Groonga
|
|
411
420
|
# @param options [::Hash] The name and value
|
412
421
|
# pairs. Omitted names are initialized as the default value.
|
413
422
|
# @option options :context (Groonga::context.default) The context
|
414
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
423
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
415
424
|
def remove_view(name, options={})
|
416
425
|
define do |schema|
|
417
426
|
schema.remove_view(name, options)
|
418
427
|
end
|
419
428
|
end
|
420
429
|
|
421
|
-
# 名前が_name_のビューを変更する。以下の省略形。
|
430
|
+
# 名前が _name_ のビューを変更する。以下の省略形。
|
422
431
|
#
|
423
432
|
# <pre>
|
433
|
+
# !!!ruby
|
424
434
|
# Groonga::Schema.define do |schema|
|
425
435
|
# schema.change_view(name, options) do |view|
|
426
436
|
# # ...
|
@@ -428,7 +438,7 @@ module Groonga
|
|
428
438
|
# end
|
429
439
|
# </pre>
|
430
440
|
#
|
431
|
-
# ブロックにはGroonga::Schema::ViewDefinitionオブジェ
|
441
|
+
# ブロックには {Groonga::Schema::ViewDefinition} オブジェ
|
432
442
|
# クトがわたるので、そのオブジェクトを利用してテーブル
|
433
443
|
# の詳細を定義する。
|
434
444
|
#
|
@@ -436,7 +446,7 @@ module Groonga
|
|
436
446
|
# pairs. Omitted names are initialized as the default value.
|
437
447
|
# @option options :context (Groonga::Context.default) The context
|
438
448
|
#
|
439
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
449
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
440
450
|
def change_view(name, options={}, &block)
|
441
451
|
define do |schema|
|
442
452
|
schema.change_view(name, options, &block)
|
@@ -446,6 +456,7 @@ module Groonga
|
|
446
456
|
# 以下と同様:
|
447
457
|
#
|
448
458
|
# <pre>
|
459
|
+
# !!!ruby
|
449
460
|
# Groonga::Schema.change_table(table_name) do |table|
|
450
461
|
# table.remove_column(column_name)
|
451
462
|
# end
|
@@ -459,6 +470,7 @@ module Groonga
|
|
459
470
|
# This is a syntax sugar of the following:
|
460
471
|
#
|
461
472
|
# <pre>
|
473
|
+
# !!!ruby
|
462
474
|
# Groonga::Schema.define do |schema|
|
463
475
|
# schema.rename_column(table_name,
|
464
476
|
# current_column_name, new_column_name)
|
@@ -473,12 +485,13 @@ module Groonga
|
|
473
485
|
# スキーマの内容を文字列をRubyスクリプト形式またはgrn式
|
474
486
|
# 形式で返す。デフォルトはRubyスクリプト形式である。
|
475
487
|
# Rubyスクリプト形式で返された値は
|
476
|
-
# Groonga::Schema.restoreすることによりスキーマ内に組み
|
488
|
+
# {Groonga::Schema.restore} することによりスキーマ内に組み
|
477
489
|
# 込むことができる。
|
478
490
|
#
|
479
491
|
# dump.rb:
|
480
492
|
#
|
481
493
|
# <pre>
|
494
|
+
# !!!ruby
|
482
495
|
# File.open("/tmp/groonga-schema.rb", "w") do |schema|
|
483
496
|
# dumped_text = Groonga::Schema.dump
|
484
497
|
# end
|
@@ -487,6 +500,7 @@ module Groonga
|
|
487
500
|
# restore.rb:
|
488
501
|
#
|
489
502
|
# <pre>
|
503
|
+
# !!!ruby
|
490
504
|
# dumped_text = Groonga::Schema.dump
|
491
505
|
# Groonga::Database.create(:path => "/tmp/new-db.grn")
|
492
506
|
# Groonga::Schema.restore(dumped_text)
|
@@ -498,6 +512,7 @@ module Groonga
|
|
498
512
|
# dump.rb:
|
499
513
|
#
|
500
514
|
# <pre>
|
515
|
+
# !!!ruby
|
501
516
|
# File.open("/tmp/groonga-schema.grn", "w") do |schema|
|
502
517
|
# dumped_text = Groonga::Schema.dump(:syntax => :command)
|
503
518
|
# end
|
@@ -512,7 +527,7 @@ module Groonga
|
|
512
527
|
# pairs. Omitted names are initialized as the default value.
|
513
528
|
# @option options :context (Groonga::Context.default) The context
|
514
529
|
#
|
515
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
530
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
516
531
|
# @option options :syntax The syntax
|
517
532
|
#
|
518
533
|
# スキーマの文字列の形式を指定する。指定可能な値は以下の通り。
|
@@ -526,7 +541,7 @@ module Groonga
|
|
526
541
|
schema.dump
|
527
542
|
end
|
528
543
|
|
529
|
-
# Groonga::Schema.dumpで文字列化したスキーマを組み込む。
|
544
|
+
# {Groonga::Schema.dump} で文字列化したスキーマを組み込む。
|
530
545
|
def restore(dumped_text, options={})
|
531
546
|
define(options) do |schema|
|
532
547
|
schema.restore(dumped_text)
|
@@ -617,7 +632,7 @@ module Groonga
|
|
617
632
|
# @param options [::Hash] The name and value
|
618
633
|
# pairs. Omitted names are initialized as the default value.
|
619
634
|
# @option options :context (Groonga::Context.default) The context
|
620
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
635
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
621
636
|
def initialize(options={})
|
622
637
|
@options = (options || {}).dup
|
623
638
|
@options[:context] ||= Groonga::Context.default
|
@@ -631,9 +646,9 @@ module Groonga
|
|
631
646
|
end
|
632
647
|
end
|
633
648
|
|
634
|
-
# Groonga::Schema#dumpで返されたスキーマの内容を読み込む。
|
649
|
+
# {Groonga::Schema#dump} で返されたスキーマの内容を読み込む。
|
635
650
|
#
|
636
|
-
#
|
651
|
+
# 読み込まれた内容は {#define} を呼び出すまでは実行されない
|
637
652
|
# ことに注意すること。
|
638
653
|
def restore(dumped_text)
|
639
654
|
instance_eval(dumped_text)
|
@@ -643,7 +658,7 @@ module Groonga
|
|
643
658
|
alias_method :load, :restore
|
644
659
|
|
645
660
|
# スキーマの内容を文字列で返す。返された値は
|
646
|
-
# Groonga::Schema#restoreすることによりスキーマ内に組み込むことができる。
|
661
|
+
# {Groonga::Schema#restore} することによりスキーマ内に組み込むことができる。
|
647
662
|
def dump
|
648
663
|
dumper = SchemaDumper.new(:context => @options[:context],
|
649
664
|
:syntax => @options[:syntax] || :ruby)
|
@@ -652,7 +667,7 @@ module Groonga
|
|
652
667
|
|
653
668
|
# 名前が _name_ のテーブルを作成する。
|
654
669
|
#
|
655
|
-
#
|
670
|
+
# テーブルの作成は {#define} を呼び出すまでは実行されないこ
|
656
671
|
# とに注意すること。
|
657
672
|
# @overload create_table(name, options= {:type => :array})
|
658
673
|
# :typeにデフォルトの:arrayを使用した場合
|
@@ -669,10 +684,10 @@ module Groonga
|
|
669
684
|
# +:double_array_trie+ のいずれかを指定する。
|
670
685
|
# @option options [Groonga::Context] :context The context.
|
671
686
|
#
|
672
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
673
|
-
# 省略した場合はGroonga::Schema.newで指定した
|
674
|
-
# Groonga::Contextを使用する。Groonga::Schema.newで指
|
675
|
-
# 定していない場合はGroonga::Context.defaultを使用する。
|
687
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
688
|
+
# 省略した場合は {Groonga::Schema.new} で指定した
|
689
|
+
# {Groonga::Context} を使用する。 {Groonga::Schema.new} で指
|
690
|
+
# 定していない場合は {Groonga::Context.default} を使用する。
|
676
691
|
# @option options :path The path
|
677
692
|
#
|
678
693
|
# テーブルを保存するパスを指定する。パスを指定すると
|
@@ -686,11 +701,11 @@ module Groonga
|
|
686
701
|
#
|
687
702
|
# 値の型を指定する。省略すると値のための領域を確保しない。
|
688
703
|
# 値を保存したい場合は必ず指定すること。
|
689
|
-
# 参考: Groonga::Type.new
|
704
|
+
# 参考: {Groonga::Type.new}
|
690
705
|
# @option options :sub_records The sub_records
|
691
706
|
#
|
692
|
-
# +true+ を指定するとGroonga::Table#groupでグループ化
|
693
|
-
# したときに、Groonga::Record#n_sub_recordsでグループに
|
707
|
+
# +true+ を指定すると {Groonga::Table#group} でグループ化
|
708
|
+
# したときに、 {Groonga::Record#n_sub_records} でグループに
|
694
709
|
# 含まれるレコードの件数を取得できる。
|
695
710
|
#
|
696
711
|
# @overload create_table(name, options= {:type => :hash})
|
@@ -708,10 +723,10 @@ module Groonga
|
|
708
723
|
# +:double_array_trie+ のいずれかを指定する。
|
709
724
|
# @option options [Groonga::Context] :context The context
|
710
725
|
#
|
711
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
712
|
-
# 省略した場合はGroonga::Schema.newで指定した
|
713
|
-
# Groonga::Contextを使用する。Groonga::Schema.newで指
|
714
|
-
# 定していない場合はGroonga::Context.defaultを使用する。
|
726
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
727
|
+
# 省略した場合は {Groonga::Schema.new} で指定した
|
728
|
+
# {Groonga::Context} を使用する。 {Groonga::Schema.new} で指
|
729
|
+
# 定していない場合は {Groonga::Context.default} を使用する。
|
715
730
|
# @option options :path The path
|
716
731
|
#
|
717
732
|
# テーブルを保存するパスを指定する。パスを指定すると
|
@@ -725,39 +740,39 @@ module Groonga
|
|
725
740
|
#
|
726
741
|
# 値の型を指定する。省略すると値のための領域を確保しない。
|
727
742
|
# 値を保存したい場合は必ず指定すること。
|
728
|
-
# 参考: Groonga::Type.new
|
743
|
+
# 参考: {Groonga::Type.new}
|
729
744
|
# @option options :sub_records The sub_records
|
730
745
|
#
|
731
|
-
# +true+ を指定するとGroonga::Table#groupでグループ化
|
732
|
-
# したときに、Groonga::Record#n_sub_recordsでグループに
|
746
|
+
# +true+ を指定すると {Groonga::Table#group} でグループ化
|
747
|
+
# したときに、 {Groonga::Record#n_sub_records} でグループに
|
733
748
|
# 含まれるレコードの件数を取得できる。
|
734
749
|
# @option options :key_type The key_type
|
735
750
|
#
|
736
751
|
# キーの種類を示すオブジェクトを指定する。
|
737
752
|
# キーの種類には型名("Int32"や"ShortText"など)または
|
738
|
-
# Groonga::Typeまたはテーブル(Groonga::Array、
|
739
|
-
# Groonga::Hash、Groonga::PatriciaTrie、
|
740
|
-
# Groonga::DoubleArrayTrieのどれか)を指定する。
|
753
|
+
# {Groonga::Type} またはテーブル( {Groonga::Array} 、
|
754
|
+
# {Groonga::Hash} 、 {Groonga::PatriciaTrie} 、
|
755
|
+
# {Groonga::DoubleArrayTrie} のどれか)を指定する。
|
741
756
|
#
|
742
|
-
# Groonga::Typeを指定した場合は、その型が示す範囲の
|
757
|
+
# {Groonga::Type} を指定した場合は、その型が示す範囲の
|
743
758
|
# 値をキーとして使用する。ただし、キーの最大サイズは
|
744
|
-
# 4096バイトであるため、Groonga::Type::TEXTや
|
745
|
-
# Groonga::Type::LONG_TEXTは使用できない。
|
759
|
+
# 4096バイトであるため、 {Groonga::Type::TEXT} や
|
760
|
+
# {Groonga::Type::LONG_TEXT} は使用できない。
|
746
761
|
#
|
747
762
|
# テーブルを指定した場合はレコードIDをキーとして使用
|
748
|
-
# する。指定したテーブルのGroonga::Recordをキーとし
|
763
|
+
# する。指定したテーブルの {Groonga::Record} をキーとし
|
749
764
|
# て使用することもでき、その場合は自動的に
|
750
|
-
# Groonga::RecordからレコードIDを取得する。
|
765
|
+
# {Groonga::Record} からレコードIDを取得する。
|
751
766
|
#
|
752
767
|
# 省略した場合は文字列をキーとして使用する。この場合、
|
753
768
|
# 4096バイトまで使用可能である。
|
754
769
|
#
|
755
770
|
# @option options :default_tokenizer The default_tokenizer
|
756
771
|
#
|
757
|
-
# Groonga::IndexColumnで使用するトークナイザを指定する。
|
772
|
+
# {Groonga::IndexColumn} で使用するトークナイザを指定する。
|
758
773
|
# デフォルトでは何も設定されていないので、テーブルに
|
759
|
-
# Groonga::IndexColumnを定義する場合は
|
760
|
-
#
|
774
|
+
# {Groonga::IndexColumn} を定義する場合は
|
775
|
+
# @"TokenBigram"@ などを指定する必要がある。
|
761
776
|
#
|
762
777
|
# @overload create_table(name, options= {:type => :double_array_trie})
|
763
778
|
# :typeに:double_array_trieを使用した場合
|
@@ -769,10 +784,10 @@ module Groonga
|
|
769
784
|
# 存在していても、強制的にテーブルを作成する。
|
770
785
|
# @option options [Groonga::Context] :context The context
|
771
786
|
#
|
772
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
773
|
-
# 省略した場合はGroonga::Schema.newで指定した
|
774
|
-
# Groonga::Contextを使用する。Groonga::Schema.newで指
|
775
|
-
# 定していない場合はGroonga::Context.defaultを使用する。
|
787
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
788
|
+
# 省略した場合は {Groonga::Schema.new} で指定した
|
789
|
+
# {Groonga::Context} を使用する。 {Groonga::Schema.new} で指
|
790
|
+
# 定していない場合は {Groonga::Context.default} を使用する。
|
776
791
|
# @option options :path The path
|
777
792
|
#
|
778
793
|
# テーブルを保存するパスを指定する。パスを指定すると
|
@@ -786,11 +801,11 @@ module Groonga
|
|
786
801
|
#
|
787
802
|
# 値の型を指定する。省略すると値のための領域を確保しない。
|
788
803
|
# 値を保存したい場合は必ず指定すること。
|
789
|
-
# 参考: Groonga::Type.new
|
804
|
+
# 参考: {Groonga::Type.new}
|
790
805
|
# @option options :sub_records The sub_records
|
791
806
|
#
|
792
|
-
# +true+ を指定するとGroonga::Table#groupでグループ化
|
793
|
-
# したときに、Groonga::Record#n_sub_recordsでグループに
|
807
|
+
# +true+ を指定すると {Groonga::Table#group} でグループ化
|
808
|
+
# したときに、 {Groonga::Record#n_sub_records} でグループに
|
794
809
|
# 含まれるレコードの件数を取得できる。
|
795
810
|
# @option options :key_normalize The key_normalize
|
796
811
|
#
|
@@ -799,28 +814,28 @@ module Groonga
|
|
799
814
|
#
|
800
815
|
# キーの種類を示すオブジェクトを指定する。
|
801
816
|
# キーの種類には型名("Int32"や"ShortText"など)または
|
802
|
-
# Groonga::Typeまたはテーブル(Groonga::Array、
|
803
|
-
# Groonga::Hash、Groonga::PatriciaTrie、
|
804
|
-
# Groonga::DoubleArrayTrieのどれか)を指定する。
|
817
|
+
# {Groonga::Type} またはテーブル( {Groonga::Array} 、
|
818
|
+
# {Groonga::Hash} 、 {Groonga::PatriciaTrie} 、
|
819
|
+
# {Groonga::DoubleArrayTrie} のどれか)を指定する。
|
805
820
|
#
|
806
|
-
# Groonga::Typeを指定した場合は、その型が示す範囲の
|
821
|
+
# {Groonga::Type} を指定した場合は、その型が示す範囲の
|
807
822
|
# 値をキーとして使用する。ただし、キーの最大サイズは
|
808
|
-
# 4096バイトであるため、Groonga::Type::TEXTや
|
809
|
-
# Groonga::Type::LONG_TEXTは使用できない。
|
823
|
+
# 4096バイトであるため、 {Groonga::Type::TEXT} や
|
824
|
+
# {Groonga::Type::LONG_TEXT} は使用できない。
|
810
825
|
#
|
811
826
|
# テーブルを指定した場合はレコードIDをキーとして使用
|
812
|
-
# する。指定したテーブルのGroonga::Recordをキーとし
|
827
|
+
# する。指定したテーブルの {Groonga::Record} をキーとし
|
813
828
|
# て使用することもでき、その場合は自動的に
|
814
|
-
# Groonga::RecordからレコードIDを取得する。
|
829
|
+
# {Groonga::Record} からレコードIDを取得する。
|
815
830
|
#
|
816
831
|
# 省略した場合は文字列をキーとして使用する。この場合、
|
817
832
|
# 4096バイトまで使用可能である。
|
818
833
|
# @option options :default_tokenizer The default_tokenizer
|
819
834
|
#
|
820
|
-
# Groonga::IndexColumnで使用するトークナイザを指定する。
|
835
|
+
# {Groonga::IndexColumn} で使用するトークナイザを指定する。
|
821
836
|
# デフォルトでは何も設定されていないので、テーブルに
|
822
|
-
# Groonga::IndexColumnを定義する場合は
|
823
|
-
#
|
837
|
+
# {Groonga::IndexColumn} を定義する場合は
|
838
|
+
# @"TokenBigram"@ などを指定する必要がある。
|
824
839
|
def create_table(name, options={})
|
825
840
|
definition = TableDefinition.new(name, @options.merge(options || {}))
|
826
841
|
yield(definition) if block_given?
|
@@ -829,14 +844,14 @@ module Groonga
|
|
829
844
|
|
830
845
|
# 名前が _name_ のテーブルを削除する。
|
831
846
|
#
|
832
|
-
# テーブルの削除は#defineを呼び出すまでは実行されないこ
|
847
|
+
# テーブルの削除は# {define} を呼び出すまでは実行されないこ
|
833
848
|
# とに注意すること。
|
834
849
|
#
|
835
850
|
# @param options [::Hash] The name and value
|
836
851
|
# pairs. Omitted names are initialized as the default value.
|
837
852
|
# @option options :context (Groonga::Context.default) The context
|
838
853
|
#
|
839
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
854
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
840
855
|
def remove_table(name, options={})
|
841
856
|
definition = TableRemoveDefinition.new(name, @options.merge(options || {}))
|
842
857
|
@definitions << definition
|
@@ -844,14 +859,14 @@ module Groonga
|
|
844
859
|
|
845
860
|
# 名前が _name_ のテーブルを変更する。
|
846
861
|
#
|
847
|
-
# テーブルの変更は #define を呼び出すまでは実行されないこ
|
862
|
+
# テーブルの変更は {#define} を呼び出すまでは実行されないこ
|
848
863
|
# とに注意すること。
|
849
864
|
#
|
850
865
|
# @param options [::Hash] The name and value
|
851
866
|
# pairs. Omitted names are initialized as the default value.
|
852
867
|
# @option options :context (Groonga::Context.default) The context
|
853
868
|
#
|
854
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
869
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
855
870
|
def change_table(name, options={})
|
856
871
|
options = @options.merge(options || {}).merge(:change => true)
|
857
872
|
definition = TableDefinition.new(name, options)
|
@@ -867,7 +882,7 @@ module Groonga
|
|
867
882
|
# @param options [::Hash] The name and value
|
868
883
|
# pairs. Omitted names are initialized as the default value.
|
869
884
|
# @option options :context (Groonga::Context.default)
|
870
|
-
# The Groonga::Context to be used in renaming.
|
885
|
+
# The {Groonga::Context} to be used in renaming.
|
871
886
|
def rename_table(current_name, new_name, options={})
|
872
887
|
options = @options.merge(options || {})
|
873
888
|
definition = TableRenameDefinition.new(current_name, new_name, options)
|
@@ -876,7 +891,7 @@ module Groonga
|
|
876
891
|
|
877
892
|
# 名前が _name_ のビューを作成する。
|
878
893
|
#
|
879
|
-
# ビューの作成は #define を呼び出すまでは実行されないこ
|
894
|
+
# ビューの作成は {#define} を呼び出すまでは実行されないこ
|
880
895
|
# とに注意すること。
|
881
896
|
#
|
882
897
|
# @param options [::Hash] The name and value
|
@@ -887,9 +902,9 @@ module Groonga
|
|
887
902
|
# ビューが存在していても、強制的にビューを作成する。
|
888
903
|
# @option options [Groonga::Context] :context (Groonga::Schema.new) The context
|
889
904
|
#
|
890
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
891
|
-
# Groonga::Schema.newで指定していない場合は
|
892
|
-
# Groonga::Context.defaultを使用する。
|
905
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
906
|
+
# {Groonga::Schema.new} で指定していない場合は
|
907
|
+
# {Groonga::Context.default} を使用する。
|
893
908
|
# @option options :path The path
|
894
909
|
#
|
895
910
|
# テーブルを保存するパスを指定する。パスを指定すると
|
@@ -906,7 +921,7 @@ module Groonga
|
|
906
921
|
|
907
922
|
# 名前が _name_ のビューを削除する。
|
908
923
|
#
|
909
|
-
# ビューの削除は #define を呼び出すまでは実行されないことに
|
924
|
+
# ビューの削除は {#define} を呼び出すまでは実行されないことに
|
910
925
|
# 注意すること。
|
911
926
|
#
|
912
927
|
# @param options [::Hash] The name and value
|
@@ -914,7 +929,7 @@ module Groonga
|
|
914
929
|
# @option options [Groonga::Context] :context (Groonga::Context.default)
|
915
930
|
# The context
|
916
931
|
#
|
917
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
932
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
918
933
|
def remove_view(name, options={})
|
919
934
|
definition = ViewRemoveDefinition.new(name, @options.merge(options || {}))
|
920
935
|
@definitions << definition
|
@@ -922,14 +937,14 @@ module Groonga
|
|
922
937
|
|
923
938
|
# 名前が _name_ のビューを変更する。
|
924
939
|
#
|
925
|
-
# ビューの変更は #define を呼び出すまでは実行されないこ
|
940
|
+
# ビューの変更は {#define} を呼び出すまでは実行されないこ
|
926
941
|
# とに注意すること。
|
927
942
|
#
|
928
943
|
# @param options [::Hash] The name and value
|
929
944
|
# pairs. Omitted names are initialized as the default value.
|
930
945
|
# @option options :context (Groonga::Context.default) The context
|
931
946
|
#
|
932
|
-
# スキーマ定義時に使用するGroonga::Contextを指定する。
|
947
|
+
# スキーマ定義時に使用する {Groonga::Context} を指定する。
|
933
948
|
def change_view(name, options={})
|
934
949
|
options = @options.merge(options || {}).merge(:change => true)
|
935
950
|
definition = ViewDefinition.new(name, options)
|
@@ -940,6 +955,7 @@ module Groonga
|
|
940
955
|
# 以下と同様:
|
941
956
|
#
|
942
957
|
# <pre>
|
958
|
+
# !!!ruby
|
943
959
|
# schema.change_table(table_name) do |table|
|
944
960
|
# table.remove_column(column_name)
|
945
961
|
# end
|
@@ -953,6 +969,7 @@ module Groonga
|
|
953
969
|
# It is a syntax sugar of the following:
|
954
970
|
#
|
955
971
|
# <pre>
|
972
|
+
# !!!ruby
|
956
973
|
# schema.change_table(table_name) do |table|
|
957
974
|
# table.rename_column(current_column_name, new_column_name)
|
958
975
|
# end
|
@@ -992,8 +1009,8 @@ module Groonga
|
|
992
1009
|
end
|
993
1010
|
end
|
994
1011
|
|
995
|
-
# スキーマ定義時にGroonga::Schema.create_tableや
|
996
|
-
# Groonga::Schema#create_tableからブロックに渡されてくる
|
1012
|
+
# スキーマ定義時に {Groonga::Schema.create_table} や
|
1013
|
+
# {Groonga::Schema#create_table} からブロックに渡されてくる
|
997
1014
|
# オブジェクト
|
998
1015
|
class TableDefinition
|
999
1016
|
include Path
|
@@ -1040,31 +1057,29 @@ module Groonga
|
|
1040
1057
|
#
|
1041
1058
|
# @param options [::Hash] The name and value
|
1042
1059
|
# pairs. Omitted names are initialized as the default value.
|
1043
|
-
# @option options :force
|
1060
|
+
# @option options :force
|
1044
1061
|
#
|
1045
1062
|
# +true+ を指定すると既存の同名のカラムが
|
1046
1063
|
# 存在していても、強制的に新しいカラムを作成する。
|
1047
|
-
# @option options :path
|
1064
|
+
# @option options :path
|
1048
1065
|
#
|
1049
1066
|
# カラムを保存するパス。
|
1050
|
-
# @option options :persistent
|
1067
|
+
# @option options :persistent
|
1051
1068
|
#
|
1052
|
-
# +true+
|
1069
|
+
# +true+ を指定すると永続カラムとなる。 +:path+ を省略
|
1053
1070
|
# した場合は自動的にパスが付加される。
|
1054
|
-
# @option options :type (:scalar)
|
1071
|
+
# @option options :type (:scalar)
|
1055
1072
|
#
|
1056
1073
|
# カラムの値の格納方法について指定する。
|
1057
|
-
#
|
1058
|
-
#
|
1059
|
-
#
|
1060
|
-
#
|
1061
|
-
# @option options :compress The compress
|
1074
|
+
#
|
1075
|
+
# - :scalar := スカラ値(単独の値)を格納する。
|
1076
|
+
# - :vector := 値の配列を格納する。
|
1077
|
+
# @option options :compress
|
1062
1078
|
#
|
1063
1079
|
# 値の圧縮方法を指定する。省略した場合は、圧縮しない。
|
1064
|
-
#
|
1065
|
-
#
|
1066
|
-
#
|
1067
|
-
# 値をlzo圧縮して格納する。
|
1080
|
+
#
|
1081
|
+
# - :zlib := 値をzlib圧縮して格納する。
|
1082
|
+
# - :lzo := 値をlzo圧縮して格納する。
|
1068
1083
|
def column(name, type, options={})
|
1069
1084
|
definition = self[name, ColumnDefinition]
|
1070
1085
|
if definition.nil?
|
@@ -1113,10 +1128,12 @@ module Groonga
|
|
1113
1128
|
# きます。
|
1114
1129
|
#
|
1115
1130
|
# _target_column_full_name_ で指定するときはテーブル名
|
1116
|
-
# とカラム名を"."
|
1117
|
-
# ルの「name」カラムのインデックスカラムを指定する場合
|
1118
|
-
# はこうなります。
|
1131
|
+
# とカラム名を"."でつなげます。
|
1119
1132
|
#
|
1133
|
+
# 例えば、「Users」テーブルの「name」カラムのインデックスカラムを
|
1134
|
+
# 指定する場合はこうなります。
|
1135
|
+
#
|
1136
|
+
# @example
|
1120
1137
|
# table.index("Users.name")
|
1121
1138
|
#
|
1122
1139
|
# @param [Array] args
|
@@ -1165,10 +1182,12 @@ module Groonga
|
|
1165
1182
|
# クスカラムを削除します。
|
1166
1183
|
#
|
1167
1184
|
# _target_column_full_name_ で指定するときはテーブル名
|
1168
|
-
# とカラム名を"."
|
1169
|
-
#
|
1170
|
-
#
|
1185
|
+
# とカラム名を"."でつなげます。
|
1186
|
+
#
|
1187
|
+
# 例えば、「Users」テーブルの「name」カラムのインデックスカラムを
|
1188
|
+
# 削除する場合はこうなります。
|
1171
1189
|
#
|
1190
|
+
# @example
|
1172
1191
|
# table.remove_index("Users.name")
|
1173
1192
|
#
|
1174
1193
|
# @param [::Hash] args { :name => target_column }と指定す
|
@@ -1196,8 +1215,7 @@ module Groonga
|
|
1196
1215
|
#
|
1197
1216
|
# @param [String or Symbol] name the column name
|
1198
1217
|
# @param [Hash] options ({}) the options
|
1199
|
-
# @see
|
1200
|
-
# available @options@.
|
1218
|
+
# @see #column #column for available options.
|
1201
1219
|
def integer8(name, options={})
|
1202
1220
|
column(name, "Int8", options)
|
1203
1221
|
end
|
@@ -1207,8 +1225,7 @@ module Groonga
|
|
1207
1225
|
#
|
1208
1226
|
# @param [String or Symbol] name the column name
|
1209
1227
|
# @param [Hash] options ({}) the options
|
1210
|
-
# @see
|
1211
|
-
# available @options@.
|
1228
|
+
# @see #column #column for available options.
|
1212
1229
|
def integer16(name, options={})
|
1213
1230
|
column(name, "Int16", options)
|
1214
1231
|
end
|
@@ -1237,8 +1254,7 @@ module Groonga
|
|
1237
1254
|
#
|
1238
1255
|
# @param [String or Symbol] name the column name
|
1239
1256
|
# @param [Hash] options ({}) the options
|
1240
|
-
# @see
|
1241
|
-
# available @options@.
|
1257
|
+
# @see #column #column for available options.
|
1242
1258
|
def unsigned_integer8(name, options={})
|
1243
1259
|
column(name, "UInt8", options)
|
1244
1260
|
end
|
@@ -1248,8 +1264,7 @@ module Groonga
|
|
1248
1264
|
#
|
1249
1265
|
# @param [String or Symbol] name the column name
|
1250
1266
|
# @param [Hash] options ({}) the options
|
1251
|
-
# @see
|
1252
|
-
# available @options@.
|
1267
|
+
# @see #column #column for available options.
|
1253
1268
|
def unsigned_integer16(name, options={})
|
1254
1269
|
column(name, "UInt16", options)
|
1255
1270
|
end
|
@@ -1293,8 +1308,11 @@ module Groonga
|
|
1293
1308
|
end
|
1294
1309
|
|
1295
1310
|
# 以下と同様:
|
1296
|
-
#
|
1297
|
-
#
|
1311
|
+
# <pre>
|
1312
|
+
# !!!ruby
|
1313
|
+
# table.time("updated_at")
|
1314
|
+
# table.time("created_at")
|
1315
|
+
# </pre>
|
1298
1316
|
def timestamps(options={})
|
1299
1317
|
time("created_at", options)
|
1300
1318
|
time("updated_at", options)
|
@@ -1355,8 +1373,7 @@ module Groonga
|
|
1355
1373
|
#
|
1356
1374
|
# @param [String or Symbol] name the column name
|
1357
1375
|
# @param [Hash] options ({}) the options
|
1358
|
-
# @see
|
1359
|
-
# available @options@.
|
1376
|
+
# @see #column #column for available options.
|
1360
1377
|
def tokyo_geo_point(name, options={})
|
1361
1378
|
column(name, "TokyoGeoPoint", options)
|
1362
1379
|
end
|
@@ -1366,8 +1383,7 @@ module Groonga
|
|
1366
1383
|
#
|
1367
1384
|
# @param [String or Symbol] name the column name
|
1368
1385
|
# @param [Hash] options ({}) the options
|
1369
|
-
# @see
|
1370
|
-
# available @options@.
|
1386
|
+
# @see #column #column for available options.
|
1371
1387
|
def wgs84_geo_point(name, options={})
|
1372
1388
|
column(name, "WGS84GeoPoint", options)
|
1373
1389
|
end
|
@@ -1632,8 +1648,8 @@ module Groonga
|
|
1632
1648
|
end
|
1633
1649
|
end
|
1634
1650
|
|
1635
|
-
# スキーマ定義時にGroonga::Schema.create_viewや
|
1636
|
-
# Groonga::Schema#create_viewからブロックに渡されてくる
|
1651
|
+
# スキーマ定義時に {Groonga::Schema.create_view} や
|
1652
|
+
# {Groonga::Schema#create_view} からブロックに渡されてくる
|
1637
1653
|
# オブジェクト
|
1638
1654
|
class ViewDefinition
|
1639
1655
|
# ビューの名前
|
@@ -1671,7 +1687,7 @@ module Groonga
|
|
1671
1687
|
view
|
1672
1688
|
end
|
1673
1689
|
|
1674
|
-
# 名前が_table_のテーブルをビューに追加する。
|
1690
|
+
# 名前が _table_ のテーブルをビューに追加する。
|
1675
1691
|
def add(table)
|
1676
1692
|
table = table.to_s if table.is_a?(Symbol)
|
1677
1693
|
@tables << table
|