scan_shard_with_diagnostics

Function scan_shard_with_diagnostics 

Source
pub fn scan_shard_with_diagnostics(
    content: &[u8],
    range_start: usize,
    range_end: usize,
) -> (ShardRecords, Option<usize>, ShardRefusals, Vec<usize>)
👎Deprecated: use scan_shard_result and its named fields
Expand description

One shard’s speculative scan over [range_start, range_end), plus the byte offset of every record this shard refused and, if any, the byte offset of the record that made the scan stop early (#3695’s malformed-record stop).

This is the exact per-chunk primitive build_entity_index_parallel fans across cores, and the sibling of the wasm sharded pre-pass’s scan_shard_classified_with_refusals: each browser geometry worker calls that one on a byte range and the main thread stitches the columns (binary-searching each shard for the previous shard’s handoff — see the [native::stitch] doc). Compiled on all targets (the native merge is wasm-gated, but the shard primitive itself is target-independent).

Chunk 0 (range_start == 0) uses the header-aware EntityScanner::new; every other shard starts speculatively at range_start via EntityScanner::new_at (which may land mid-record — the handoff stitch makes that exact, not heuristic). Returns every record with start < range_end (strictly increasing in start), the handoff (the start of the first record at/after range_end, i.e. the next shard’s first real entity, or None at EOF), the refusal offsets, and the malformed-record stop offset (see below).

It does not report either diagnostic, and it must not. A shard with range_start > 0 starts at an arbitrary byte, so it can begin inside a quoted value; a string literal containing #4294967297=IFCWALL( satisfies the scanner’s #<digits>[ws]*= shape check (which has no quote context), so the speculative prefix can refuse arbitrarily many records that the file never declared. Reporting from inside the shard therefore turns a file with NOTHING oversized in it into a “skipped N records” warning — a false alarm on valid input, which is worse than the inflated count the first version of this was thought to produce (#3395, retracted reasoning on #3430).

Bounding by ownership alone (start < range_end) does not fix it either: a false refusal parsed out of a quoted value INSIDE the owned range still counts. Only the stitch knows which bytes of a shard were kept, so only the stitch can attribute a refusal — see [native::stitch].

The malformed-record offsets are the line_start of every record ifc_lite_core::EntityScanner::find_entity_end refused. Most are RECOVERABLE: a record missing its ; is dropped and the scan carries on (#4179), so records/handoff above continue past it. Only a record with nothing to resume from stops the scan, and that shows in handoff being None before range_end. All of them, not just the first: a shard can hold a speculative drop inside a quoted value AND a real one after it, and [native::stitch] must be able to find the real one. Same speculative-prefix caveat as a refusal, so it is not reported here either.