groonga-command 1.4.6 → 1.4.7
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 +7 -0
- data/lib/groonga/command/load.rb +13 -1
- data/lib/groonga/command/version.rb +2 -2
- data/test/command/test-load.rb +35 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0516f0f80a6af2fefb12d10390e6f314ecf88e08f1cafc3abc942c92e13a23b
|
4
|
+
data.tar.gz: 67eb82831789e515f65f153d9dd6b2833b0b364b4d80befdb04013ca7343caf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6771fb6bd7beab7ac173819a9164d810240372a2caad156c3b34d86a45d3a79549fda55e2a86aaba17040640fdede581ef3b878f79870ba3bf588f4d0388d88
|
7
|
+
data.tar.gz: 96d88ac9df80ab87c3df8537a0f6280d851cd24af476fc04ccd6439e46f91a80a01ee59c6e0511c8d340cdaabebd1ecfcf651bc16e3d7b3a769997d8e8187048
|
data/doc/text/news.md
CHANGED
data/lib/groonga/command/load.rb
CHANGED
@@ -84,7 +84,19 @@ module Groonga
|
|
84
84
|
unless defined?(::Arrow)
|
85
85
|
raise NotImplementedError, "red-arrow is required"
|
86
86
|
end
|
87
|
-
|
87
|
+
source_lines = (original_source || "").lines
|
88
|
+
if source_lines.size >= 2
|
89
|
+
if /\s--columns\s/ =~ source_lines.first
|
90
|
+
target_columns = columns
|
91
|
+
else
|
92
|
+
target_columns = nil
|
93
|
+
end
|
94
|
+
target_values = JSON.parse(source_lines[1..-1].join(""))
|
95
|
+
else
|
96
|
+
target_columns = columns
|
97
|
+
target_values = values
|
98
|
+
end
|
99
|
+
builder = ArrowTableBuilder.new(target_columns, target_values)
|
88
100
|
builder.build
|
89
101
|
end
|
90
102
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2020 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
|
@@ -16,6 +16,6 @@
|
|
16
16
|
|
17
17
|
module Groonga
|
18
18
|
module Command
|
19
|
-
VERSION = "1.4.
|
19
|
+
VERSION = "1.4.7"
|
20
20
|
end
|
21
21
|
end
|
data/test/command/test-load.rb
CHANGED
@@ -123,7 +123,7 @@ class LoadCommandTest < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
sub_test_case("Array") do
|
126
|
-
def
|
126
|
+
def test_without_columns_argument
|
127
127
|
command = load_command({"values" => [
|
128
128
|
["column1", "column2"],
|
129
129
|
["value1", "value2"],
|
@@ -135,7 +135,7 @@ class LoadCommandTest < Test::Unit::TestCase
|
|
135
135
|
command.build_arrow_table)
|
136
136
|
end
|
137
137
|
|
138
|
-
def
|
138
|
+
def test_with_columns_argument
|
139
139
|
command = load_command({"columns" => ["column1", "column2"].join(", "),
|
140
140
|
"values" => [
|
141
141
|
["value1", "value2"],
|
@@ -168,5 +168,38 @@ class LoadCommandTest < Test::Unit::TestCase
|
|
168
168
|
command.build_arrow_table)
|
169
169
|
end
|
170
170
|
end
|
171
|
+
|
172
|
+
sub_test_case("raw values") do
|
173
|
+
def test_without_columns_argument
|
174
|
+
columns = ["column1", "column2"]
|
175
|
+
command = load_command("columns" => columns.join(","))
|
176
|
+
command.original_source = "load\n" + [
|
177
|
+
columns,
|
178
|
+
["value1", "value2"],
|
179
|
+
["value10", "value20"],
|
180
|
+
].to_json
|
181
|
+
columns = {
|
182
|
+
"column1" => ["value1", "value10"],
|
183
|
+
"column2" => ["value2", "value20"],
|
184
|
+
}
|
185
|
+
assert_equal(Arrow::Table.new(columns),
|
186
|
+
command.build_arrow_table)
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_with_columns_argument
|
190
|
+
columns = ["column1", "column2"]
|
191
|
+
command = load_command("columns" => columns.join(","))
|
192
|
+
command.original_source = "load --columns #{columns.join(",")}\n" + [
|
193
|
+
["value1", "value2"],
|
194
|
+
["value10", "value20"],
|
195
|
+
].to_json
|
196
|
+
columns = {
|
197
|
+
"column1" => ["value1", "value10"],
|
198
|
+
"column2" => ["value2", "value20"],
|
199
|
+
}
|
200
|
+
assert_equal(Arrow::Table.new(columns),
|
201
|
+
command.build_arrow_table)
|
202
|
+
end
|
203
|
+
end
|
171
204
|
end
|
172
205
|
end
|