apache / apache/paimon-cpp

[Feature] Unpack predicate boolean kernel bitmaps a byte at a time

Fermée
#335 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
C++
Étoiles
65
Forks
25
Merge moyen
2 j 12 h
PR mergées (30 j)
80

Description

## Search before asking

- [x] I searched in the [issues](https://github.com/apache/paimon-cpp/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`, 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()` and `Array::IsValid()` honour them, and a null row unpacks to 0 whatever the value bitmap holds for it, which is what both `IN` / `NOT IN` and every `NullFalseLeafBinaryFunction` require.

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

- [x] I'm willing to submit a PR!

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez dans src/paimon/common/utils/arrow/ et localisez MultiLiteralsLeafFunction et NullFalseLeafBinaryFunction, puis suivez leurs boucles existantes de conversion de bitmap en octets à travers LeafFunction::Test. Ajoutez le helper partagé et un test de propriétés couvrant chaque offset et chaque longueur, les deux valeurs de négation et les périodes de validité non alignées sur des octets. C’est terminé lorsque le helper correspond à la référence de l’accessor ligne par ligne et que les deux appelants renvoient des octets inchangés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp
Domaine
data
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
74/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.