Use `Array::to_arc` instead of `make_array(x.to_data())` and `x.slice(0, x.len())`

Aperta Adatta ai principianti
#27,687 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Quattro siti di chiamata sono indicati con link alle righe: datafusion/physical-expr-common/src/datum.rs, datafusion/physical-expr/src/expressions/in_list/array_static_filter.rs, datafusion/physical-expr-common/src/utils.rs e datafusion/physical-plan/src/spill/spilled_row_sizes.rs (il caso dictionary.keys(), che potrebbe richiedere keys.to_arc() sul figlio). Per prima cosa verifica che la versione fissata di arrow nel Cargo.toml del workspace esponga già Array::to_arc; in caso contrario, l'aggiornamento della dipendenza è un prerequisito. È completato quando ogni workaround viene sostituito con x.to_arc() e cargo test passa per i crate interessati.

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

Descrizione

Is your feature request related to a problem or challenge?

arrow-rs adds Array::to_arc in apache/arrow-rs#12420, and it is expected to ship in arrow 60.3.0 or 61.0.0. It returns an ArrayRef that shares the buffers of a &dyn Array. When the &dyn Array is an &ArrayRef, it returns a new reference to the same allocation.

DataFusion has four places outside tests that turn a &dyn Array into an ArrayRef with a workaround:

make_array(x.to_data()) builds an ArrayData and then rebuilds a typed array from it, and nested types repeat that for every child. slice(0, len) recounts the null buffer's nulls and re-slices the children of nested types. to_arc clones an arrow-rs array into a new Arc, and for an ArrayRef it only increments the reference count.

Describe the solution you'd like

After DataFusion upgrades to an arrow release that includes Array::to_arc, replace each workaround above with x.to_arc().

Describe alternatives you've considered

We could keep the workarounds. They return equal arrays but do more work per call.

Additional context

The same arrow-rs PR switches arrow's own cast, concat, nullif, and shift from these workarounds to to_arc.

Lingua principale
Rust
Stelle
9.6k
Fork
2.7k
Merge medio
3g 17h
PR unite (30g)
318

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 apache/datafusion

Tutte le issue di apache/datafusion

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.