mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-07 18:37:56 -05:00
detect corrupt chunks in multiproc
This commit is contained in:
parent
ff8c7e5353
commit
26b8648c82
1 changed files with 14 additions and 7 deletions
|
|
@ -27,13 +27,20 @@ let aggregate_into ~dir ~final_file () : unit =
|
|||
let buf = Bytes.create 4096 in
|
||||
|
||||
let emit_chunk buf i len =
|
||||
if !afternewline && !first then
|
||||
first := false
|
||||
else if !afternewline then (
|
||||
output_string oc ",\n";
|
||||
afternewline := false
|
||||
);
|
||||
output oc buf i len
|
||||
if len = 0 then
|
||||
()
|
||||
else if Bytes.get buf i = '{' && Bytes.get buf (i + len - 1) <> '}' then
|
||||
(* incomplete chunk *)
|
||||
()
|
||||
else (
|
||||
if !afternewline && !first then
|
||||
first := false
|
||||
else if !afternewline then (
|
||||
output_string oc ",\n";
|
||||
afternewline := false
|
||||
);
|
||||
output oc buf i len
|
||||
)
|
||||
in
|
||||
|
||||
(* dump content of jsonl file into [oc]. Insert "," before every object
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue