sdf-jkl opened a new pull request, #12469:
URL: https://github.com/apache/arrow-rs/pull/12469

   # Which issue does this PR close?
   
   - None yet. This is groundwork for comparing ALP pages against a constant 
without decoding them, described below.
   
   # Rationale for this change
   
   `AlpDecoder` can only reach a vector through its read cursor. 
`load_current_vector` checks each vector's start against a running 
`expected_next_offset`, and `skip` seeds that field so a jump passes the check. 
Code that wants vector `i` on its own, outside a decoder, has no way in.
   
   The next step needs that. Each ALP vector stores a frame of reference, which 
is the exact minimum of its packed values, and a bit width, so the packed 
values lie in `[FOR, FOR + 2^bit_width - 1]`, and decoding is monotonic. A 
comparison against a constant can fill whole vectors as true or false from that 
header, check the few exceptions exactly, and decode only the vectors whose 
bounds straddle the constant. On the ALP paper's float datasets in their 
natural order, that decides about 75% of values without unpacking for clustered 
columns, against 44% with page statistics.
   
   # What changes are included in this PR?
   
   - `AlpPage<Value>` (`pub(crate)`): `try_new` validates the page header and 
the offsets section, which `set_data` used to do, and `vector(idx)` parses and 
validates one vector through the offset array.
   - `AlpVector<Value>`: one parsed vector, holding its decode constants and 
its packed values and exception sections.
   - `CurrentVector` keeps only cursor state over an `AlpVector`, and 
`AlpDecoder` holds an `AlpPage`. `expected_next_offset` and 
`AlpEncodedVectorView::expected_stored_size` are removed.
   
   Contiguity is now checked per vector: vector 0 must start right after the 
offsets section, and every vector must fill `[offset, next offset)` exactly, 
which `parse_vector_view` already enforced. For sequential reads this accepts 
and rejects the same pages, with the same error messages.
   
   # Are these changes tested?
   
   Covered by the existing tests, since behaviour does not change: the ALP 
decoder unit tests, including the offset and contiguity rejection tests whose 
messages are unchanged, `test_alp_extended`, and the ALP writer round trips. 
Not benchmarked: the decode loop is unchanged, and loading a vector now clones 
one more `Bytes` handle.
   
   # Are there any significant user-facing changes?
   
   No. The new items are `pub(crate)`. One corner case reports a different 
error: a page whose offsets section is truncated and whose header value count 
exceeds the caller's count now reports the offsets error first.
   
   # AI usage disclosure
   
   The refactor and this description were drafted with Claude Code. This stays 
a draft until I have reviewed it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to