Skip to content

Frequency-sort dictionary values in FloatDictScheme before assigning codes #11887

Done

Description

@lwwmanning

FloatDictScheme assigns dictionary codes in hash-set order, so common values can land on wide codes. Sort the distinct values by descending count, with ties broken on their total-order bits, before assigning codes. This makes Taxi.congestion_surcharge 38.6% smaller and does not change the wire format. Part of #11890.

Details

The codes come from vortex-compressor/src/builtins/dict/float.rs, typed_encode!, line 162:

let values: Buffer<$typ> = distinct.distinct_values().iter().map(|x| x.0).collect();

The codes are then bit-packed with patches. Taxi.congestion_surcharge (f64, 19.1M rows) is almost entirely two values. In f64 hash order, both landed past code 1, so the codes needed 2 bits and the column took 4.79 MB. Narrowed to f32, the same values happened to get codes 0 and 1 and packed into 1 bit with patches. That took 2.94 MB.

DictArray accepts values in any order, and set_all_values_referenced(true) still holds, so readers do not change. The output also stops depending on the hash layout. #12044 extends the same frequency-sorted code assignment to integer, string, binary, and decimal dictionaries.

Activity

  1. added
    feature
    on Nov 23, 2026
  2. added a commit that references this issue on Nov 27, 2026
    1f63db7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions