Skip to content

Commit

Permalink
return reference from DictionaryArray::values() (#313)
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
  • Loading branch information
tustvold committed May 17, 2021
1 parent c863a2c commit 6217913
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions arrow/src/array/array_dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/compute/kernels/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>()
Expand Down

0 comments on commit 6217913

Please sign in to comment.