ranflarion opened a new pull request, #10966:
URL: https://github.com/apache/arrow-rs/pull/10966

   # Which issue does this PR close?
   
   - Closes #10965.
   - Related to #10963, which skips the filter for chunks whose data pages are 
all dictionary encoded; the two are independent and merge in either order.
   
   # Rationale for this change
   
   While a column is dictionary encoded every row was still hashed into the 
bloom filter, although the interner already holds the distinct values. For a 
low-cardinality column that is N inserts where D carry the same information, 
and those are exactly the columns that stay dictionary encoded. Suggested by 
@etseidl in #10963.
   
   # What changes are included in this PR?
   
   - `ColumnValueEncoderImpl::write_slice` and the byte array `encode` insert 
into the filter only when no dictionary encoder is active.
   - `flush_dict_page` on both encoders inserts every interned value before 
handing the dictionary page over. It runs on fallback and at chunk close, so 
after a fallback the filter holds the dictionary's values plus every value 
written plain afterwards.
   - `DictEncoder::uniques` exposes the interned values for the primitive path.
   
   The set of values inserted is unchanged and folding decides from the final 
fill rate, so the serialized filter is byte-identical; only the write-side cost 
changes.
   
   Benchmark (`cargo bench -p parquet --bench arrow_writer -- 
'<batch>/bloom_filter'`, Apple M-series, criterion, main vs this branch):
   
   | batch | main | this PR | change |
   |---|---|---|---|
   | string_dictionary_low_cardinality_100 | 19.20 ms | 14.01 ms | -27.0% |
   | primitive_non_null | 58.90 ms | 57.98 ms | -1.6% |
   | string_dictionary | 48.85 ms | 49.10 ms | +0.5% (p = 0.24) |
   | string_non_null | 108.63 ms | 108.96 ms | +0.3% (p = 0.05) |
   
   # Are these changes tested?
   
   Yes. New round-trip tests for `StringArray` and `Int64Array` cover a chunk 
that stays dictionary encoded (asserted through the page encoding mask) and a 
chunk that falls back to plain after a small dictionary page limit, checking 
the filter for every written value and for absent ones. The existing bloom 
filter round-trip tests already sweep dictionary disabled, immediate fallback 
and dictionary enabled and pass unchanged.
   
   # Are there any user-facing changes?
   
   No API or output change. `DictEncoder::uniques` is new but the type is not 
exported from the crate.
   


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