splitCsvBlocks
Splits text into at most maxBlocks blocks, cutting only at newlines outside quoted fields (quote parity is tracked, so an embedded newline never splits a field). The cut points are a pure function of the bytes, so the split is deterministic.
Above the block threshold the scan runs in three phases: the byte segments' quote parity and last candidate newlines are found in parallel (both parity assumptions recorded, since a quoted field may span a segment start), a serial prefix picks each segment's true candidate by the running parity - every cut lands at a truly unquoted newline, so every block starts at even parity - and the blocks' newline counts (the line numbers of the first-error diagnostics) are found in one more parallel pass. The serial walk stays for small texts and single-threaded runs; both produce the same kind of cuts, only their spacing differs (chunking is value-neutral).
Parameters
text | the CSV bytes |
maxBlocks | the block budget (also the segment count) |
quote | the dialect's quote character |