fix(cpp): preserve Gorilla sentinel values in batch reads - #883
Open
ColinLeeo wants to merge 2 commits into
Open
fix(cpp): preserve Gorilla sentinel values in batch reads#883ColinLeeo wants to merge 2 commits into
ColinLeeo wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a correctness issue in the C++ Gorilla decoding path where in-band sentinel values (canonical NaN for FLOAT/DOUBLE, min values for INT32/INT64) could prematurely terminate batch decoding. It introduces exact-count read/skip helpers in the base Decoder so callers that already know the expected value count (via page metadata/bitmaps/time batch counts) can decode deterministically without treating embedded sentinel bit-patterns as end-of-stream.
Changes:
- Add
read_exact_*/skip_exact_*helpers tostorage::Decoderto enforce exact-count semantics even when batch decoders stop on in-band terminators. - Switch aligned and non-aligned chunk reader fast paths from capacity-based batch reads/skips to exact-count reads/skips for fixed-width value columns.
- Add regression tests covering embedded Gorilla NaN values at both the codec level and end-to-end reader level.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/src/encoding/decoder.h | Adds exact-count read/skip helpers that combine batch decoding with scalar fallback to preserve embedded terminator values. |
| cpp/src/reader/chunk_reader.cc | Uses exact-count skip/read for fixed-width value decoding to prevent Gorilla sentinels from truncating batches. |
| cpp/src/reader/aligned_chunk_reader.cc | Uses exact-count skip/read for aligned value decoding and predecode paths where the bitmap provides the exact non-null value count. |
| cpp/test/encoding/gorilla_codec_test.cc | Adds regression coverage for exact-count read/skip preserving embedded NaN values. |
| cpp/test/reader/tsfile_reader_test.cc | Adds end-to-end reader regression ensuring aligned/non-aligned Gorilla DOUBLE preserves embedded NaN and subsequent values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
Fixes premature termination in C++ Gorilla batch decoding when an encoded value matches the codec end marker.
Gorilla uses canonical NaN as the FLOAT/DOUBLE end marker and reserved minimum values for INT32/INT64. The regular batch API cannot distinguish an embedded marker from the physical end of the stream. Readers already know the exact value count from page metadata or the corresponding time batch, so this change adds exact-count read and skip APIs that preserve embedded marker values while retaining the existing batch fast path.
Changes
Tests