Dictionary-shaped takes decode every row of FoR, ALP and ZigZag values

Open
#12,071 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start by reading #12048 and #11890, then locate the TakeExecuteAdaptor and the take kernels for FoR, ZigZag, and ALP. Add benchmarks comparing pushdown with decoding values before gathering across several codes-to-values ratios, recording time and allocations. Use the results to recommend where the rule belongs and whether a length threshold or ratio is appropriate; preserve pushdown for Sparse, RunEnd, Sequence, and Chunked.

Written by the indexing model from the issue text.

Description

This concerns take on encodings that wrap a child and decode it one element at a time: FoR, ZigZag, ALP, ALPRD, Delta and Widen. In Vortex, ArrayRef::take builds a lazy DictArray(indices, values). Each of these encodings registers a TakeExecuteAdaptor kernel for a Dict parent. So a real dictionary column, such as Dict(codes, FoR), takes the same path as a plain take.

When the codes outnumber the values, the kernel still pushes the codes into the encoded child and returns a full-length array, such as FoR(take(encoded, codes)). So one execution step turns a dictionary-encoded column into a full-length encoded array. The decode then runs once per row instead of once per distinct value. Nobody has measured what this costs in time or memory.

#12048 adds a guard to ZigZag only. Its take kernel declines when indices.len() > array.len(), so Dict decodes its values first and stays a Dict. No benchmark measures that guard, and FoR and ALP keep the old path. The length test is also only a stand-in for "this take is dictionary-shaped".

Questions to answer with benchmarks:

  1. For Dict over FoR, ZigZag and ALP values, which is faster: pushing the take into the encoded child, or decoding the values and then gathering? Measure several ratios of codes to values, and what each path allocates.
  2. Does the answer differ by encoding? ZigZag decodes with a shift and an XOR, while ALP multiplies and applies patches.
  3. If decoding first wins, should the rule live once in TakeExecuteAdaptor as an opt-in, or in each encoding's kernel? Sparse, RunEnd, Sequence and Chunked rely on the pushdown and must keep it.
  4. Is indices.len() > array.len() the right test, or should the rule use a ratio of codes to values?

Related to #11890.

🤖 Generated with Claude Code

Dominant language
Rust
Stars
3.2k
Forks
239
Avg merge
1d 4h
Merged PRs (30d)
684

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vortex-data/vortex

All issues in vortex-data/vortex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.