Skip to content

fix(cpp): preserve Gorilla sentinel values in batch reads - #883

Open
ColinLeeo wants to merge 2 commits into
apache:developfrom
ColinLeeo:fix/aligned-gorilla-nan-parallel-read
Open

fix(cpp): preserve Gorilla sentinel values in batch reads#883
ColinLeeo wants to merge 2 commits into
apache:developfrom
ColinLeeo:fix/aligned-gorilla-nan-parallel-read

Conversation

@ColinLeeo

@ColinLeeo ColinLeeo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

  • Add shared exact-count read and skip helpers to Decoder.
  • Use exact-count decoding in aligned and non-aligned chunk readers.
  • Preserve embedded Gorilla marker values and all following values.
  • Propagate decoding errors from filtered skip paths.
  • Add codec-level and reader-level regression coverage.

Tests

  • Full C++ test suite: 733 tests passed.
  • Gorilla codec regression for embedded NaN read and skip.
  • Aligned and non-aligned DOUBLE/GORILLA reader regression.

@ColinLeeo ColinLeeo changed the title fix(cpp): preserve Gorilla sentinel values in aligned reads fix(cpp): preserve Gorilla sentinel values in batch reads Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to storage::Decoder to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants