Skip to content

Commit 44844aa

Browse files
committed
Remove VTable::nchildren; count non-None slots at the call sites
Same treatment as VTable::child: the only override (PythonVTable) matched the default, so the method was not a real customization point. Signed-off-by: "Joe Isaacs" <joe.isaacs@live.co.uk> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XbjnDVZQ9KqXgAAhxy9g7D
1 parent 03d6ef7 commit 44844aa

3 files changed

Lines changed: 9 additions & 17 deletions

File tree

vortex-array/src/array/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ impl<V: VTable> DynArrayData for ArrayData<V> {
273273
}
274274

275275
fn nchildren(&self, this: &ArrayRef) -> usize {
276-
let view = unsafe { ArrayView::new_unchecked(this, &self.data) };
277-
V::nchildren(view)
276+
let view: ArrayView<'_, V> = unsafe { ArrayView::new_unchecked(this, &self.data) };
277+
view.slots().iter().filter(|s| s.is_some()).count()
278278
}
279279

280280
fn nth_child(&self, this: &ArrayRef, idx: usize) -> Option<ArrayRef> {
@@ -287,9 +287,12 @@ impl<V: VTable> DynArrayData for ArrayData<V> {
287287
}
288288

289289
fn children_names(&self, this: &ArrayRef) -> Vec<String> {
290-
let view = unsafe { ArrayView::new_unchecked(this, &self.data) };
291-
(0..V::nchildren(view))
292-
.map(|i| V::child_name(view, i))
290+
let view: ArrayView<'_, V> = unsafe { ArrayView::new_unchecked(this, &self.data) };
291+
view.slots()
292+
.iter()
293+
.filter(|s| s.is_some())
294+
.enumerate()
295+
.map(|(i, _)| V::child_name(view, i))
293296
.collect()
294297
}
295298

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,12 @@ pub trait VTable: 'static + Clone + Sized + Send + Sync + Debug {
115115
buffers: &[BufferHandle],
116116
) -> VortexResult<ArrayParts<Self>>;
117117

118-
/// Returns the number of children in the array.
119-
///
120-
/// The default counts non-None slots.
121-
fn nchildren(array: ArrayView<'_, Self>) -> usize {
122-
array.slots().iter().filter(|s| s.is_some()).count()
123-
}
124-
125118
/// Returns the name of the child at the given index.
126119
///
127120
/// The default returns the slot name of the `idx`-th non-None slot.
128121
///
129122
/// # Panics
130-
/// Panics if `idx >= nchildren(array)`.
123+
/// Panics if `idx` is not less than the number of non-None slots.
131124
fn child_name(array: ArrayView<'_, Self>, idx: usize) -> String {
132125
array
133126
.slots()

vortex-python/src/arrays/py/vtable.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ impl VTable for PythonVTable {
9292
with_empty_buffers(self, array, buffers)
9393
}
9494

95-
fn nchildren(_array: ArrayView<'_, Self>) -> usize {
96-
0
97-
}
98-
9995
fn child_name(_array: ArrayView<'_, Self>, idx: usize) -> String {
10096
vortex_panic!("PythonArray child_name index {idx} out of bounds")
10197
}

0 commit comments

Comments
 (0)