Skip to content

Commit

Permalink
Further cleanup and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Mar 23, 2023
1 parent d58996f commit 1ddbb77
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions arrow-arith/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ fn math_checked_divide_op_on_iters<T, F>(
left: impl Iterator<Item = Option<T::Native>>,
right: impl Iterator<Item = Option<T::Native>>,
op: F,
nulls: Option<NullBuffer>,
nulls: Option<arrow_buffer::NullBuffer>,
) -> Result<PrimitiveArray<T>, ArrowError>
where
T: ArrowNumericType,
F: Fn(T::Native, T::Native) -> Result<T::Native, ArrowError>,
{
let buffer = if null_bit_buffer.is_some() {
let buffer = if nulls.is_some() {
let values = left.zip(right).map(|(left, right)| {
if let (Some(l), Some(r)) = (left, right) {
op(l, r)
Expand Down Expand Up @@ -272,17 +272,16 @@ where
}

// Create the combined `Bitmap`
let nulls = NullBuffer::union(left.nulls(), right.nulls());
let nulls = arrow_buffer::NullBuffer::union(left.nulls(), right.nulls());

let lanes = T::lanes();
let buffer_size = left.len() * std::mem::size_of::<T::Native>();
let mut result =
arrow_buffer::MutableBuffer::new(buffer_size).with_bitset(buffer_size, false);

match &null_bit_buffer {
match &nulls {
Some(b) => {
// combine_option_bitmap returns a slice or new buffer starting at 0
let valid_chunks = b.bit_chunks(0, left.len());
let valid_chunks = b.inner().bit_chunks();

// process data in chunks of 64 elements since we also get 64 bits of validity information at a time

Expand Down Expand Up @@ -602,7 +601,7 @@ where
)));
}

let nulls = NullBuffer::union(left.nulls(), right.nulls());
let nulls = arrow_buffer::NullBuffer::union(left.nulls(), right.nulls());

// Safety justification: Since the inputs are valid Arrow arrays, all values are
// valid indexes into the dictionary (which is verified during construction)
Expand Down
2 changes: 1 addition & 1 deletion arrow-arith/src/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ pub fn is_null(input: &dyn Array) -> Result<BooleanArray, ArrowError> {
pub fn is_not_null(input: &dyn Array) -> Result<BooleanArray, ArrowError> {
let len = input.len();

let output = match input.data_ref().nulls() {
let output = match input.nulls() {
None => {
let len_bytes = ceil(len, 8);
MutableBuffer::new(len_bytes)
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/dictionary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl<K: ArrowDictionaryKeyType> DictionaryArray<K> {

/// Returns a clone of the value type of this list.
pub fn value_type(&self) -> DataType {
self.values.data_ref().data_type().clone()
self.values.data_type().clone()
}

/// The length of the dictionary is the length of the keys array.
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl From<FixedSizeListArray> for FixedSizeBinaryArray {
.len(v.len())
.offset(v.offset())
.add_buffer(child_data.buffers()[0].slice(child_data.offset()))
.nulls(v.data_ref().nulls().cloned());
.nulls(v.nulls().cloned());

let data = unsafe { builder.build_unchecked() };
Self::from(data)
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/fixed_size_list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl FixedSizeListArray {

/// Returns a clone of the value type of this list.
pub fn value_type(&self) -> DataType {
self.values.data_ref().data_type().clone()
self.values.data_type().clone()
}

/// Returns ith value of this list array.
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {

/// Returns a clone of the value type of this list.
pub fn value_type(&self) -> DataType {
self.values.data_ref().data_type().clone()
self.values.data_type().clone()
}

/// Returns ith value of this list array.
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/null_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Array for NullArray {
/// Returns the total number of null values in this array.
/// The null count of a `NullArray` always equals its length.
fn null_count(&self) -> usize {
self.data_ref().len()
self.len()
}
}

Expand Down

0 comments on commit 1ddbb77

Please sign in to comment.