Skip to content

test(cpp): cover the ALP decoder API - #1121

Merged
ColinLeeo merged 1 commit into
apache:developfrom
ColinLeeo:colin/cpp-alp-decoder-tests
Nov 17, 2026
Merged

ColinLeeo merged 1 commit into
apache:developfrom
ColinLeeo:colin/cpp-alp-decoder-tests

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Summary

The ALP decoder's page-level codec was covered by alp_codec_test.cc, but the AlpDecoderBase API used by the read path had 47% line coverage and 23 never-executed functions (single-value reads, skip, every type-mismatch return).

cpp/test/encoding/alp_decoder_api_test.cc now covers, for FloatAlpDecoder and DoubleAlpDecoder:

  • sequential read_float / read_double and exhaustion with E_NO_MORE_DATA
  • read_batch_* with capacity smaller than, larger than, and equal to the remaining values, plus capacity <= 0 and out == nullptr
  • skip_* clamping: zero/negative counts, partial skips, skipping past the end, and skipping before/after reads
  • type-mismatch returns for every typed entry point on both decoders (read_boolean/int32/int64/float/double/String, batch and skip)
  • valid empty pages (value_count == 0), malformed pages (E_DECODE_ERR), and the post-failure state
  • reset() reuse with a different page, destroy(), owns_resources()
  • both byte-stream paths: a wrapped page buffer and a copied ByteStream

Coverage of alp_decoder.h: 47.2% -> 97.6% lines (124/127), 44/44 functions. The three remaining lines are defensive branches that need a >4 GiB stream or a failing stream read, so they are not unit-testable without mocking the allocator.

Test plan

  • ./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON (Java, C++, Python; 1663 C++ tests passed)
  • ./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON (1664 tests, 0 failed; macOS run used the Xcode 26.6 toolchain with ASAN_OPTIONS=detect_container_overflow=0 for the uninstrumented ANTLR runtime)
  • ./mvnw spotless:check -P with-java,with-python

Exercise AlpDecoderBase directly instead of only the page-level
AlpEncodePage/AlpDecodePage path: single-value reads, batch reads with
capacity/null/remaining limits, skip clamping, type-mismatch returns for
every typed entry point, valid empty pages, malformed pages, reset and
decoder reuse, and the wrapped and copied byte-stream paths.

alp_decoder.h: 47% -> 97.6% line coverage, all 44 functions.
@ColinLeeo
ColinLeeo merged commit bddd082 into apache:develop Nov 17, 2026
36 checks passed
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.

1 participant