groonga-command 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +8 -0
- data/lib/groonga/command/drilldownable.rb +150 -0
- data/lib/groonga/command/logical-select.rb +12 -57
- data/lib/groonga/command/select.rb +5 -139
- data/lib/groonga/command/sliceable.rb +82 -0
- data/lib/groonga/command/version.rb +1 -1
- data/test/command/test-logical-select.rb +139 -4
- data/test/command/test-select.rb +49 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce9859484daef364ba74d82aa2391c0f1adbf7c28370b3d8ca974cb7dd18c451
|
4
|
+
data.tar.gz: c59cf788e9ac27ec0eea8e7ae330d62a48b6a48af000ef72d2c284b730969c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801903b0deea2eaccb58f175e3eca3557f3783c1e627986016c65ce82709a7bc3f3ddbe882fd0fed9146e94819d0e8fe68ee836f321b0b5c6a37c72dc216c615
|
7
|
+
data.tar.gz: 7fca220f7e886b28753a6610a228c4deffa2b2e18d0946d44c5179920a9452cc1dae9eed3101c481c61c659151c4f391fc979d3342a38313f0a1a2370d6bd556
|
data/doc/text/news.md
CHANGED
@@ -0,0 +1,150 @@
|
|
1
|
+
# Copyright (C) 2019 Sutou Kouhei <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Groonga
|
18
|
+
module Command
|
19
|
+
module Drilldownable
|
20
|
+
# @return [String] `drilldown` parameter value.
|
21
|
+
#
|
22
|
+
# @since 1.1.3
|
23
|
+
def drilldown
|
24
|
+
self[:drilldown]
|
25
|
+
end
|
26
|
+
|
27
|
+
def drilldowns
|
28
|
+
@drilldowns ||= array_value(:drilldown)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String, nil] The filter for the drilled down result.
|
32
|
+
#
|
33
|
+
# @since 1.3.3
|
34
|
+
def drilldown_filter
|
35
|
+
self[:drilldown_filter]
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] `drilldown_sortby` parameter value.
|
39
|
+
#
|
40
|
+
# @since 1.1.3
|
41
|
+
#
|
42
|
+
# @deprecated since 1.4.4. Use `drilldown_sort_keys` instead.
|
43
|
+
def drilldown_sortby
|
44
|
+
self[:drilldown_sortby]
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [::Array<String>] The sort keys for drilldowns.
|
48
|
+
#
|
49
|
+
# @since 1.2.8
|
50
|
+
def drilldown_sort_keys
|
51
|
+
value = self[:drilldown_sort_keys] || self[:drilldown_sortby] || ""
|
52
|
+
parse_array_value(value)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String] `drilldown_output_columns` parameter value.
|
56
|
+
#
|
57
|
+
# @since 1.1.3
|
58
|
+
def drilldown_output_columns
|
59
|
+
self[:drilldown_output_columns]
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String] `drilldown_offset` parameter value.
|
63
|
+
#
|
64
|
+
# @since 1.1.3
|
65
|
+
def drilldown_offset
|
66
|
+
integer_value(:drilldown_offset)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [String] `drilldown_limit` parameter value.
|
70
|
+
#
|
71
|
+
# @since 1.1.3
|
72
|
+
def drilldown_limit
|
73
|
+
integer_value(:drilldown_limit)
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String] `drilldown_calc_types` parameter value.
|
77
|
+
#
|
78
|
+
# @since 1.1.3
|
79
|
+
def drilldown_calc_types
|
80
|
+
self[:drilldown_calc_types]
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [String] `drilldown_calc_target` parameter value.
|
84
|
+
#
|
85
|
+
# @since 1.1.3
|
86
|
+
def drilldown_calc_target
|
87
|
+
self[:drilldown_calc_target]
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [::Hash<String, Drilldown>] The labeled drilldowns.
|
91
|
+
#
|
92
|
+
# @since 1.2.8
|
93
|
+
def labeled_drilldowns
|
94
|
+
@labeled_drilldowns ||= parse_labeled_drilldowns
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def parse_labeled_drilldowns
|
99
|
+
raw_labeled_drilldowns = {}
|
100
|
+
@arguments.each do |name, value|
|
101
|
+
case name.to_s
|
102
|
+
when /\Adrilldowns?\[(.+?)\]\.(.+?)\z/
|
103
|
+
label = $1
|
104
|
+
parameter_name = $2
|
105
|
+
raw_labeled_drilldowns[label] ||= {}
|
106
|
+
raw_labeled_drilldowns[label][parameter_name] = value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
build_labeled_drilldowns(raw_labeled_drilldowns)
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_labeled_drilldowns(raw_labeled_drilldowns)
|
113
|
+
labeled_drilldowns = {}
|
114
|
+
raw_labeled_drilldowns.each do |label, raw_drilldown|
|
115
|
+
keys = parse_array_value(raw_drilldown["keys"])
|
116
|
+
sort_keys = raw_drilldown["sort_keys"] || raw_drilldown["sortby"]
|
117
|
+
sort_keys = parse_array_value(sort_keys)
|
118
|
+
output_columns = parse_array_value(raw_drilldown["output_columns"])
|
119
|
+
offset = parse_integer_value(raw_drilldown["offset"])
|
120
|
+
limit = parse_integer_value(raw_drilldown["limit"])
|
121
|
+
calc_types = parse_array_value(raw_drilldown["calc_types"])
|
122
|
+
calc_target = raw_drilldown["calc_target"]
|
123
|
+
filter = raw_drilldown["filter"]
|
124
|
+
drilldown = Drilldown.new(keys,
|
125
|
+
sort_keys,
|
126
|
+
output_columns,
|
127
|
+
offset,
|
128
|
+
limit,
|
129
|
+
calc_types,
|
130
|
+
calc_target,
|
131
|
+
filter,
|
132
|
+
label)
|
133
|
+
labeled_drilldowns[label] = drilldown
|
134
|
+
end
|
135
|
+
labeled_drilldowns
|
136
|
+
end
|
137
|
+
|
138
|
+
class Drilldown < Struct.new(:keys,
|
139
|
+
:sort_keys,
|
140
|
+
:output_columns,
|
141
|
+
:offset,
|
142
|
+
:limit,
|
143
|
+
:calc_types,
|
144
|
+
:calc_target,
|
145
|
+
:filter,
|
146
|
+
:label)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015-
|
1
|
+
# Copyright (C) 2015-2019 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,7 +15,9 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
require "groonga/command/base"
|
18
|
+
require "groonga/command/drilldownable"
|
18
19
|
require "groonga/command/searchable"
|
20
|
+
require "groonga/command/sliceable"
|
19
21
|
|
20
22
|
module Groonga
|
21
23
|
module Command
|
@@ -23,7 +25,9 @@ module Groonga
|
|
23
25
|
#
|
24
26
|
# @since 1.1.3
|
25
27
|
class LogicalSelect < Base
|
28
|
+
include Drilldownable
|
26
29
|
include Searchable
|
30
|
+
include Sliceable
|
27
31
|
|
28
32
|
class << self
|
29
33
|
def command_name
|
@@ -51,6 +55,13 @@ module Groonga
|
|
51
55
|
:drilldown_calc_types,
|
52
56
|
:drilldown_calc_target,
|
53
57
|
:sort_keys,
|
58
|
+
:drilldown_sort_keys,
|
59
|
+
:match_columns,
|
60
|
+
:query,
|
61
|
+
:drilldown_filter,
|
62
|
+
:load_table,
|
63
|
+
:load_columns,
|
64
|
+
:load_values,
|
54
65
|
]
|
55
66
|
end
|
56
67
|
end
|
@@ -134,62 +145,6 @@ module Groonga
|
|
134
145
|
integer_value(:limit)
|
135
146
|
end
|
136
147
|
|
137
|
-
# @return [String] `drilldown` parameter value.
|
138
|
-
#
|
139
|
-
# @since 1.1.3
|
140
|
-
def drilldown
|
141
|
-
self[:drilldown]
|
142
|
-
end
|
143
|
-
|
144
|
-
# @return [Array<String>] drilldown keys.
|
145
|
-
#
|
146
|
-
# @since 1.1.3
|
147
|
-
def drilldowns
|
148
|
-
@drilldowns ||= array_value(:drilldown)
|
149
|
-
end
|
150
|
-
|
151
|
-
# @return [String] `drilldown_sortby` parameter value.
|
152
|
-
#
|
153
|
-
# @since 1.1.3
|
154
|
-
def drilldown_sortby
|
155
|
-
self[:drilldown_sortby]
|
156
|
-
end
|
157
|
-
|
158
|
-
# @return [String] `drilldown_output_columns` parameter value.
|
159
|
-
#
|
160
|
-
# @since 1.1.3
|
161
|
-
def drilldown_output_columns
|
162
|
-
self[:drilldown_output_columns]
|
163
|
-
end
|
164
|
-
|
165
|
-
# @return [String] `drilldown_offset` parameter value.
|
166
|
-
#
|
167
|
-
# @since 1.1.3
|
168
|
-
def drilldown_offset
|
169
|
-
integer_value(:drilldown_offset)
|
170
|
-
end
|
171
|
-
|
172
|
-
# @return [String] `drilldown_limit` parameter value.
|
173
|
-
#
|
174
|
-
# @since 1.1.3
|
175
|
-
def drilldown_limit
|
176
|
-
integer_value(:drilldown_limit)
|
177
|
-
end
|
178
|
-
|
179
|
-
# @return [String] `drilldown_calc_types` parameter value.
|
180
|
-
#
|
181
|
-
# @since 1.1.3
|
182
|
-
def drilldown_calc_types
|
183
|
-
self[:drilldown_calc_types]
|
184
|
-
end
|
185
|
-
|
186
|
-
# @return [String] `drilldown_calc_target` parameter value.
|
187
|
-
#
|
188
|
-
# @since 1.1.3
|
189
|
-
def drilldown_calc_target
|
190
|
-
self[:drilldown_calc_target]
|
191
|
-
end
|
192
|
-
|
193
148
|
# @return [::Array<String>] The sort keys.
|
194
149
|
#
|
195
150
|
# @since 1.4.2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2019 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -16,12 +16,16 @@
|
|
16
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
17
|
|
18
18
|
require "groonga/command/base"
|
19
|
+
require "groonga/command/drilldownable"
|
19
20
|
require "groonga/command/searchable"
|
21
|
+
require "groonga/command/sliceable"
|
20
22
|
|
21
23
|
module Groonga
|
22
24
|
module Command
|
23
25
|
class Select < Base
|
26
|
+
include Drilldownable
|
24
27
|
include Searchable
|
28
|
+
include Sliceable
|
25
29
|
|
26
30
|
class << self
|
27
31
|
def command_name
|
@@ -88,150 +92,12 @@ module Groonga
|
|
88
92
|
self[:filter]
|
89
93
|
end
|
90
94
|
|
91
|
-
def drilldowns
|
92
|
-
@drilldowns ||= array_value(:drilldown)
|
93
|
-
end
|
94
|
-
|
95
|
-
# @return [String, nil] The filter for the drilled down result.
|
96
|
-
#
|
97
|
-
# @since 1.3.3
|
98
|
-
def drilldown_filter
|
99
|
-
self[:drilldown_filter]
|
100
|
-
end
|
101
|
-
|
102
|
-
# @return [::Array<String>] The sort keys for drilldowns.
|
103
|
-
#
|
104
|
-
# @since 1.2.8
|
105
|
-
def drilldown_sort_keys
|
106
|
-
value = self[:drilldown_sort_keys] || self[:drilldown_sortby] || ""
|
107
|
-
parse_array_value(value)
|
108
|
-
end
|
109
|
-
|
110
|
-
# @return [::Hash<String, Drilldown>] The labeled drilldowns.
|
111
|
-
#
|
112
|
-
# @since 1.2.8
|
113
|
-
def labeled_drilldowns
|
114
|
-
@labeled_drilldowns ||= parse_labeled_drilldowns
|
115
|
-
end
|
116
|
-
|
117
|
-
# @return [::Hash<String, Slice>] The slices.
|
118
|
-
#
|
119
|
-
# @since 1.3.0
|
120
|
-
def slices
|
121
|
-
@slices ||= parse_slices
|
122
|
-
end
|
123
|
-
|
124
95
|
# TODO: We should return `::Array` instead of raw
|
125
96
|
# `output_columns` value. But it breaks backward
|
126
97
|
# compatibility...
|
127
98
|
def output_columns
|
128
99
|
self[:output_columns]
|
129
100
|
end
|
130
|
-
|
131
|
-
private
|
132
|
-
def parse_labeled_drilldowns
|
133
|
-
raw_labeled_drilldowns = {}
|
134
|
-
@arguments.each do |name, value|
|
135
|
-
case name.to_s
|
136
|
-
when /\Adrilldowns?\[(.+?)\]\.(.+?)\z/
|
137
|
-
label = $1
|
138
|
-
parameter_name = $2
|
139
|
-
raw_labeled_drilldowns[label] ||= {}
|
140
|
-
raw_labeled_drilldowns[label][parameter_name] = value
|
141
|
-
end
|
142
|
-
end
|
143
|
-
build_labeled_drilldowns(raw_labeled_drilldowns)
|
144
|
-
end
|
145
|
-
|
146
|
-
def build_labeled_drilldowns(raw_labeled_drilldowns)
|
147
|
-
labeled_drilldowns = {}
|
148
|
-
raw_labeled_drilldowns.each do |label, raw_drilldown|
|
149
|
-
keys = parse_array_value(raw_drilldown["keys"])
|
150
|
-
sort_keys = raw_drilldown["sort_keys"] || raw_drilldown["sortby"]
|
151
|
-
sort_keys = parse_array_value(sort_keys)
|
152
|
-
output_columns = parse_array_value(raw_drilldown["output_columns"])
|
153
|
-
offset = parse_integer_value(raw_drilldown["offset"])
|
154
|
-
limit = parse_integer_value(raw_drilldown["limit"])
|
155
|
-
calc_types = parse_array_value(raw_drilldown["calc_types"])
|
156
|
-
calc_target = raw_drilldown["calc_target"]
|
157
|
-
filter = raw_drilldown["filter"]
|
158
|
-
drilldown = Drilldown.new(keys,
|
159
|
-
sort_keys,
|
160
|
-
output_columns,
|
161
|
-
offset,
|
162
|
-
limit,
|
163
|
-
calc_types,
|
164
|
-
calc_target,
|
165
|
-
filter,
|
166
|
-
label)
|
167
|
-
labeled_drilldowns[label] = drilldown
|
168
|
-
end
|
169
|
-
labeled_drilldowns
|
170
|
-
end
|
171
|
-
|
172
|
-
def parse_slices
|
173
|
-
raw_slices = {}
|
174
|
-
@arguments.each do |name, value|
|
175
|
-
case name.to_s
|
176
|
-
when /\Aslices?\[(.+?)\]\.(.+?)\z/
|
177
|
-
label = $1
|
178
|
-
parameter_name = $2
|
179
|
-
raw_slices[label] ||= {}
|
180
|
-
raw_slices[label][parameter_name] = value
|
181
|
-
end
|
182
|
-
end
|
183
|
-
build_slices(raw_slices)
|
184
|
-
end
|
185
|
-
|
186
|
-
def build_slices(raw_slices)
|
187
|
-
slices = {}
|
188
|
-
raw_slices.each do |label, raw_slice|
|
189
|
-
match_columns = raw_slice["match_columns"]
|
190
|
-
query = raw_slice["query"]
|
191
|
-
query_expander = raw_slice["query_expander"]
|
192
|
-
query_flags = parse_flags_value(raw_slice["query_flags"])
|
193
|
-
filter = raw_slice["filter"]
|
194
|
-
sort_keys = parse_array_value(raw_slice["sort_keys"])
|
195
|
-
output_columns = parse_array_value(raw_slice["output_columns"])
|
196
|
-
offset = parse_integer_value(raw_slice["offset"])
|
197
|
-
limit = parse_integer_value(raw_slice["limit"])
|
198
|
-
slices[label] = Slice.new(label,
|
199
|
-
match_columns,
|
200
|
-
query,
|
201
|
-
query_expander,
|
202
|
-
query_flags,
|
203
|
-
filter,
|
204
|
-
sort_keys,
|
205
|
-
output_columns,
|
206
|
-
offset,
|
207
|
-
limit)
|
208
|
-
end
|
209
|
-
slices
|
210
|
-
end
|
211
|
-
|
212
|
-
class Drilldown < Struct.new(:keys,
|
213
|
-
:sort_keys,
|
214
|
-
:output_columns,
|
215
|
-
:offset,
|
216
|
-
:limit,
|
217
|
-
:calc_types,
|
218
|
-
:calc_target,
|
219
|
-
:filter,
|
220
|
-
:label)
|
221
|
-
end
|
222
|
-
|
223
|
-
# @since 1.3.1
|
224
|
-
class Slice < Struct.new(:label,
|
225
|
-
:match_columns,
|
226
|
-
:query,
|
227
|
-
:query_expander,
|
228
|
-
:query_flags,
|
229
|
-
:filter,
|
230
|
-
:sort_keys,
|
231
|
-
:output_columns,
|
232
|
-
:offset,
|
233
|
-
:limit)
|
234
|
-
end
|
235
101
|
end
|
236
102
|
end
|
237
103
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright (C) 2019 Sutou Kouhei <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Groonga
|
18
|
+
module Command
|
19
|
+
module Sliceable
|
20
|
+
# @return [::Hash<String, Slice>] The slices.
|
21
|
+
#
|
22
|
+
# @since 1.3.0
|
23
|
+
def slices
|
24
|
+
@slices ||= parse_slices
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def parse_slices
|
29
|
+
raw_slices = {}
|
30
|
+
@arguments.each do |name, value|
|
31
|
+
case name.to_s
|
32
|
+
when /\Aslices?\[(.+?)\]\.(.+?)\z/
|
33
|
+
label = $1
|
34
|
+
parameter_name = $2
|
35
|
+
raw_slices[label] ||= {}
|
36
|
+
raw_slices[label][parameter_name] = value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
build_slices(raw_slices)
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_slices(raw_slices)
|
43
|
+
slices = {}
|
44
|
+
raw_slices.each do |label, raw_slice|
|
45
|
+
match_columns = raw_slice["match_columns"]
|
46
|
+
query = raw_slice["query"]
|
47
|
+
query_expander = raw_slice["query_expander"]
|
48
|
+
query_flags = parse_flags_value(raw_slice["query_flags"])
|
49
|
+
filter = raw_slice["filter"]
|
50
|
+
sort_keys = parse_array_value(raw_slice["sort_keys"])
|
51
|
+
output_columns = parse_array_value(raw_slice["output_columns"])
|
52
|
+
offset = parse_integer_value(raw_slice["offset"])
|
53
|
+
limit = parse_integer_value(raw_slice["limit"])
|
54
|
+
slices[label] = Slice.new(label,
|
55
|
+
match_columns,
|
56
|
+
query,
|
57
|
+
query_expander,
|
58
|
+
query_flags,
|
59
|
+
filter,
|
60
|
+
sort_keys,
|
61
|
+
output_columns,
|
62
|
+
offset,
|
63
|
+
limit)
|
64
|
+
end
|
65
|
+
slices
|
66
|
+
end
|
67
|
+
|
68
|
+
# @since 1.3.1
|
69
|
+
class Slice < Struct.new(:label,
|
70
|
+
:match_columns,
|
71
|
+
:query,
|
72
|
+
:query_expander,
|
73
|
+
:query_flags,
|
74
|
+
:filter,
|
75
|
+
:sort_keys,
|
76
|
+
:output_columns,
|
77
|
+
:offset,
|
78
|
+
:limit)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 Kouhei
|
1
|
+
# Copyright (C) 2015-2019 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -160,6 +160,13 @@ class LogicalSelectCommandTest < Test::Unit::TestCase
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
+
class SortKeysTest < self
|
164
|
+
def test_reader
|
165
|
+
command = logical_select_command(:sort_keys => "-_score, _key")
|
166
|
+
assert_equal(["-_score", "_key"], command.sort_keys)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
163
170
|
class DrilldownTest < self
|
164
171
|
def test_reader
|
165
172
|
command = logical_select_command(:drilldown => "name")
|
@@ -209,10 +216,138 @@ class LogicalSelectCommandTest < Test::Unit::TestCase
|
|
209
216
|
end
|
210
217
|
end
|
211
218
|
|
212
|
-
class
|
219
|
+
class DrilldownFilterTest < self
|
213
220
|
def test_reader
|
214
|
-
command = logical_select_command(:
|
215
|
-
assert_equal(
|
221
|
+
command = logical_select_command(:drilldown_filter => "_nsubrecs > 1")
|
222
|
+
assert_equal("_nsubrecs > 1",
|
223
|
+
command.drilldown_filter)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
class DrilldownSortKeysTest < self
|
228
|
+
def test_reader
|
229
|
+
command = logical_select_command(:drilldown_sort_keys => "-_nsubrecs,_key")
|
230
|
+
assert_equal(["-_nsubrecs", "_key"],
|
231
|
+
command.drilldown_sort_keys)
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_sortby
|
235
|
+
command = logical_select_command(:drilldown_sortby => "-_nsubrecs,_key")
|
236
|
+
assert_equal(["-_nsubrecs", "_key"],
|
237
|
+
command.drilldown_sort_keys)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
class LabeledDrilldownsTest < self
|
242
|
+
def test_multiple
|
243
|
+
parameters = {
|
244
|
+
"drilldowns[tag].keys" => "tag",
|
245
|
+
"drilldowns[tag].sort_keys" => "-_nsubrecs,_key",
|
246
|
+
"drilldowns[tag].output_columns" => "_key,_nsubrecs,_min,_max",
|
247
|
+
"drilldowns[tag].offset" => "1",
|
248
|
+
"drilldowns[tag].limit" => "10",
|
249
|
+
"drilldowns[tag].calc_types" => "MIN,MAX",
|
250
|
+
"drilldowns[tag].calc_target" => "_nsubrecs",
|
251
|
+
"drilldowns[tag].filter" => "_nsubrecs > 1",
|
252
|
+
|
253
|
+
"drilldowns[author_tag].keys" => "author,tag",
|
254
|
+
"drilldowns[author_tag].sort_keys" => "_value.author",
|
255
|
+
"drilldowns[author_tag].output_columns" => "_value.author,_nsubrecs",
|
256
|
+
}
|
257
|
+
command = logical_select_command(parameters)
|
258
|
+
drilldowns = {
|
259
|
+
"author_tag" => drilldown(:label => "author_tag",
|
260
|
+
:keys => ["author", "tag"],
|
261
|
+
:sort_keys => ["_value.author"],
|
262
|
+
:output_columns => [
|
263
|
+
"_value.author",
|
264
|
+
"_nsubrecs",
|
265
|
+
]),
|
266
|
+
"tag" => drilldown(:label => "tag",
|
267
|
+
:keys => ["tag"],
|
268
|
+
:sort_keys => ["-_nsubrecs", "_key"],
|
269
|
+
:output_columns => [
|
270
|
+
"_key",
|
271
|
+
"_nsubrecs",
|
272
|
+
"_min",
|
273
|
+
"_max",
|
274
|
+
],
|
275
|
+
:offset => 1,
|
276
|
+
:limit => 10,
|
277
|
+
:calc_types => ["MIN", "MAX"],
|
278
|
+
:calc_target => "_nsubrecs",
|
279
|
+
:filter => "_nsubrecs > 1"),
|
280
|
+
}
|
281
|
+
assert_equal(drilldowns,
|
282
|
+
command.labeled_drilldowns)
|
283
|
+
end
|
284
|
+
|
285
|
+
def drilldown(parameters)
|
286
|
+
drilldown = Groonga::Command::LogicalSelect::Drilldown.new
|
287
|
+
parameters.each do |key, value|
|
288
|
+
drilldown[key] = value
|
289
|
+
end
|
290
|
+
drilldown
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
class SlicesTest < self
|
295
|
+
def test_full
|
296
|
+
parameters = {
|
297
|
+
"slices[book_alice].match_columns" => "tag",
|
298
|
+
"slices[book_alice].query" => "Book",
|
299
|
+
"slices[book_alice].query_expander" => "Synonyms.tag",
|
300
|
+
"slices[book_alice].query_flags" => "ALLOW_COLUMN|ALLOW_LEADING_NOT",
|
301
|
+
"slices[book_alice].filter" => "user == \"alice\"",
|
302
|
+
"slices[book_alice].sort_keys" => "_score, user",
|
303
|
+
"slices[book_alice].offset" => "10",
|
304
|
+
"slices[book_alice].limit" => "25",
|
305
|
+
}
|
306
|
+
command = logical_select_command(parameters)
|
307
|
+
|
308
|
+
slices = {
|
309
|
+
"book_alice" => slice(:label => "book_alice",
|
310
|
+
:match_columns => "tag",
|
311
|
+
:query => "Book",
|
312
|
+
:query_expander => "Synonyms.tag",
|
313
|
+
:query_flags => [
|
314
|
+
"ALLOW_COLUMN",
|
315
|
+
"ALLOW_LEADING_NOT",
|
316
|
+
],
|
317
|
+
:filter => "user == \"alice\"",
|
318
|
+
:sort_keys => ["_score", "user"],
|
319
|
+
:offset => 10,
|
320
|
+
:limit => 25),
|
321
|
+
}
|
322
|
+
assert_equal(slices, command.slices)
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_multiple
|
326
|
+
parameters = {
|
327
|
+
"slices[groonga].query" => "tag:Groonga",
|
328
|
+
"slices[rroonga].filter" => "tag == Rroonga",
|
329
|
+
"slices[rroonga].sort_keys" => "date",
|
330
|
+
"slices[rroonga].output_columns" => "_key, date",
|
331
|
+
}
|
332
|
+
command = logical_select_command(parameters)
|
333
|
+
|
334
|
+
slices = {
|
335
|
+
"groonga" => slice(:label => "groonga",
|
336
|
+
:query => "tag:Groonga"),
|
337
|
+
"rroonga" => slice(:label => "rroonga",
|
338
|
+
:filter => "tag == Rroonga",
|
339
|
+
:sort_keys => ["date"],
|
340
|
+
:output_columns => ["_key", "date"]),
|
341
|
+
}
|
342
|
+
assert_equal(slices, command.slices)
|
343
|
+
end
|
344
|
+
|
345
|
+
def slice(parameters)
|
346
|
+
slice = Groonga::Command::LogicalSelect::Slice.new
|
347
|
+
parameters.each do |key, value|
|
348
|
+
slice[key] = value
|
349
|
+
end
|
350
|
+
slice
|
216
351
|
end
|
217
352
|
end
|
218
353
|
end
|
data/test/command/test-select.rb
CHANGED
@@ -158,6 +158,55 @@ class SelectCommandTest < Test::Unit::TestCase
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
class DrilldownTest < self
|
162
|
+
def test_reader
|
163
|
+
command = select_command(:drilldown => "name")
|
164
|
+
assert_equal("name", command.drilldown)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
class DrilldownSortbyTest < self
|
169
|
+
def test_reader
|
170
|
+
command = select_command(:drilldown_sortby => "_nsubrecs")
|
171
|
+
assert_equal("_nsubrecs", command.drilldown_sortby)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class DrilldownOutputColumnsTest < self
|
176
|
+
def test_reader
|
177
|
+
command = select_command(:drilldown_output_columns => "name, _nsubrecs")
|
178
|
+
assert_equal("name, _nsubrecs", command.drilldown_output_columns)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class DrilldownOffsetTest < self
|
183
|
+
def test_reader
|
184
|
+
command = select_command(:drilldown_offset => "5")
|
185
|
+
assert_equal(5, command.drilldown_offset)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class DrilldownLimitTest < self
|
190
|
+
def test_reader
|
191
|
+
command = select_command(:drilldown_limit => "10")
|
192
|
+
assert_equal(10, command.drilldown_limit)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
class DrilldownCalcTypesTest < self
|
197
|
+
def test_reader
|
198
|
+
command = select_command(:drilldown_calc_types => "MIN,AVG")
|
199
|
+
assert_equal("MIN,AVG", command.drilldown_calc_types)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class DrilldownCalcTargetTest < self
|
204
|
+
def test_reader
|
205
|
+
command = select_command(:drilldown_calc_target => "n_occurred")
|
206
|
+
assert_equal("n_occurred", command.drilldown_calc_target)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
161
210
|
class DrilldownFilterTest < self
|
162
211
|
def test_reader
|
163
212
|
command = select_command(:drilldown_filter => "_nsubrecs > 1")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/groonga/command/config-get.rb
|
148
148
|
- lib/groonga/command/config-set.rb
|
149
149
|
- lib/groonga/command/delete.rb
|
150
|
+
- lib/groonga/command/drilldownable.rb
|
150
151
|
- lib/groonga/command/dump.rb
|
151
152
|
- lib/groonga/command/error.rb
|
152
153
|
- lib/groonga/command/format/command.rb
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- lib/groonga/command/searchable.rb
|
185
186
|
- lib/groonga/command/select.rb
|
186
187
|
- lib/groonga/command/shutdown.rb
|
188
|
+
- lib/groonga/command/sliceable.rb
|
187
189
|
- lib/groonga/command/status.rb
|
188
190
|
- lib/groonga/command/suggest.rb
|
189
191
|
- lib/groonga/command/table-copy.rb
|