Skip to content

Commit 8e3b4c0

Browse files
committed
refactor(array): rename output allocation to with_capacity
Signed-off-by: Connor Tsui <[email protected]>
1 parent 5350a60 commit 8e3b4c0

9 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎vortex-array/src/scalar_fn/unstable/row/batch/tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl OutputElement for NullProducingI64 {
261261
DType::from(i64::PTYPE)
262262
}
263263

264-
fn allocate(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
264+
fn with_capacity(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
265265
allocator.with_capacity(rows)
266266
}
267267
}

‎vortex-array/src/scalar_fn/unstable/row/execute/owned.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ where
142142

143143
let prepared = prepare(Args::const_values(&columns));
144144
let valid_rows = valid.bit_buffer();
145-
let mut values = Out::allocate(valid_rows.len(), ctx.allocator());
145+
let mut values = Out::with_capacity(valid_rows.len(), ctx.allocator());
146146
let output = &mut values.slots()[..valid_rows.len()];
147147

148148
for slot in output.iter_mut() {
@@ -221,7 +221,7 @@ where
221221
);
222222

223223
let prepared = prepare(Args::const_values(&columns));
224-
let mut values = Out::allocate(row_count, ctx.allocator());
224+
let mut values = Out::with_capacity(row_count, ctx.allocator());
225225
let output = &mut values.slots()[..row_count];
226226

227227
for slot in output.iter_mut() {
@@ -288,7 +288,7 @@ where
288288
let prepared = prepare(Args::const_values(&columns));
289289

290290
let row_count = args.row_count();
291-
let mut values = Out::allocate(row_count, ctx.allocator());
291+
let mut values = Out::with_capacity(row_count, ctx.allocator());
292292
let output = &mut values.slots()[..row_count];
293293

294294
let Some(source) = decoded_source::<Args>(&columns, row_count) else {

‎vortex-array/src/scalar_fn/unstable/row/execute/retry.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
let prepared = prepare(Args::const_values(&columns));
6363

6464
let row_count = args.row_count();
65-
let mut values = Out::allocate(row_count, ctx.allocator());
65+
let mut values = Out::with_capacity(row_count, ctx.allocator());
6666
let output = &mut values.slots()[..row_count];
6767

6868
let failure_evidence = if let Some(views) = Args::views_if_no_consts(&columns) {

‎vortex-array/src/scalar_fn/unstable/row/execute/tests.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn sink_payloads_use_allocator(#[case] traversal: Traversal) -> VortexResult<()>
321321
#[test]
322322
fn primitive_finish_reuses_allocation() {
323323
let (allocator, tracker) = tracking_allocator();
324-
let mut values = i64::allocate(3, &allocator);
324+
let mut values = i64::with_capacity(3, &allocator);
325325
let slots = &mut values.slots()[..3];
326326
let ptr = slots.as_ptr().cast::<i64>();
327327

@@ -455,7 +455,7 @@ impl OutputElement for One {
455455
i64::element_dtype()
456456
}
457457

458-
fn allocate(rows: usize, _allocator: &BufferAllocatorRef) -> Self::Buffer {
458+
fn with_capacity(rows: usize, _allocator: &BufferAllocatorRef) -> Self::Buffer {
459459
vec![MaybeUninit::uninit(); rows]
460460
}
461461
}

‎vortex-array/src/scalar_fn/unstable/row/types/element/bool.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl OutputElement for bool {
101101
DType::Bool(Nullability::NonNullable)
102102
}
103103

104-
fn allocate(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
104+
fn with_capacity(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
105105
allocator.with_capacity(rows)
106106
}
107107

‎vortex-array/src/scalar_fn/unstable/row/types/element/output.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ pub trait OutputElement: 'static + Sized + Default {
3636
///
3737
/// Finishing the buffer must produce an all-valid column whose dtype matches
3838
/// [`element_dtype`](Self::element_dtype) except for outer nullability.
39-
fn allocate(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer;
39+
fn with_capacity(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer;
4040

4141
/// Map a contiguous row source directly into an all-valid column.
4242
///
43-
/// The default writes into the storage returned by [`allocate`](Self::allocate), then finishes it.
43+
/// The default writes into the storage returned by [`with_capacity`](Self::with_capacity), then
44+
/// finishes it.
4445
/// An output type can override this method when its physical representation supports a more
4546
/// efficient bulk mapping. The implementation **must** call `apply` exactly once for every
4647
/// source row in increasing order and return the same values as the default implementation.
@@ -57,7 +58,7 @@ pub trait OutputElement: 'static + Sized + Default {
5758
F: Fn(S::Item) -> Self,
5859
{
5960
let row_count = source.len();
60-
let mut values = Self::allocate(row_count, allocator);
61+
let mut values = Self::with_capacity(row_count, allocator);
6162
let output = &mut values.slots()[..row_count];
6263

6364
source.map_into(output, apply);

‎vortex-array/src/scalar_fn/unstable/row/types/element/primitive.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<T: NativePType> OutputElement for T {
109109
DType::Primitive(T::PTYPE, Nullability::NonNullable)
110110
}
111111

112-
fn allocate(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
112+
fn with_capacity(rows: usize, allocator: &BufferAllocatorRef) -> Self::Buffer {
113113
allocator.with_capacity(rows)
114114
}
115115
}

‎vortex-array/src/scalar_fn/unstable/row/types/sink/fixed_size_list.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ unsafe impl<T: OutputElement + Copy + Default> OutputSink for FixedSizeListSink<
132132
})?;
133133

134134
Ok(Self {
135-
values: T::allocate(element_capacity, allocator),
135+
values: T::with_capacity(element_capacity, allocator),
136136
allocator: allocator.clone(),
137137
width,
138138
row_count: rows,

‎vortex-array/src/scalar_fn/unstable/row/types/sink/uninit_element.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ unsafe impl<T: OutputElement + Copy + Default> OutputSink for UninitElementSink<
112112
allocator: &BufferAllocatorRef,
113113
) -> VortexResult<Self> {
114114
Ok(Self {
115-
values: T::allocate(rows, allocator),
115+
values: T::with_capacity(rows, allocator),
116116
allocator: allocator.clone(),
117117
row_count: rows,
118118
})

0 commit comments

Comments
 (0)