File statistics: bloom filters for equality predicates

Aperta
#352 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start with beacon-db/beacon-file-stats/src/pruning.rs to understand PruningStatistics::contained(), then read segment/format.rs and collector.rs for the segment layout and FileAnalysis flow. Check how Parquet footer bloom filters and the existing statistics pass provide filter data. Done means implementing the proposed version 3 storage and read/write paths, preserving version 2 reads, and meeting the acceptance checks for pruning correctness, size, and query behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

beacon-kernel enhancement rust

Summary

The file statistics store keeps a minimum and a maximum for each column of each file. That prunes a
range predicate well. It prunes an equality predicate on a text column badly.

Add an optional per-column bloom filter to the segment. Answer PruningStatistics::contained() from
it.

The problem

A range holds every value between its two ends.

SELECT * FROM read_netcdf('argo/**/*.nc') WHERE "PLATFORM_CODE" = '6903240';

A file that holds codes 1900001 to 7900999 passes the range test. Nearly every file does. Beacon
prunes nothing and opens the whole archive.

The same shape covers each identifier column that a user queries: platform code, cruise identifier,
station name, EDMO code, instrument type, data provider.

pruning.rs:83 states the current answer:

fn contained(&self, _column: &Column, _values: &HashSet<ScalarValue>) -> Option<BooleanArray> {
    None
}

None is the fail-open answer. It is correct and it prunes nothing.

Proposal

1. The filter

Use the Parquet split-block bloom filter (parquet::bloom_filter::Sbbf, xxhash64).

One reason decides this: a Parquet file may already hold that exact filter in its footer. Beacon
then copies the bytes and reads no data. Any other design needs a full scan of each Parquet file.

2. The segment layout

Each column already holds one block. See
segment/format.rs.

  • Add one BufRef for the filter bytes and one offsets buffer, one entry per file.
  • Raise VERSION from 2 to 3.
  • The reader must read a version 2 segment. It reports no filter for it. A store must not need a
    rebuild.
3. The size budget

The store targets 1M files and about 50 columns per file, so about 50M cells. A 256 byte filter on
each cell costs 12.8 GB. That is too much.

So a filter is opt-in for each column:

  • BEACON_FILE_STATS_BLOOM_COLUMNS holds a list of column name globs. Default empty.
  • Size each filter from the distinct count of the file, with a cap. Target a 1% false positive rate.
  • Write no filter for a column with a distinct count above the cap. A range test still applies.
4. The read path

Implement contained():

  • Return Some with false for a file whose filter reports every value absent.
  • Return Some with true for every other file of that column.
  • Return None for an unknown column, for a segment of version 2, and for any error.

A bloom filter never reports a false negative, so false is a true answer. This keeps the fail-open
rule of the module.

5. The write path

The collector needs the distinct values, and FileAnalysis carries none today. See
collector.rs.

  • Extend FileAnalysis with an optional filter for each column.
  • Parquet: read the filter from the file footer. No scan.
  • Other formats: build the filter during the read that the statistics pass already performs.

Acceptance

  • A query with WHERE "PLATFORM_CODE" = '...' prunes files that a range test keeps.
  • A benchmark reports the file count before and after, over at least 10 000 files.
  • A Parquet file with a footer filter needs no scan.
  • A version 2 segment reads without error and reports no filter.
  • A pruned file never holds a matching row. A test proves this over random data.
  • The store size stays the same with the default configuration.
  • IN lists and NOT IN behave. DataFusion sends both through contained().

Part of #345.

Lingua principale
Rust
Stelle
16
Fork
4
Merge medio
19h 58m
PR unite (30g)
39

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di maris-development/beacon

Tutte le issue di maris-development/beacon

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.