Abdallah-Afifi commented on issue #11985:
URL: https://github.com/apache/arrow-rs/issues/11985#issuecomment-7196523421

   Thanks, I'll take this.
   
   Your PLAIN idea turns out to be the actual fix rather than just a nicer one. 
Every exception stores a 2-byte position on top of the full value, so demoting 
a vector to all-exceptions can never get below 1.25x PLAIN for f64, or 1.5x for 
f32. Encoded page bytes for the high-entropy input in the description:
   
   | | bytes | vs PLAIN |
   | --- | --- | --- |
   | ALP today | 90,619 | 1.38x |
   | every value an exception, `bit_width = 0` | 82,063 | 1.25x |
   | PLAIN | 65,536 | 1.00x |
   
   The middle row is computed from the format, and it matches the exhaustive 
per-vector optimum to within 50 bytes. So demotion closes only about a third of 
the gap. It's still worth a separate PR, since it never makes a vector bigger 
and it fixes the 63-bit packing you saw, but it won't close this issue.
   
   @sdf-jkl a design question before I start on the fallback. The column writer 
already switches encoding mid-chunk for dictionary fallback, and PLAIN's size 
is just `num_values * width`, so the comparison needs no second encode. The 
catch is that only the first page is buffered: later pages stream and drop 
their raw floats once each vector is encoded, so there's nothing left to write 
as PLAIN. Would you rather keep each page's raw values around (more memory), or 
decide from the first page and stay on PLAIN for the rest of the chunk, the way 
dictionary fallback does?
   


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