groonga-client-rails 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5944798b653ef748f6429cdd1fdb0a558c89654
|
4
|
+
data.tar.gz: 1c78060794d0cf29cef4557f57ff9d1e13d50b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6de16e66a42cd4cf2eb103c904dd52d5709c7de1f6d6de76b3ab493adc8fb28a656cb35a9eeb4cec175a09d9beecb73d68535787690b57eade16fd05868a3237
|
7
|
+
data.tar.gz: 48f6ef9c6225805038aca00ca820835676fe1fc6752dbe8259c5618265d66aed2f8672f60627a7ff5ab203d10c6cbfd8dcb1d57369197cc94a86fba7af924426
|
data/doc/text/news.md
CHANGED
@@ -60,6 +60,10 @@ module Groonga
|
|
60
60
|
@options[:type] || "Text"
|
61
61
|
end
|
62
62
|
|
63
|
+
def normalizer
|
64
|
+
@options[:normalizer]
|
65
|
+
end
|
66
|
+
|
63
67
|
def text_family_type?
|
64
68
|
case type
|
65
69
|
when "ShortText", "Text", "LongText"
|
@@ -73,6 +77,10 @@ module Groonga
|
|
73
77
|
@options[:vector]
|
74
78
|
end
|
75
79
|
|
80
|
+
def reference?
|
81
|
+
@options[:reference]
|
82
|
+
end
|
83
|
+
|
76
84
|
def have_index?
|
77
85
|
@options[:index]
|
78
86
|
end
|
@@ -33,11 +33,10 @@ module Groonga
|
|
33
33
|
current_table = find_current_table
|
34
34
|
return if current_table # TODO: validation
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
36
|
+
execute(:table_create,
|
37
|
+
:name => @schema.table,
|
38
|
+
:flags => "TABLE_PAT_KEY",
|
39
|
+
:key_type => "ShortText")
|
41
40
|
end
|
42
41
|
|
43
42
|
def sync_columns
|
@@ -49,26 +48,50 @@ module Groonga
|
|
49
48
|
|
50
49
|
def sync_column(column, current_column)
|
51
50
|
if current_column.nil?
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
flags = []
|
52
|
+
if column.vector?
|
53
|
+
flags << "COLUMN_VECTOR"
|
54
|
+
else
|
55
|
+
flags << "COLUMN_SCALAR"
|
56
|
+
end
|
57
|
+
if column.reference?
|
58
|
+
reference_table_name = generate_reference_table_name(column)
|
59
|
+
sync_reference_table(column, reference_table_name)
|
60
|
+
type = reference_table_name
|
61
|
+
else
|
62
|
+
type = column.type
|
63
63
|
end
|
64
|
+
execute(:column_create,
|
65
|
+
:table => @schema.table,
|
66
|
+
:name => column.name,
|
67
|
+
:type => type,
|
68
|
+
:flags => flags.join("|"))
|
64
69
|
end
|
65
70
|
|
66
71
|
sync_column_index(column, current_column)
|
67
72
|
end
|
68
73
|
|
74
|
+
def sync_reference_table(column, reference_table_name)
|
75
|
+
return if @current_schema.tables[reference_table_name]
|
76
|
+
|
77
|
+
parameters = {
|
78
|
+
:name => reference_table_name,
|
79
|
+
:flags => "TABLE_PAT_KEY",
|
80
|
+
}
|
81
|
+
parameters[:key_type] = column.type
|
82
|
+
if column.text_family_type?
|
83
|
+
parameters[:normalizer] = decide_normalizer(column.normalizer)
|
84
|
+
end
|
85
|
+
execute(:table_create, parameters)
|
86
|
+
end
|
87
|
+
|
69
88
|
def sync_column_index(column, current_column)
|
70
89
|
if column.have_index?
|
71
|
-
|
90
|
+
if column.reference?
|
91
|
+
lexicon_name = generate_reference_table_name(column)
|
92
|
+
else
|
93
|
+
lexicon_name = generate_lexicon_name(column)
|
94
|
+
end
|
72
95
|
index_column_name = "index"
|
73
96
|
if current_column
|
74
97
|
indexes = current_column.indexes
|
@@ -78,7 +101,7 @@ module Groonga
|
|
78
101
|
indexes.each do |index|
|
79
102
|
return if index.full_name == "#{lexicon_name}.#{index_column_name}"
|
80
103
|
end
|
81
|
-
sync_lexicon(column, lexicon_name)
|
104
|
+
sync_lexicon(column, lexicon_name) unless column.reference?
|
82
105
|
create_index_column(column, lexicon_name, index_column_name)
|
83
106
|
else
|
84
107
|
remove_indexes(current_column)
|
@@ -95,37 +118,35 @@ module Groonga
|
|
95
118
|
if column.have_full_text_search_index?
|
96
119
|
parameters[:key_type] = "ShortText"
|
97
120
|
parameters[:default_tokenizer] = "TokenBigram"
|
98
|
-
parameters[:normalizer] =
|
121
|
+
parameters[:normalizer] = decide_normalizer(column.normalizer)
|
122
|
+
elsif column.reference?
|
123
|
+
parameters[:key_type] = generate_reference_table_name(column)
|
99
124
|
else
|
100
125
|
parameters[:key_type] = column.type
|
101
126
|
if column.text_family_type?
|
102
|
-
parameters[:normalizer] =
|
127
|
+
parameters[:normalizer] = decide_normalizer(column.normalizer)
|
103
128
|
end
|
104
129
|
end
|
105
|
-
|
106
|
-
client.table_create(parameters)
|
107
|
-
end
|
130
|
+
execute(:table_create, parameters)
|
108
131
|
end
|
109
132
|
|
110
133
|
def create_index_column(column, lexicon_name, index_column_name)
|
111
134
|
flags = "COLUMN_INDEX"
|
112
135
|
flags += "|WITH_POSITION" if column.have_full_text_search_index?
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
136
|
+
execute(:column_create,
|
137
|
+
:table => lexicon_name,
|
138
|
+
:name => index_column_name,
|
139
|
+
:flags => flags,
|
140
|
+
:type => @schema.table,
|
141
|
+
:source => column.name)
|
120
142
|
end
|
121
143
|
|
122
144
|
def remove_indexes(current_column)
|
123
145
|
return if current_column.nil?
|
124
146
|
current_column.indexes.each do |index|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
147
|
+
execute(:column_remove,
|
148
|
+
:table => index.table.name,
|
149
|
+
:name => index.name)
|
129
150
|
end
|
130
151
|
end
|
131
152
|
|
@@ -141,6 +162,32 @@ module Groonga
|
|
141
162
|
current_table.columns
|
142
163
|
end
|
143
164
|
end
|
165
|
+
|
166
|
+
def decide_normalizer(custom_normalizer)
|
167
|
+
if custom_normalizer == false
|
168
|
+
nil
|
169
|
+
else
|
170
|
+
custom_normalizer || "NormalizerAuto"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def execute(name, parameters)
|
175
|
+
Client.open do |client|
|
176
|
+
response = client.execute(name, parameters)
|
177
|
+
unless response.success?
|
178
|
+
raise Client::Request::ErrorResponse.new(response)
|
179
|
+
end
|
180
|
+
response
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def generate_reference_table_name(column)
|
185
|
+
"reference_#{@schema.table}_#{column.name}"
|
186
|
+
end
|
187
|
+
|
188
|
+
def generate_lexicon_name(column)
|
189
|
+
"lexicon_#{@schema.table}_#{column.name}"
|
190
|
+
end
|
144
191
|
end
|
145
192
|
end
|
146
193
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-client-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: groonga-client
|