You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/03/14 10:42:11 UTC

[arrow] branch master updated: ARROW-11951: [Rust] Remove OffsetSize::prefix

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8420e26  ARROW-11951: [Rust] Remove OffsetSize::prefix
8420e26 is described below

commit 8420e2670b31b46753b312b236ac263d6f4da365
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Sun Mar 14 06:40:48 2021 -0400

    ARROW-11951: [Rust] Remove OffsetSize::prefix
    
    # Background:
    Left over cleanups suggested by from @sunchao on  https://github.com/apache/arrow/pull/9425
    
    Broken out from https://github.com/apache/arrow/pull/9508
    
    # Rationale:
    This function is redundant with `OffsetSize::is_large`
    
    Closes #9690 from alamb/alamb/remove_prefix
    
    Authored-by: Andrew Lamb <an...@nerdnetworks.org>
    Signed-off-by: Andrew Lamb <an...@nerdnetworks.org>
---
 rust/arrow/src/array/array_binary.rs |  4 +++-
 rust/arrow/src/array/array_list.rs   | 16 ++++------------
 rust/arrow/src/array/array_string.rs |  4 +++-
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/rust/arrow/src/array/array_binary.rs b/rust/arrow/src/array/array_binary.rs
index 9bc182e..475e954 100644
--- a/rust/arrow/src/array/array_binary.rs
+++ b/rust/arrow/src/array/array_binary.rs
@@ -183,7 +183,9 @@ impl<'a, T: BinaryOffsetSizeTrait> GenericBinaryArray<T> {
 
 impl<OffsetSize: BinaryOffsetSizeTrait> fmt::Debug for GenericBinaryArray<OffsetSize> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}BinaryArray\n[\n", OffsetSize::prefix())?;
+        let prefix = if OffsetSize::is_large() { "Large" } else { "" };
+
+        write!(f, "{}BinaryArray\n[\n", prefix)?;
         print_long_array(self, f, |array, index, f| {
             fmt::Debug::fmt(&array.value(index), f)
         })?;
diff --git a/rust/arrow/src/array/array_list.rs b/rust/arrow/src/array/array_list.rs
index 4eb9e5d..8117b8b 100644
--- a/rust/arrow/src/array/array_list.rs
+++ b/rust/arrow/src/array/array_list.rs
@@ -32,8 +32,6 @@ use crate::datatypes::{ArrowNativeType, ArrowPrimitiveType, DataType, Field};
 /// trait declaring an offset size, relevant for i32 vs i64 array types.
 pub trait OffsetSizeTrait: ArrowNativeType + Num + Ord + std::ops::AddAssign {
     fn is_large() -> bool;
-
-    fn prefix() -> &'static str;
 }
 
 impl OffsetSizeTrait for i32 {
@@ -41,10 +39,6 @@ impl OffsetSizeTrait for i32 {
     fn is_large() -> bool {
         false
     }
-
-    fn prefix() -> &'static str {
-        ""
-    }
 }
 
 impl OffsetSizeTrait for i64 {
@@ -52,10 +46,6 @@ impl OffsetSizeTrait for i64 {
     fn is_large() -> bool {
         true
     }
-
-    fn prefix() -> &'static str {
-        "Large"
-    }
 }
 
 pub struct GenericListArray<OffsetSize> {
@@ -183,7 +173,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {
             .collect();
 
         let field = Box::new(Field::new("item", T::DATA_TYPE, true));
-        let data_type = if OffsetSize::prefix() == "Large" {
+        let data_type = if OffsetSize::is_large() {
             DataType::LargeList(field)
         } else {
             DataType::List(field)
@@ -266,7 +256,9 @@ impl<OffsetSize: 'static + OffsetSizeTrait> Array for GenericListArray<OffsetSiz
 
 impl<OffsetSize: OffsetSizeTrait> fmt::Debug for GenericListArray<OffsetSize> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}ListArray\n[\n", OffsetSize::prefix())?;
+        let prefix = if OffsetSize::is_large() { "Large" } else { "" };
+
+        write!(f, "{}ListArray\n[\n", prefix)?;
         print_long_array(self, f, |array, index, f| {
             fmt::Debug::fmt(&array.value(index), f)
         })?;
diff --git a/rust/arrow/src/array/array_string.rs b/rust/arrow/src/array/array_string.rs
index fa927bb..bc6f274 100644
--- a/rust/arrow/src/array/array_string.rs
+++ b/rust/arrow/src/array/array_string.rs
@@ -268,7 +268,9 @@ impl<'a, T: StringOffsetSizeTrait> GenericStringArray<T> {
 
 impl<OffsetSize: StringOffsetSizeTrait> fmt::Debug for GenericStringArray<OffsetSize> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}StringArray\n[\n", OffsetSize::prefix())?;
+        let prefix = if OffsetSize::is_large() { "Large" } else { "" };
+
+        write!(f, "{}StringArray\n[\n", prefix)?;
         print_long_array(self, f, |array, index, f| {
             fmt::Debug::fmt(&array.value(index), f)
         })?;