Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return reference from DictionaryArray::values() (#313) #314

Merged
merged 1 commit into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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