groonga-client 0.6.6 → 0.6.8

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
  SHA256:
3
- metadata.gz: ad8ac6fe851f63509ad13e5c8abb1541ff2f47631764b86bc23ffc85719ae56a
4
- data.tar.gz: 558bc6f1e08568791ca791a3be107b9f075864096bf003ca9cb37dc273a7479b
3
+ metadata.gz: 5eff655174ca6884d2bfb486f8bbdf482f1eb01f9cccc0340670cce03a6233ea
4
+ data.tar.gz: 3b98a877d32035990fa3f955fbd540b9e20ad9b5757c86dcdc855114c82713eb
5
5
  SHA512:
6
- metadata.gz: 9bde0f05e3d9a17f545bacad7cd6c91099ea65e1371d015860b5f18d714b31d875ba615b21ac6c8bba15333ce7f760b673c6ecf31e8daa8ebc726b79f53618a8
7
- data.tar.gz: e992b6e14dac0073485a909886c128acca19af991a9d45dc89a57ed1557754a9ab5fe38edd687bcbd86a571dc0155264752b671cf1861e2353c9a12f40309507
6
+ metadata.gz: 0ab452bca052b4258c0271960c7ff9689cea77cbb2b642f224195809361bdf6d7e18ec1347d01bb558aed0496f0e970f97d1df9ef0b5743a8d861a9e4dcd1639
7
+ data.tar.gz: 186fa2f3260fe48bc56295fed075fc9617f9b9f559390f63a2a3ca7f37cd75e9db07ab0aae63959ed605c44656cdb878896381068fad6d81c96d15715caf3aab
data/doc/text/news.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.6.8 - 2023-11-07
4
+
5
+ ### Improvements
6
+
7
+ * Added support for `output_trace_log`.
8
+
9
+ ## 0.6.7 - 2022-01-07
10
+
11
+ ### Improvements
12
+
13
+ * `load`: Added support for `Arrow::Table`.
14
+
3
15
  ## 0.6.6 - 2021-12-10
4
16
 
5
17
  ### Improvements
@@ -167,7 +167,12 @@ module Groonga
167
167
  def process_response(response, command)
168
168
  case command.output_type
169
169
  when :json
170
- puts(JSON.pretty_generate([response.header, response.body]))
170
+ output = {"header" => response.header}
171
+ if response.trace_logs
172
+ output["trace_logs"] = response.trace_logs
173
+ end
174
+ output["body"] = response.body
175
+ puts(JSON.pretty_generate(output))
171
176
  when :xml
172
177
  puts(response.raw)
173
178
  else
@@ -25,9 +25,9 @@ module Groonga
25
25
  @client = client
26
26
  @split_load_chunk_size = options[:split_load_chunk_size] || 10000
27
27
  @generate_request_id = options[:generate_request_id]
28
- @target_commands = options[:target_commands]
29
- @target_tables = options[:target_tables]
30
- @target_columns = options[:target_columns]
28
+ @target_commands = options[:target_commands] || []
29
+ @target_tables = options[:target_tables] || []
30
+ @target_columns = options[:target_columns] || []
31
31
  @load_values = []
32
32
  @parser = create_command_parser
33
33
  end
@@ -46,7 +46,7 @@ module Groonga
46
46
  last_line = line
47
47
  @parser << line
48
48
  end
49
- if last_line and last_line.end_with?("\n")
49
+ if last_line and not last_line.end_with?("\n")
50
50
  @parser << "\n"
51
51
  end
52
52
  end
@@ -168,11 +168,17 @@ module Groonga
168
168
  command.arguments,
169
169
  [])
170
170
  command.path_prefix = path_prefix
171
- case @options[:load_input_type]
171
+ load_input_type = @options[:load_input_type]
172
+ if defined?(Arrow) and command[:values].is_a?(Arrow::Table)
173
+ load_input_type = "apache-arrow"
174
+ arrow_table = command[:values]
175
+ elsif load_input_type == "apache-arrow"
176
+ arrow_table = command.build_arrow_table
177
+ end
178
+ case load_input_type
172
179
  when "apache-arrow"
173
180
  command[:input_type] = "apache-arrow"
174
181
  content_type = "application/x-apache-arrow-streaming"
175
- arrow_table = command.build_arrow_table
176
182
  if arrow_table
177
183
  buffer = Arrow::ResizableBuffer.new(1024)
178
184
  arrow_table.save(buffer, format: :stream)
@@ -67,6 +67,7 @@ module Groonga
67
67
  class << self
68
68
  def parse(command, raw_response)
69
69
  return_code = nil
70
+ trace_logs = nil
70
71
  case command.output_type
71
72
  when :json
72
73
  callback = command["callback"]
@@ -81,6 +82,13 @@ module Groonga
81
82
  return_code = header[0] if header
82
83
  else
83
84
  header = response["header"]
85
+ trace_log = response["trace_log"]
86
+ if trace_log
87
+ names = trace_log["columns"].collect {|column| column["name"]}
88
+ trace_logs = trace_log["logs"].collect do |log|
89
+ Hash[names.zip(log)]
90
+ end
91
+ end
84
92
  body = response["body"]
85
93
  return_code = header["return_code"] if header
86
94
  end
@@ -91,7 +99,7 @@ module Groonga
91
99
  header, body = parse_tsv(raw_response)
92
100
  return_code = header["return_code"] if header
93
101
  when :arrow, :"apache-arrow"
94
- header, body = parse_apache_arrow(raw_response)
102
+ header, trace_logs, body = parse_apache_arrow(raw_response)
95
103
  return_code = header["return_code"] if header
96
104
  else
97
105
  header = nil
@@ -102,6 +110,7 @@ module Groonga
102
110
  else
103
111
  response = Error.new(command, header, body)
104
112
  end
113
+ response.trace_logs = trace_logs
105
114
  response.raw = raw_response
106
115
  response
107
116
  end
@@ -187,6 +196,7 @@ module Groonga
187
196
 
188
197
  def parse_apache_arrow(response)
189
198
  header = nil
199
+ trace_logs = nil
190
200
  body = nil
191
201
  buffer = Arrow::Buffer.new(response)
192
202
  Arrow::BufferInputStream.open(buffer) do |input|
@@ -194,9 +204,14 @@ module Groonga
194
204
  reader = Arrow::RecordBatchStreamReader.new(input)
195
205
  schema = reader.schema
196
206
  record_batches = reader.to_a
197
- if apache_arrow_metadata?(schema)
207
+ data_type = (schema.metadata || {})["GROONGA:data_type"]
208
+ case data_type
209
+ when "metadata"
198
210
  table = Arrow::Table.new(schema, record_batches)
199
211
  header = table.each_record.first.to_h
212
+ when "trace_log"
213
+ table = Arrow::Table.new(schema, record_batches)
214
+ trace_logs = table.raw_records
200
215
  else
201
216
  body = {}
202
217
  body["columns"] = schema.fields.collect do |field|
@@ -212,11 +227,7 @@ module Groonga
212
227
  end
213
228
  end
214
229
  end
215
- return header, body
216
- end
217
-
218
- def apache_arrow_metadata?(schema)
219
- (schema.metadata || {})["GROONGA:data_type"] == "metadata"
230
+ return header, trace_logs, body
220
231
  end
221
232
  end
222
233
 
@@ -239,11 +250,16 @@ module Groonga
239
250
  # @return [String] The unparsed response. It may be JSON, XML or
240
251
  # Groonga command format.
241
252
  attr_accessor :raw
253
+ # @return [::Array, nil] The trace logs of response.
254
+ # @see https://groonga.org/docs/reference/command/output_trace_log.html
255
+ # The trace log document.
256
+ attr_accessor :trace_logs
242
257
 
243
258
  def initialize(command, header, body)
244
259
  self.command = command
245
260
  self.header = header
246
261
  self.body = body
262
+ self.trace_logs = nil
247
263
  self.raw = nil
248
264
  end
249
265
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2021 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2013-2022 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
  class Client
19
- VERSION = "0.6.6"
19
+ VERSION = "0.6.8"
20
20
  end
21
21
  end
@@ -280,7 +280,11 @@ module Groonga
280
280
  def normalize_parameters(parameters)
281
281
  normalized_parameters = {}
282
282
  parameters.each do |key, value|
283
- normalized_parameters[key] = value.to_s
283
+ if defined?(Arrow) and value.is_a?(Arrow::Table)
284
+ normalized_parameters[key] = value
285
+ else
286
+ normalized_parameters[key] = value.to_s
287
+ end
284
288
  end
285
289
  normalized_parameters
286
290
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Haruka Yoshihara
8
8
  - Kouhei Sutou
9
9
  - Kosuke Asami
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-12-10 00:00:00.000000000 Z
13
+ date: 2023-11-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gqtp
@@ -286,7 +286,7 @@ homepage: https://github.com/ranguba/groonga-client
286
286
  licenses:
287
287
  - LGPLv2.1+
288
288
  metadata: {}
289
- post_install_message:
289
+ post_install_message:
290
290
  rdoc_options: []
291
291
  require_paths:
292
292
  - lib
@@ -301,8 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  - !ruby/object:Gem::Version
302
302
  version: '0'
303
303
  requirements: []
304
- rubygems_version: 3.3.0.dev
305
- signing_key:
304
+ rubygems_version: 3.5.0.dev
305
+ signing_key:
306
306
  specification_version: 4
307
307
  summary: Groonga-client is a client for Groonga (http://groonga.org/) implemented
308
308
  with pure Ruby. You can use it without Groonga.