Repository navigation
fix(cpp): stop serial aligned multi-column read at chunk end - #1098
Merged
Merged
Conversation
AlignedChunkReader::get_cur_page_header() resets the page header and returns E_OK once a chunk's data has been fully consumed. The serial multi-value path treated that reset header as a page to decode, decompressed a zero-byte page and surfaced E_TSFILE_CORRUPTED for multi-page chunks. Check has_more_data_multi() right after the headers are fetched and drop the now-redundant check after the skip branch, so the reader reports the end of the chunk instead of decoding an empty page.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the chunk-completion handling change.
No open issues 🎉
What changed in this PR
Fixes end-of-chunk handling in the C++ serial aligned multi-column reader so normal completion returns E_NO_MORE_DATA instead of a corruption error.
Changes:
- Checks chunk exhaustion after fetching page headers, before attempting to decode an empty page.
- Adds a regression test verifying all 40 rows across multiple pages and two columns are read successfully before completion.
| File | Description |
|---|---|
| cpp/test/reader/aligned_serial_chunk_end_test.cc | Adds regression coverage for serial multi-page reads and clean chunk completion. |
| cpp/src/reader/aligned_chunk_reader.cc | Moves the exhaustion check before decoding and uses the multi-column data check. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The serial path for multi-column aligned chunks reported
E_TSFILE_CORRUPTEDafter the last page of a chunk was consumed.AlignedChunkReader::get_cur_page_header()resets the page header and returnsE_OKwhenchunk_visit_offset - serialized_size >= data_size.get_next_page_multi_serial()did not distinguish that from a real page: it broke out of the header loop withE_OKand calleddecode_cur_time_page_data()on the zero-byte header, which failed withE_COMPRESS_ERRand surfaced asE_TSFILE_CORRUPTED(35).This only reproduces when the serial path is used (no decode pool, no offset/field filter that would build a page plan) and the aligned chunk has more than one page.
Fix
Check
has_more_data_multi()immediately after the page headers are fetched, and returnE_NO_MORE_DATAwhen the chunk is exhausted. The previous end-of-chunk check at the bottom of the loop is removed; a skipped final page now exits through the same top-of-loop check on the next iteration. Single-page chunks and the page-plan path are unchanged.Test
New
AlignedSerialChunkEndTest.SerialReadStopsAtChunkEndincpp/test/reader/aligned_serial_chunk_end_test.cc: writes a 40-row, two-column aligned chunk with 8 points per page, drivesAlignedChunkReaderthrough the serial path with a 40-rowTsBlock, and verifies all 40 rows decode and the read ends withE_NO_MORE_DATA. Fails withret=35before the fix.Full
TsFile_Test: 1475 tests ran, 1472 passed, 3 skipped.mvn -o -P with-cpp spotless:checkpasses.