Skip to content

Commit 933bdc1

Browse files
author
Matthew Katz
committed
add rebuild to duckdb exporter
Signed-off-by: Matthew Katz <katz@spiraldb.com>
1 parent 925488f commit 933bdc1

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

vortex-array/public-api.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23082,6 +23082,8 @@ impl vortex_array::Array<vortex_array::arrays::ListView>
2308223082

2308323083
pub fn vortex_array::Array<vortex_array::arrays::ListView>::rebuild(&self, vortex_array::arrays::listview::ListViewRebuildMode) -> vortex_error::VortexResult<vortex_array::arrays::ListViewArray>
2308423084

23085+
pub fn vortex_array::Array<vortex_array::arrays::ListView>::should_rebuild(&self, bool) -> bool
23086+
2308523087
impl vortex_array::Array<vortex_array::arrays::Masked>
2308623088

2308723089
pub fn vortex_array::Array<vortex_array::arrays::Masked>::try_new(vortex_array::ArrayRef, vortex_array::validity::Validity) -> vortex_error::VortexResult<Self>

vortex-array/src/arrays/listview/rebuild.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl ListViewArray {
389389
}
390390
}
391391

392-
fn should_rebuild(&self, exact: bool) -> bool {
392+
pub fn should_rebuild(&self, exact: bool) -> bool {
393393
let density = if exact {
394394
self.compute_density()
395395
} else {

vortex-duckdb/src/exporter/list_view.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use vortex::array::ExecutionCtx;
1111
use vortex::array::arrays::ListViewArray;
1212
use vortex::array::arrays::PrimitiveArray;
1313
use vortex::array::arrays::listview::ListViewDataParts;
14+
use vortex::array::arrays::listview::ListViewRebuildMode;
1415
use vortex::array::match_each_integer_ptype;
1516
use vortex::array::validity::Validity;
1617
use vortex::dtype::IntegerPType;
@@ -50,13 +51,20 @@ pub(crate) fn new_exporter(
5051
ctx: &mut ExecutionCtx,
5152
) -> VortexResult<Box<dyn ColumnExporter>> {
5253
let len = array.len();
54+
55+
let compact_array = if array.should_rebuild(false) {
56+
array.rebuild(ListViewRebuildMode::MakeZeroCopyToList)?
57+
} else {
58+
array
59+
};
60+
5361
let ListViewDataParts {
5462
elements_dtype,
5563
elements,
5664
offsets,
5765
sizes,
5866
validity,
59-
} = array.into_data_parts();
67+
} = compact_array.into_data_parts();
6068
// Cache an `elements` vector up front so that future exports can reference it.
6169
let num_elements = elements.len();
6270

0 commit comments

Comments
 (0)