Skip to content

Commit 80bd461

Browse files
committed
ArrayRef
Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent 035fb48 commit 80bd461

7 files changed

Lines changed: 16 additions & 176 deletions

File tree

ARRAYVIEW_PLAN.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

PLAN.md

Lines changed: 0 additions & 145 deletions
This file was deleted.

vortex-array/src/arrays/chunked/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl ChunkedData {
154154

155155
#[inline]
156156
pub fn chunk_offsets(&self) -> Buffer<u64> {
157-
self.chunk_offsets.to_buffer()
157+
self.chunk_offsets_data().to_buffer()
158158
}
159159

160160
pub(crate) fn find_chunk_idx(&self, index: usize) -> VortexResult<(usize, usize)> {

vortex-array/src/arrays/chunked/vtable/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::Precision;
1919
use crate::ToCanonical;
2020
use crate::arrays::ChunkedData;
2121
use crate::arrays::PrimitiveData;
22+
use crate::arrays::chunked::array::CHUNK_OFFSETS_SLOT;
23+
use crate::arrays::chunked::array::CHUNKS_OFFSET;
2224
use crate::arrays::chunked::compute::kernel::PARENT_KERNELS;
2325
use crate::arrays::chunked::compute::rules::PARENT_RULES;
2426
use crate::arrays::chunked::vtable::canonical::_canonicalize;
@@ -210,17 +212,17 @@ impl VTable for Chunked {
210212

211213
fn slot_name(_array: ArrayView<'_, Self>, idx: usize) -> String {
212214
match idx {
213-
0 => "chunk_offsets".to_string(),
214-
n => format!("chunks[{}]", n - 1),
215+
CHUNK_OFFSETS_SLOT => "chunk_offsets".to_string(),
216+
n => format!("chunks[{}]", n - CHUNKS_OFFSET),
215217
}
216218
}
217219

218220
fn with_slots(array: &mut Self::ArrayData, slots: Vec<Option<ArrayRef>>) -> VortexResult<()> {
219221
// Slots: chunk_offsets, then chunks...
220222
vortex_ensure!(!slots.is_empty(), "Chunked array needs at least one slot");
221223

222-
let nchunks = slots.len() - 1;
223-
let chunk_offsets_ref = slots[0]
224+
let nchunks = slots.len() - CHUNKS_OFFSET;
225+
let chunk_offsets_ref = slots[CHUNK_OFFSETS_SLOT]
224226
.as_ref()
225227
.ok_or_else(|| vortex_err!("chunk_offsets slot must not be None"))?;
226228
let chunk_offsets_buf = chunk_offsets_ref.to_primitive().to_buffer::<u64>();
@@ -232,7 +234,7 @@ impl VTable for Chunked {
232234
chunk_offsets_buf.len()
233235
);
234236

235-
let chunks: Vec<ArrayRef> = slots[1..]
237+
let chunks: Vec<ArrayRef> = slots[CHUNKS_OFFSET..]
236238
.iter()
237239
.map(|s| {
238240
s.clone()

vortex-array/src/arrays/constant/vtable/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::ExecutionResult;
1717
use crate::IntoArray;
1818
use crate::Precision;
1919
use crate::arrays::ConstantData;
20+
use crate::arrays::constant::array::NUM_SLOTS;
2021
use crate::arrays::constant::compute::rules::PARENT_RULES;
2122
use crate::arrays::constant::vtable::canonical::constant_canonicalize;
2223
use crate::buffer::BufferHandle;
@@ -176,8 +177,9 @@ impl VTable for Constant {
176177

177178
fn with_slots(_array: &mut Self::ArrayData, slots: Vec<Option<ArrayRef>>) -> VortexResult<()> {
178179
vortex_ensure!(
179-
slots.is_empty(),
180-
"ConstantArray has no slots, got {}",
180+
slots.len() == NUM_SLOTS,
181+
"ConstantArray expects exactly {} slots, got {}",
182+
NUM_SLOTS,
181183
slots.len()
182184
);
183185
Ok(())

vortex-array/src/arrays/null/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ impl VTable for Null {
131131

132132
fn with_slots(_array: &mut Self::ArrayData, slots: Vec<Option<ArrayRef>>) -> VortexResult<()> {
133133
vortex_ensure!(
134-
slots.is_empty(),
135-
"NullArray has no slots, got {}",
134+
slots.len() == NUM_SLOTS,
135+
"NullArray expects exactly {} slots, got {}",
136+
NUM_SLOTS,
136137
slots.len()
137138
);
138139
Ok(())

vortex-array/src/vtable/typed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<V: VTable> Array<V> {
235235
// NOTE(ngates): use downcast_unchecked when it becomes stable
236236
debug_assert!(any.is::<ArrayInner<V>>());
237237
// SAFETY: caller guarantees that T is the correct type
238-
unsafe { &*(self as *const dyn Any as *const ArrayInner<V>) }
238+
unsafe { &*(any as *const dyn Any as *const ArrayInner<V>) }
239239
}
240240
}
241241

0 commit comments

Comments
 (0)