[Feature] Unpack predicate boolean kernel bitmaps a byte at a time
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
Research direction
Start in src/paimon/common/utils/arrow/ and locate MultiLiteralsLeafFunction and NullFalseLeafBinaryFunction, then trace their existing bitmap-to-byte loops through LeafFunction::Test. Add the shared helper and a property test covering every offset and length, both negate values, and non-byte-aligned validity periods. Done means the helper matches the row-by-row accessor reference and both callers return unchanged bytes.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched in the issues and found nothing similar.
Motivation
Two predicate leaf functions evaluate a batch by running an arrow::compute kernel and reading back the arrow::BooleanArray it writes: MultiLiteralsLeafFunction (IN / NOT IN, via IsIn) and NullFalseLeafBinaryFunction (the comparison functions). A kernel returns a bitmap, one bit per row, but LeafFunction::Test returns std::vector<char>, one byte per row, so both call sites spread the bits over bytes with the same per-row loop: test IsNull, read Value, apply the negation NOT IN needs, store a byte. That is a shift, a mask and a byte store per row, duplicated across the two call sites, on the selection path every filtered batch goes through.
Solution
Extract the spread into one helper, ArrowUtils::UnpackBooleansToBytes(array, negate), and read the bitmap a byte at a time instead of a bit at a time:
- A compile-time table maps each of the 256 bitmap bytes to the eight bytes it expands to, so the aligned body produces eight rows per iteration with one lookup and one 8-byte store.
- A scalar head and tail cover the rows sharing a partial leading or trailing byte, which is where the array offset is not byte-aligned; a batch a kernel has just written is aligned, so it takes the fast body throughout.
- The offset and the validity bitmap are honoured exactly as
BooleanArray::Value()andArray::IsValid()honour them, and a null row unpacks to 0 whatever the value bitmap holds for it, which is what bothIN/NOT INand everyNullFalseLeafBinaryFunctionrequire.
MultiLiteralsLeafFunction passes its negate through; NullFalseLeafBinaryFunction passes negate=false. The bytes each returns are unchanged.
Anything else?
A property test that asserts the helper equals a row-by-row reference through the very accessors it replaces, over every (offset, length) slice of a bitmap whose value and null periods are not multiples of eight and both negate values, pins the offset, validity and negate handling against the definitions it optimizes. No change to any header under include/paimon/, the storage format, or the protocol: ArrowUtils is an internal utility under src/paimon/common/utils/arrow/.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Dominant language
- C++
- Stars
- 65
- Forks
- 29
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 78
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/paimon-cpp
-
enhancement
apache/paimon-cpp#381 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
apache/paimon-cpp#375 · 1 assignee ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
apache/paimon-cpp#361 · 1 assignee ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
apache/paimon-cpp#325 · 1 assignee ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/paimon-cpp#319 · 1 reaction · 1 assignee ·
All issues in apache/paimon-cpp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100