Can `ResumableParser` return whether the last `partial_value` container is completed or not?
まだ誰も着手していません。
評価
調査の方向性
まず、issue にある 2 つの JSON::ResumableParser のチャンク例を再現し、parse 後に partial_value がどのように設定されるかを調べます。最後のレコードが完了している場合と不完全な場合の parser の状態を追跡します。呼び出し側が、説明されている workaround のシナリオも含めて、これらのケースを確実に区別できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This is not a critical feature request.
I'm trying to migrate to json gem from json-stream gem in https://github.com/groonga/groonga-command-parser/ by JSON::ResumableParser.
It parses records to be loaded to Groonga (a full text search engine with column store). The records use the following format:
[
{"column_name1": "record1's column_value1", "column_name2": 2, ...},
{"column_name1": "record2's column_value1", "column_name2": 2, ...},
...
]
groonga-command-parser wants to process a record as soon as it's completed. For example, it wants to process the first record when the following chunk is processed:
[
{"column_name1": "record1's column_value1", "column_name2": 2, ...},
We can do it by the following script:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1"},
CHUNK
parser.parse
p parser.partial_value[0] # => {"column1" => "value1"}
But it doesn't work with the following chunk:
[
{"column_name1": "record1's column_value1",
We can't know whether the record is completed or not:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1",
CHUNK
parser.parse
p parser.partial_value[0] # => {"column1" => "value1"} # This is not completed yet
groonga-command-parser has a workaround for it. It ignores the last record:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1"},
CHUNK
parser.parse
p parser.partial_value[0..-2] # => []
parser << <<-CHUNK
{"column1": "value2"},
CHUNK
parser.parse
p parser.partial_value[0..-2] # => [{"column1" => "value1"}] # 1st record
If we can detect whether a record in this example is completed or not, it's useful. But this is not a critical feature request because there is a workaround for this case.
- 主要言語
- Ruby
- スター
- 782
- フォーク
- 383
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 10
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/json のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON. オープンjruby
-
jruby
-
new feature
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
riscv/riscv-unified-db#2624 · リアクション 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100