This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 72cafde586 Provide default `is_empty` impl for 
`arrow::array::ArrayBuilder` (#4543)
72cafde586 is described below

commit 72cafde586af831d911473c6d1bbd56d2482cfdb
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Wed Jul 19 18:11:48 2023 +0200

    Provide default `is_empty` impl for `arrow::array::ArrayBuilder` (#4543)
---
 arrow-array/src/builder/boolean_builder.rs                  | 5 -----
 arrow-array/src/builder/fixed_size_binary_builder.rs        | 5 -----
 arrow-array/src/builder/fixed_size_list_builder.rs          | 5 -----
 arrow-array/src/builder/generic_byte_run_builder.rs         | 5 -----
 arrow-array/src/builder/generic_bytes_builder.rs            | 5 -----
 arrow-array/src/builder/generic_bytes_dictionary_builder.rs | 5 -----
 arrow-array/src/builder/generic_list_builder.rs             | 5 -----
 arrow-array/src/builder/map_builder.rs                      | 4 ----
 arrow-array/src/builder/mod.rs                              | 4 +++-
 arrow-array/src/builder/null_builder.rs                     | 5 -----
 arrow-array/src/builder/primitive_builder.rs                | 5 -----
 arrow-array/src/builder/primitive_dictionary_builder.rs     | 5 -----
 arrow-array/src/builder/primitive_run_builder.rs            | 5 -----
 arrow-array/src/builder/struct_builder.rs                   | 5 -----
 14 files changed, 3 insertions(+), 65 deletions(-)

diff --git a/arrow-array/src/builder/boolean_builder.rs 
b/arrow-array/src/builder/boolean_builder.rs
index b4283775e6..5f00132696 100644
--- a/arrow-array/src/builder/boolean_builder.rs
+++ b/arrow-array/src/builder/boolean_builder.rs
@@ -197,11 +197,6 @@ impl ArrayBuilder for BooleanBuilder {
         self.values_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.values_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/fixed_size_binary_builder.rs 
b/arrow-array/src/builder/fixed_size_binary_builder.rs
index a213b3bbf8..180150e988 100644
--- a/arrow-array/src/builder/fixed_size_binary_builder.rs
+++ b/arrow-array/src/builder/fixed_size_binary_builder.rs
@@ -139,11 +139,6 @@ impl ArrayBuilder for FixedSizeBinaryBuilder {
         self.null_buffer_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.null_buffer_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/fixed_size_list_builder.rs 
b/arrow-array/src/builder/fixed_size_list_builder.rs
index 0dd5804430..f7e8999099 100644
--- a/arrow-array/src/builder/fixed_size_list_builder.rs
+++ b/arrow-array/src/builder/fixed_size_list_builder.rs
@@ -113,11 +113,6 @@ where
         self.null_buffer_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.null_buffer_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/generic_byte_run_builder.rs 
b/arrow-array/src/builder/generic_byte_run_builder.rs
index 4e3f36889a..41165208de 100644
--- a/arrow-array/src/builder/generic_byte_run_builder.rs
+++ b/arrow-array/src/builder/generic_byte_run_builder.rs
@@ -150,11 +150,6 @@ where
         self.current_run_end_index
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.current_run_end_index == 0
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/generic_bytes_builder.rs 
b/arrow-array/src/builder/generic_bytes_builder.rs
index f77940055b..d84be8c2fc 100644
--- a/arrow-array/src/builder/generic_bytes_builder.rs
+++ b/arrow-array/src/builder/generic_bytes_builder.rs
@@ -189,11 +189,6 @@ impl<T: ByteArrayType> ArrayBuilder for 
GenericByteBuilder<T> {
         self.null_buffer_builder.len()
     }
 
-    /// Returns whether the number of binary slots is zero
-    fn is_empty(&self) -> bool {
-        self.null_buffer_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/generic_bytes_dictionary_builder.rs 
b/arrow-array/src/builder/generic_bytes_dictionary_builder.rs
index d5c62865ff..282f423fa6 100644
--- a/arrow-array/src/builder/generic_bytes_dictionary_builder.rs
+++ b/arrow-array/src/builder/generic_bytes_dictionary_builder.rs
@@ -193,11 +193,6 @@ where
         self.keys_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.keys_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/generic_list_builder.rs 
b/arrow-array/src/builder/generic_list_builder.rs
index 99e15d10f3..b31814615f 100644
--- a/arrow-array/src/builder/generic_list_builder.rs
+++ b/arrow-array/src/builder/generic_list_builder.rs
@@ -91,11 +91,6 @@ where
         self.null_buffer_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.null_buffer_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/map_builder.rs 
b/arrow-array/src/builder/map_builder.rs
index 56b5619cea..4e3ec4a794 100644
--- a/arrow-array/src/builder/map_builder.rs
+++ b/arrow-array/src/builder/map_builder.rs
@@ -214,10 +214,6 @@ impl<K: ArrayBuilder, V: ArrayBuilder> ArrayBuilder for 
MapBuilder<K, V> {
         self.null_buffer_builder.len()
     }
 
-    fn is_empty(&self) -> bool {
-        self.len() == 0
-    }
-
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
     }
diff --git a/arrow-array/src/builder/mod.rs b/arrow-array/src/builder/mod.rs
index 1e5e6426be..38a7500dd5 100644
--- a/arrow-array/src/builder/mod.rs
+++ b/arrow-array/src/builder/mod.rs
@@ -237,7 +237,9 @@ pub trait ArrayBuilder: Any + Send {
     fn len(&self) -> usize;
 
     /// Returns whether number of array slots is zero
-    fn is_empty(&self) -> bool;
+    fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
 
     /// Builds the array
     fn finish(&mut self) -> ArrayRef;
diff --git a/arrow-array/src/builder/null_builder.rs 
b/arrow-array/src/builder/null_builder.rs
index 0b43450069..94cb7f5cc2 100644
--- a/arrow-array/src/builder/null_builder.rs
+++ b/arrow-array/src/builder/null_builder.rs
@@ -133,11 +133,6 @@ impl ArrayBuilder for NullBuilder {
         self.len
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.len() == 0
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/primitive_builder.rs 
b/arrow-array/src/builder/primitive_builder.rs
index 3e31b1d055..b23d6bba36 100644
--- a/arrow-array/src/builder/primitive_builder.rs
+++ b/arrow-array/src/builder/primitive_builder.rs
@@ -121,11 +121,6 @@ impl<T: ArrowPrimitiveType> ArrayBuilder for 
PrimitiveBuilder<T> {
         self.values_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.values_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/primitive_dictionary_builder.rs 
b/arrow-array/src/builder/primitive_dictionary_builder.rs
index cde1abe22b..7323ee5762 100644
--- a/arrow-array/src/builder/primitive_dictionary_builder.rs
+++ b/arrow-array/src/builder/primitive_dictionary_builder.rs
@@ -194,11 +194,6 @@ where
         self.keys_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.keys_builder.is_empty()
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/primitive_run_builder.rs 
b/arrow-array/src/builder/primitive_run_builder.rs
index 53674a73b1..01a989199b 100644
--- a/arrow-array/src/builder/primitive_run_builder.rs
+++ b/arrow-array/src/builder/primitive_run_builder.rs
@@ -136,11 +136,6 @@ where
         self.current_run_end_index
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.current_run_end_index == 0
-    }
-
     /// Builds the array and reset this builder.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())
diff --git a/arrow-array/src/builder/struct_builder.rs 
b/arrow-array/src/builder/struct_builder.rs
index 88a23db6d1..0c878e6210 100644
--- a/arrow-array/src/builder/struct_builder.rs
+++ b/arrow-array/src/builder/struct_builder.rs
@@ -52,11 +52,6 @@ impl ArrayBuilder for StructBuilder {
         self.null_buffer_builder.len()
     }
 
-    /// Returns whether the number of array slots is zero
-    fn is_empty(&self) -> bool {
-        self.len() == 0
-    }
-
     /// Builds the array.
     fn finish(&mut self) -> ArrayRef {
         Arc::new(self.finish())

Reply via email to