groonga-client 0.6.7 → 0.6.9

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: 3a13092963c9a1d652d8c16687494adcd044ac4036e5740085aab049f3c84b77
4
- data.tar.gz: 29d881eb07c7dbec1c87070f42bf19e850a8849f0b72e0d09696b10f521d5392
3
+ metadata.gz: e6da9f45867a1b6ba3343309e8935b8efdc8b9d3c8d35d7dec702738b38829a7
4
+ data.tar.gz: 29178875a3d700f8b17c2c1cfab67c37baf86a811af258e5bb2069916d90de24
5
5
  SHA512:
6
- metadata.gz: 8901feec4d9cb6315502d1e5e30d91df3dc9d94a628cf5e5dbb6ae9045ff0a75f0cd4c2e6ef826d4de482ea96fbe80e05d32897a9a8b2cba20c8f4ff66fc3f4d
7
- data.tar.gz: ced3f733068a72491b4f2f8f5472f1fa5c605d3af4d7a345290764f97b49a2fd0d732dd6bf26499fc1af1759359052289b51026974ab9969d62b1fa37d4d6b18
6
+ metadata.gz: b351339a18628c2230cdc20714cbc82517cbc46618860a3cac0f31d3a75ffaae2181771affbe17a9a61575cecbc071a284f040436fa59efe30450b82f12d8cc3
7
+ data.tar.gz: a8c6326cbfb48225dc799915867c3757c05d824f02ec79fa510407d306431fba0745c5aba7a1ad1c8ba5382e58b97c0e469299ea8c5e8c855ef9e211f2538021
data/doc/text/news.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.6.9 - 2024-04-10
4
+
5
+ ### Improvements
6
+
7
+ * HTTP: Added support for request cancel.
8
+
9
+ ## 0.6.8 - 2023-11-07
10
+
11
+ ### Improvements
12
+
13
+ * Added support for `output_trace_log`.
14
+
3
15
  ## 0.6.7 - 2022-01-07
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
@@ -66,15 +66,19 @@ module Groonga
66
66
  http.start do
67
67
  http.read_timeout = read_timeout
68
68
  response = send_request(http, command)
69
+ body = response.body
69
70
  case response
70
- when Net::HTTPSuccess, Net::HTTPBadRequest
71
- yield(response.body)
71
+ when Net::HTTPSuccess,
72
+ Net::HTTPBadRequest, # for invalid request
73
+ Net::HTTPRequestTimeOut # for canceled request
74
+ yield(body)
72
75
  else
73
- if response.body.start_with?("[[")
74
- yield(response.body)
76
+ # "[[" is for command_version=1
77
+ # "{" is for command_version=3
78
+ if body.start_with?("[[") or body.start_with?("{")
79
+ yield(body)
75
80
  else
76
- message =
77
- "#{response.code} #{response.message}: #{response.body}"
81
+ message = "#{response.code} #{response.message}: #{body}"
78
82
  raise Error.new(message)
79
83
  end
80
84
  end
@@ -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-2023 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.7"
19
+ VERSION = "0.6.9"
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Haruka Yoshihara
8
8
  - Kouhei Sutou
9
9
  - Kosuke Asami
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2022-01-06 00:00:00.000000000 Z
12
+ date: 2024-04-10 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: gqtp
@@ -286,7 +285,6 @@ homepage: https://github.com/ranguba/groonga-client
286
285
  licenses:
287
286
  - LGPLv2.1+
288
287
  metadata: {}
289
- post_install_message:
290
288
  rdoc_options: []
291
289
  require_paths:
292
290
  - lib
@@ -301,8 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
299
  - !ruby/object:Gem::Version
302
300
  version: '0'
303
301
  requirements: []
304
- rubygems_version: 3.4.0.dev
305
- signing_key:
302
+ rubygems_version: 3.6.0.dev
306
303
  specification_version: 4
307
304
  summary: Groonga-client is a client for Groonga (http://groonga.org/) implemented
308
305
  with pure Ruby. You can use it without Groonga.