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-40280: [C++] Specialize ResolvedChunk::Value on value-specific types instead of entire class #40281

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

felipecrv
Copy link
Contributor

@felipecrv felipecrv commented Feb 28, 2024

Rationale for this change

Less template-specialization without any loss in efficiency.

What changes are included in this PR?

  • ChunkedResolver tweak
  • Explicitly declare copy constructors of ChunkedResolver
    • at the moment they are necessary because ChunkedArrayResolver is copied in compute kernel code
  • Make ChunkedArrayResolver re-use ChunkResolver via composition instead of inheritance
    • This will allow the ChunkResolver API to evolve in ways that might not make sense if it's a sub-class of ChunkedArrayResolver
  • Use std::enable_if instead of duplicating the ResolvedChunk implementation and template-specializing
  • Only specialize ResolvedChunk::Value on value-type-specific types preserving the same type-safety checks (static and runtime)

Are these changes tested?

Yes, by existing tests.

Are there any user-facing changes?

No, because these are API are under the internal namespace at the moment even though there are plans to make it public. These changes are preparation for that if we end up making them public.

@felipecrv felipecrv changed the title GH-40280: [C++] GH-40280: [C++] Specialize ResolvedChunk::Value on value-specific typed instead of entire class Feb 28, 2024
@felipecrv felipecrv changed the title GH-40280: [C++] Specialize ResolvedChunk::Value on value-specific typed instead of entire class GH-40280: [C++] Specialize ResolvedChunk::Value on value-specific types instead of entire class Feb 28, 2024
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

// The target array in chunked array.
const Array* array;
// The index in the target array.
const int64_t index;

ResolvedChunk(const Array* array, int64_t index) : array(array), index(index) {}

public:
Copy link
Member

Choose a reason for hiding this comment

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

I may misread, but I think we're already in a public section given that this is a struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean to make it a class and the members private. I should have done it in this PR, but forgotten.

Copy link
Contributor Author

@felipecrv felipecrv Mar 5, 2024

Choose a reason for hiding this comment

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

I'm removing it in another PR now.

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Feb 29, 2024
@felipecrv felipecrv merged commit 214378b into apache:main Feb 29, 2024
38 of 39 checks passed
@felipecrv felipecrv removed the awaiting committer review Awaiting committer review label Feb 29, 2024
@felipecrv felipecrv deleted the chunked_array_resolver branch March 1, 2024 01:17
Copy link

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 214378b.

There was 1 benchmark result indicating a performance regression:

The full Conbench report has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.

@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Mar 5, 2024
thisisnic pushed a commit to thisisnic/arrow that referenced this pull request Mar 8, 2024
…ic types instead of entire class (apache#40281)

### Rationale for this change

Less template-specialization without any loss in efficiency.

### What changes are included in this PR?

 - `ChunkedResolver` tweak
 - Explicitly declare copy constructors of `ChunkedResolver`
     - at the moment they are necessary because `ChunkedArrayResolver` is copied in compute kernel code
 - Make `ChunkedArrayResolver` re-use `ChunkResolver` via composition instead of inheritance
     - This will allow the `ChunkResolver` API to evolve in ways that might not make sense if it's a sub-class of `ChunkedArrayResolver`
 - Use `std::enable_if` instead of duplicating the `ResolvedChunk` implementation and template-specializing
 - Only specialize `ResolvedChunk::Value` on value-type-specific types preserving the same type-safety checks (static and runtime)

### Are these changes tested?

Yes, by existing tests.

### Are there any user-facing changes?

No, because these are API are under the internal namespace at the moment even though there are plans to make it public. These changes are preparation for that if we end up making them public.
* GitHub Issue: apache#40280

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants