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/05/21 18:30:28 UTC

[arrow-rs] branch master updated: return reference from DictionaryArray::values() (#313) (#314)

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-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 71c2159  return reference from DictionaryArray::values() (#313) (#314)
71c2159 is described below

commit 71c21595a0856e4f87838c8c3bb5f2b04fb88024
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Fri May 21 19:30:23 2021 +0100

    return reference from DictionaryArray::values() (#313) (#314)
    
    Signed-off-by: Raphael Taylor-Davies <r....@googlemail.com>
---
 arrow/src/array/array_dictionary.rs | 6 +++---
 arrow/src/compute/kernels/cast.rs   | 4 ++--
 arrow/src/compute/kernels/sort.rs   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arrow/src/array/array_dictionary.rs b/arrow/src/array/array_dictionary.rs
index 5948658..9b036da 100644
--- a/arrow/src/array/array_dictionary.rs
+++ b/arrow/src/array/array_dictionary.rs
@@ -101,9 +101,9 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
             .flatten()
     }
 
-    /// Returns an `ArrayRef` to the dictionary values.
-    pub fn values(&self) -> ArrayRef {
-        self.values.clone()
+    /// Returns a reference to the dictionary values array
+    pub fn values(&self) -> &ArrayRef {
+        &self.values
     }
 
     /// Returns a clone of the value type of this list.
diff --git a/arrow/src/compute/kernels/cast.rs b/arrow/src/compute/kernels/cast.rs
index de1516b..4c5bb93 100644
--- a/arrow/src/compute/kernels/cast.rs
+++ b/arrow/src/compute/kernels/cast.rs
@@ -1371,10 +1371,10 @@ fn dictionary_cast<K: ArrowDictionaryKeyType>(
                 })?;
 
             let keys_array: ArrayRef = Arc::new(dict_array.keys_array());
-            let values_array: ArrayRef = dict_array.values();
+            let values_array = dict_array.values();
             let cast_keys = cast_with_options(&keys_array, to_index_type, &cast_options)?;
             let cast_values =
-                cast_with_options(&values_array, to_value_type, &cast_options)?;
+                cast_with_options(values_array, to_value_type, &cast_options)?;
 
             // Failure to cast keys (because they don't fit in the
             // target type) results in NULL values;
diff --git a/arrow/src/compute/kernels/sort.rs b/arrow/src/compute/kernels/sort.rs
index 7cd463d..0a02167 100644
--- a/arrow/src/compute/kernels/sort.rs
+++ b/arrow/src/compute/kernels/sort.rs
@@ -1007,7 +1007,7 @@ mod tests {
         expected_data: Vec<Option<&str>>,
     ) {
         let array = DictionaryArray::<T>::from_iter(data.into_iter());
-        let array_values = array.values();
+        let array_values = array.values().clone();
         let dict = array_values
             .as_any()
             .downcast_ref::<StringArray>()