diff --git a/arrow-array/src/array/byte_array.rs b/arrow-array/src/array/byte_array.rs index a57abc5b1e71..bec0caab1045 100644 --- a/arrow-array/src/array/byte_array.rs +++ b/arrow-array/src/array/byte_array.rs @@ -461,6 +461,11 @@ impl Array for GenericByteArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut sum = self.value_offsets.inner().inner().capacity(); sum += self.value_data.capacity(); diff --git a/arrow-array/src/array/byte_view_array.rs b/arrow-array/src/array/byte_view_array.rs index a35df0d200be..81bb6a38550b 100644 --- a/arrow-array/src/array/byte_view_array.rs +++ b/arrow-array/src/array/byte_view_array.rs @@ -583,6 +583,11 @@ impl Array for GenericByteViewArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut sum = self.buffers.iter().map(|b| b.capacity()).sum::(); sum += self.views.inner().capacity(); diff --git a/arrow-array/src/array/dictionary_array.rs b/arrow-array/src/array/dictionary_array.rs index 6f27b383c0ea..1187e16769a0 100644 --- a/arrow-array/src/array/dictionary_array.rs +++ b/arrow-array/src/array/dictionary_array.rs @@ -866,6 +866,10 @@ impl Array for TypedDictionaryArray<'_, K, V self.dictionary.logical_nulls() } + fn logical_null_count(&self) -> usize { + self.dictionary.logical_null_count() + } + fn is_nullable(&self) -> bool { self.dictionary.is_nullable() } diff --git a/arrow-array/src/array/fixed_size_binary_array.rs b/arrow-array/src/array/fixed_size_binary_array.rs index 1371e81e2650..8f1489ee4c3c 100644 --- a/arrow-array/src/array/fixed_size_binary_array.rs +++ b/arrow-array/src/array/fixed_size_binary_array.rs @@ -610,6 +610,11 @@ impl Array for FixedSizeBinaryArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut sum = self.value_data.capacity(); if let Some(n) = &self.nulls { diff --git a/arrow-array/src/array/fixed_size_list_array.rs b/arrow-array/src/array/fixed_size_list_array.rs index 72855cef1f04..00a3144a87ad 100644 --- a/arrow-array/src/array/fixed_size_list_array.rs +++ b/arrow-array/src/array/fixed_size_list_array.rs @@ -409,6 +409,11 @@ impl Array for FixedSizeListArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut size = self.values.get_buffer_memory_size(); if let Some(n) = self.nulls.as_ref() { diff --git a/arrow-array/src/array/list_array.rs b/arrow-array/src/array/list_array.rs index 06d5ee4e142d..1fab0009f2cc 100644 --- a/arrow-array/src/array/list_array.rs +++ b/arrow-array/src/array/list_array.rs @@ -493,6 +493,11 @@ impl Array for GenericListArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut size = self.values.get_buffer_memory_size(); size += self.value_offsets.inner().inner().capacity(); diff --git a/arrow-array/src/array/list_view_array.rs b/arrow-array/src/array/list_view_array.rs index bab686c3e47a..4e949a642701 100644 --- a/arrow-array/src/array/list_view_array.rs +++ b/arrow-array/src/array/list_view_array.rs @@ -334,6 +334,11 @@ impl Array for GenericListViewArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut size = self.values.get_buffer_memory_size(); size += self.value_offsets.inner().capacity(); diff --git a/arrow-array/src/array/map_array.rs b/arrow-array/src/array/map_array.rs index d40b8ee84518..254437630a44 100644 --- a/arrow-array/src/array/map_array.rs +++ b/arrow-array/src/array/map_array.rs @@ -380,6 +380,11 @@ impl Array for MapArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut size = self.entries.get_buffer_memory_size(); size += self.value_offsets.inner().inner().capacity(); diff --git a/arrow-array/src/array/run_array.rs b/arrow-array/src/array/run_array.rs index 81c8cdcea4d3..dc4e6c96d9da 100644 --- a/arrow-array/src/array/run_array.rs +++ b/arrow-array/src/array/run_array.rs @@ -596,6 +596,10 @@ impl Array for TypedRunArray<'_, R, V> { self.run_array.logical_nulls() } + fn logical_null_count(&self) -> usize { + self.run_array.logical_null_count() + } + fn is_nullable(&self) -> bool { self.run_array.is_nullable() } diff --git a/arrow-array/src/array/struct_array.rs b/arrow-array/src/array/struct_array.rs index d8bb1ace7a8c..41eb8235e540 100644 --- a/arrow-array/src/array/struct_array.rs +++ b/arrow-array/src/array/struct_array.rs @@ -378,6 +378,11 @@ impl Array for StructArray { self.nulls.as_ref() } + fn logical_null_count(&self) -> usize { + // More efficient that the default implementation + self.null_count() + } + fn get_buffer_memory_size(&self) -> usize { let mut size = self.fields.iter().map(|a| a.get_buffer_memory_size()).sum(); if let Some(n) = self.nulls.as_ref() {