Skip to content

GH-31868: [C++] Support concatenating extension arrays#14463

Merged
jorisvandenbossche merged 4 commits into
apache:mainfrom
jorisvandenbossche:ARROW-16503-concat-extension
Apr 12, 2023
Merged

GH-31868: [C++] Support concatenating extension arrays#14463
jorisvandenbossche merged 4 commits into
apache:mainfrom
jorisvandenbossche:ARROW-16503-concat-extension

Conversation

@jorisvandenbossche

@jorisvandenbossche jorisvandenbossche commented Oct 20, 2022

Copy link
Copy Markdown
Member

(still needs a test in C++ and more elaborate tests (eg extension types with nested data))

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@lhoestq

lhoestq commented Dec 2, 2022

Copy link
Copy Markdown

Thanks for fixing this :) is there anything blocking this PR ?

@jorisvandenbossche jorisvandenbossche changed the title ARROW-16503: [C++] Support concatenating extension arrays GH-31868: [C++] Support concatenating extension arrays Apr 5, 2023
@github-actions

github-actions Bot commented Apr 5, 2023

Copy link
Copy Markdown

@jorisvandenbossche

Copy link
Copy Markdown
Member Author

is there anything blocking this PR ?

Nothing! Just me finding the time to update this, doing that now.

@jorisvandenbossche jorisvandenbossche force-pushed the ARROW-16503-concat-extension branch from c3824db to 8be5a38 Compare April 5, 2023 13:36
@jorisvandenbossche jorisvandenbossche marked this pull request as ready for review April 5, 2023 13:51
@jorisvandenbossche jorisvandenbossche added this to the 12.0.0 milestone Apr 11, 2023
Comment thread cpp/src/arrow/array/concatenate.cc Outdated
for (size_t i = 0; i < in_.size(); ++i) {
auto storage = in_[i]->Copy();
storage->type = e.storage_type();
storage_data[i] = storage;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can std::move(storage) here to avoid unnecessary increments of ref-counts on the shared_ptr.

The whole loop body can be free of unnecessary code if re-written as:

        storage_data[i] = in_[i]->Copy();
        storage_data[i]->type = e.storage_type();

And another way.

ArrayDataVector storage_data;
storage_data.reserve(in_.size());
for (auto &input : in_) {
  storage_data.emplace_back(input->Copy())->type = e.storage_type();
}

The last two avoid having to check the refcount of storage when its dtor is called at the end of the body.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Apr 11, 2023
Comment thread cpp/src/arrow/array/concatenate.cc Outdated
storage_data[i] = storage;
}
std::shared_ptr<ArrayData> out_storage;
RETURN_NOT_OK(ConcatenateImpl(storage_data, pool_).Concatenate(&out_storage));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this recursion guaranteed to stop? Can't an extension have EXTENSION as its storage type as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, you can have an extension type that has a storage type that is an extension type itself. And I suppose that in theory you could create two extension types that point to each other as their storage type, creating an infinite loop. But this is a pattern (i.e. calling the impl on the storage) we use in other places as well, so you will already run into troubles anyway. I am not sure how important it is we explicitly check for this everywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would also assume that just creating an instance of such recursive extension type will already fail, since instantiating the storage types would also give a infinite recursive loop then.

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Apr 12, 2023
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Apr 12, 2023
@jorisvandenbossche

Copy link
Copy Markdown
Member Author

@felipecrv thanks for the review!

@felipecrv felipecrv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, but I'm not a committer.

@jorisvandenbossche jorisvandenbossche merged commit 5184d7c into apache:main Apr 12, 2023
@jorisvandenbossche jorisvandenbossche deleted the ARROW-16503-concat-extension branch April 12, 2023 18:02
@ursabot

ursabot commented Apr 15, 2023

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 48294b0 and contender = 5184d7c. 5184d7c is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed] test-mac-arm
[Finished ⬇️4.34% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️1.23% ⬆️0.03%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 5184d7c1 ec2-t3-xlarge-us-east-2
[Failed] 5184d7c1 test-mac-arm
[Finished] 5184d7c1 ursa-i9-9960x
[Finished] 5184d7c1 ursa-thinkcentre-m75q
[Finished] 48294b07 ec2-t3-xlarge-us-east-2
[Failed] 48294b07 test-mac-arm
[Finished] 48294b07 ursa-i9-9960x
[Finished] 48294b07 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@ursabot

ursabot commented Apr 15, 2023

Copy link
Copy Markdown

['Python', 'R'] benchmarks have high level of regressions.
ursa-i9-9960x

liujiacheng777 pushed a commit to LoongArch-Python/arrow that referenced this pull request May 11, 2023
…14463)

(still needs a test in C++ and more elaborate tests (eg extension types with nested data))
* Closes: apache#31868

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
ArgusLi pushed a commit to Bit-Quill/arrow that referenced this pull request May 15, 2023
…14463)

(still needs a test in C++ and more elaborate tests (eg extension types with nested data))
* Closes: apache#31868

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
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.

[C++] Can't concatenate extension arrays

4 participants