Distinguish between missing and errored values in TaskResultBuffer #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the way we store parsed results doesn't allow us to distinguish between a missing value and value that failed to parse. Since the result buffer was designed for a scenario where a row with any error would be discarded as a whole (and the presence of any error in a row is marked in the row_statuses vector), it wasn't necessary to make this distinction for actual data ingestion because ingested rows could only have missing and validly parsed values. However, this was bad for error reporting and debugging the parsing failure, thus this change.
Instead of a single bit matrix to store both errored and missing values, the
TaskResultBuffernow holds two matrices (missing_valuesanderrored_values) and the parser grows them lazily as needed, as before, i.e.missing_valuesis grown only when a row in the input data has a missing value in it, anderrored_valuesis grown only when a row in the input data has an error in it. In case no row contains both missing and errors, this leads to the same memory footprint as before, in case of overlap, we store the data redundantly, but with an overhead of ~ 1 bit per field, per row with both missing and errors. With the exception of pathological cases like a CSV containing only newlines and large schema, the memory overhead should be pretty minimal, e.g. a file using two 32MiB buffers with 6 columns and an average row size of 64 bytes, the two matrices would at most take2 * 32MiB / 64B * 6 / 8~768 KiBeach.