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

Conversation

mapleFU
Copy link
Member

@mapleFU mapleFU commented Nov 27, 2024

Rationale for this change

Minor enhance the doc and impl of DictionaryArray::Transpose

What changes are included in this PR?

Minor enhance the doc and impl of DictionaryArray::Transpose

Are these changes tested?

Covered by existing

Are there any user-facing changes?

No

Copy link

⚠️ GitHub issue #44866 has been automatically assigned in GitHub to PR creator.

@@ -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

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Nov 27, 2024
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Nov 28, 2024
@mapleFU
Copy link
Member Author

mapleFU commented Nov 28, 2024

@pitrou Would you mind take a look?

@@ -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?

/// into the target array's indices. The value of transpose_map should
/// be in the range [0, this->length()). And the dictionary array's
/// indices in the target array's indices should be in the range
/// of [0, dictionary->length()).
Copy link
Member

Choose a reason for hiding this comment

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

Those two sentences are difficult to understand, and I'm not sure they are correct either. Are you sure you want to add 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.

It's from the user-case here #44827 . I think we should try describe this well

Copy link
Member

Choose a reason for hiding this comment

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

I'm against this: 1) this should be obvious from the function description 2) your description seems wrong (the transpose_map values should be in [0, dictionary->length()), not [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.

You're right, one is dictionary indice, another is dictionary's dictionary's indices...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants