Can `ResumableParser` return whether the last `partial_value` container is completed or not?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia riproducendo i due esempi di chunk di JSON::ResumableParser presenti nell’issue e verifica come viene valorizzato partial_value dopo parse. Traccia lo stato del parser per un ultimo record completo rispetto a uno incompleto; il lavoro è concluso quando i chiamanti possono distinguere in modo affidabile questi casi, inclusi gli scenari di workaround descritti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Ruby
- Stelle
- 782
- Fork
- 383
- Merge medio
- 1g 18h
- PR unite (30g)
- 10
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ruby/json
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON. Apertajruby
-
jruby
-
new feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
riscv/riscv-unified-db#2624 · 1 reazione ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100