Skip to content

[ntuple] Fix zero pages for encoded and deferred columns - #23742

Draft
Elvand-Lie wants to merge 1 commit into
root-project:masterfrom
Elvand-Lie:fix/ntuple-merger-zero-pages
Draft

Elvand-Lie wants to merge 1 commit into
root-project:masterfrom
Elvand-Lie:fix/ntuple-merger-zero-pages

Conversation

@Elvand-Lie

Copy link
Copy Markdown
Contributor

This Pull request:

Fix incorrect default pages written by RNTupleMerger for a field missing from a later source (Union mode), and for a field that a later source added through late model extension (any merging mode, including the default one used by hadd).

Changes or fixes:

Zero-page generation used packed byte counts as if they were in-memory element counts and recreated column elements without their stored bit widths or quantization ranges. Missing bool, bitset and half-precision fields consequently received too few elements; truncated and quantized fields received incorrectly encoded pages.

Generate default pages by element count, using the destination column's bit width and value range. Return packing errors, including a quantization range that excludes zero, as a failed RResult identifying the field.

Deferred columns also compared their first element index with a cluster entry index and applied repetitions again when filling the gap. Convert the first element index to entries using the shared repetition calculation before comparing or filling. Both defects must be fixed together: for deferred bitsets, the incorrect packed-byte conversion previously canceled the extra repetition factor.

Tests cover a missing middle source for bool, bitset<8>, half-precision float, truncated float and quantized float; a quantized range excluding zero; and deferred array<float,3>, bitset<8> and bool fields with one or two clusters. Successful merges check every value and each cluster's column element count.

Validation

Base: upstream master fbcf83fe9a58e65f36ba55bdc3821a7983f4799a. Candidate: a81947c7fdb915c3bef2644833ea279d3ae7108f.

  • Built tree/ntuple/test/all tree/ntupleutil/test/all with -j3.
  • Full ntuple_merger: 352 tests passed, including all 12 new regression cases.
  • With only the merger implementation reverted to plain master, 11 new cases failed and 1 passed. Each ran separately with core dumps disabled. The deferred bitset case that passes is retained as a guard against the two errors canceling each other.
  • Restored and rebuilt the fixed merger, then ran ctest -R "ntuple|hadd" -E "largefile|largevector|tutorial" -j2 --output-on-failure:
100% tests passed, 0 tests failed out of 51
Total Test time (real) =  65.90 sec
  • Merging the deferred bool and std::array<float,3> setup through TFileMerger with no merge options, as hadd does: master reports success but writes 6 instead of 10 bool elements and 60 instead of 30 float elements in the second cluster, and the values read back are wrong; with this change all values match.
  • Changed-line clang-format 18.1.8 and git diff --check passed.

The separate recompression path still constructs source column elements without their low-precision parameters. Recompression of Real32Trunc/Real32Quant with a different output compression is outside this change and is not addressed here.

AI assistance: Codex (gpt-6.1-sol) implemented the change and regressions, and Claude Code (opus) discovered the defects and independently validates the work.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes incorrect zero-page generation and deferred-column filling in RNTupleMerger.

Union merges synthesize default pages when a source lacks a field. Packed
byte sizes do not give the number of in-memory elements for bit and
low-precision columns, and recreating elements without the stored bit
width and value range can produce invalid pages.

Configure destination elements from their descriptors and split default
pages by element count. Report packing failures with the field name
through RResult rather than throwing out of Merge.

Convert deferred first-element indices to entries before filling gaps,
using the same field repetition calculation as zero-page generation.
Fix both paths together because their errors cancel for some bitsets.

Cover missing encoded fields, quantized ranges excluding zero, and
deferred arrays, bitsets and bools across one or two clusters.

Assisted-by: codex:gpt-6.1-sol
Assisted-by: claude-code:opus
@Elvand-Lie
Elvand-Lie marked this pull request as draft October 16, 2026 15:02

This branch has not been deployed

No deployments
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