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

GH-44866: [C++] Minor enhance the doc and impl of DictionaryArray::Transpose #44867

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions cpp/src/arrow/array/array_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ struct CompactTransposeMapVisitor {
AllocateBuffer(dict_length * sizeof(int32_t), pool));
auto* output_map_raw = output_map->mutable_data_as<int32_t>();
int32_t current_index = 0;
for (CType i = 0; i < dict_len; i++) {
for (CType i = 0; i < dict_len; ++i) {
if (dict_used[i]) {
dict_indices_builder.UnsafeAppend(i);
output_map_raw[i] = current_index;
Expand Down Expand Up @@ -309,7 +309,7 @@ Result<std::unique_ptr<Buffer>> CompactTransposeMap(
CompactTransposeMapVisitor visitor{data, pool, nullptr, nullptr};
RETURN_NOT_OK(VisitTypeInline(*dict_type.index_type(), &visitor));

out_compact_dictionary = visitor.out_compact_dictionary;
out_compact_dictionary = std::move(visitor.out_compact_dictionary);
return std::move(visitor.output_map);
}
} // namespace
Expand All @@ -320,7 +320,7 @@ Result<std::shared_ptr<Array>> DictionaryArray::Transpose(
ARROW_ASSIGN_OR_RAISE(auto transposed,
TransposeDictIndices(data_, data_->type, type, dictionary->data(),
transpose_map, pool));
return MakeArray(std::move(transposed));
return MakeArray(transposed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because MakeArray takes a const ref as argument..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, perhaps MakeArray will be fixed at some point, but there's no reason to remove the move here? It's not worse in any case?

}

Result<std::shared_ptr<Array>> DictionaryArray::Compact(MemoryPool* pool) const {
Expand Down Expand Up @@ -520,8 +520,8 @@ struct RecursiveUnifier {

Result<std::unique_ptr<DictionaryUnifier>> DictionaryUnifier::Make(
std::shared_ptr<DataType> value_type, MemoryPool* pool) {
MakeUnifier maker(pool, value_type);
RETURN_NOT_OK(VisitTypeInline(*value_type, &maker));
MakeUnifier maker(pool, std::move(value_type));
RETURN_NOT_OK(VisitTypeInline(*maker.value_type, &maker));
return std::move(maker.result);
}

Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/array/array_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class ARROW_EXPORT DictionaryArray : public Array {
/// \param[in] type the new type object
/// \param[in] dictionary the new dictionary
/// \param[in] transpose_map transposition array of this array's indices
/// into the target array's indices
/// into the target array's indices. The value of transpose_map should
/// be in the range [0, this->length()).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether this should be DCHECK-ed

///
/// \param[in] pool a pool to allocate the array data from
Result<std::shared_ptr<Array>> Transpose(
const std::shared_ptr<DataType>& type, const std::shared_ptr<Array>& dictionary,
Expand Down
Loading