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,6 +27,12 @@ let aggregate_into ~dir ~final_file () : unit =
|
||||||
let buf = Bytes.create 4096 in
|
let buf = Bytes.create 4096 in
|
||||||
|
|
||||||
let emit_chunk buf i len =
|
let emit_chunk 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
|
if !afternewline && !first then
|
||||||
first := false
|
first := false
|
||||||
else if !afternewline then (
|
else if !afternewline then (
|
||||||
|
|
@ -34,6 +40,7 @@ let aggregate_into ~dir ~final_file () : unit =
|
||||||
afternewline := false
|
afternewline := false
|
||||||
);
|
);
|
||||||
output oc buf i len
|
output oc buf i len
|
||||||
|
)
|
||||||
in
|
in
|
||||||
|
|
||||||
(* dump content of jsonl file into [oc]. Insert "," before every object
|
(* dump content of jsonl file into [oc]. Insert "," before every object
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue