From 601968b014232a7c4fcdd17beaa762da71d67067 Mon Sep 17 00:00:00 2001 From: Palladium Date: Fri, 19 Aug 2022 17:10:02 +0530 Subject: [PATCH] remove len field from MapBuilder (#2520) --- arrow/src/array/builder/map_builder.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arrow/src/array/builder/map_builder.rs b/arrow/src/array/builder/map_builder.rs index 7e68abd5f1a1..d59ce3476de7 100644 --- a/arrow/src/array/builder/map_builder.rs +++ b/arrow/src/array/builder/map_builder.rs @@ -36,7 +36,6 @@ pub struct MapBuilder { field_names: MapFieldNames, key_builder: K, value_builder: V, - len: i32, } #[derive(Debug, Clone)] @@ -82,7 +81,6 @@ impl MapBuilder { field_names: field_names.unwrap_or_default(), key_builder, value_builder, - len, } } @@ -108,13 +106,11 @@ impl MapBuilder { } self.offsets_builder.append(self.key_builder.len() as i32); self.null_buffer_builder.append(is_valid); - self.len += 1; Ok(()) } pub fn finish(&mut self) -> MapArray { let len = self.len(); - self.len = 0; // Build the keys let keys_arr = self @@ -146,7 +142,7 @@ impl MapBuilder { let offset_buffer = self.offsets_builder.finish(); let null_bit_buffer = self.null_buffer_builder.finish(); - self.offsets_builder.append(self.len); + self.offsets_builder.append(0); let map_field = Box::new(Field::new( self.field_names.entry.as_str(), struct_array.data_type().clone(), @@ -166,11 +162,11 @@ impl MapBuilder { impl ArrayBuilder for MapBuilder { fn len(&self) -> usize { - self.len as usize + self.null_buffer_builder.len() } fn is_empty(&self) -> bool { - self.len == 0 + self.len() == 0 } fn finish(&mut self) -> ArrayRef {