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

[C++] ChunkedArrayResolver::Resolve is prematurely template-specialized #40280

Closed
felipecrv opened this issue Feb 28, 2024 · 1 comment
Closed

Comments

@felipecrv
Copy link
Contributor

Describe the enhancement requested

ChunkedArrayResolver::Resolve<T> can be made more generic by always producing a ResolvedChunk<arrow::Array> instead of

  • ResolvedChunk<arrow::Int64Array>
  • ResolvedChunk<arrow::BoolArray>
  • ResolvedChunk<arrow::StringArray
  • and so on...

It's only ResolvedChunk::Value that needs to specialize on the sub-type of arrow::Array.

Other possible improvements that might end up with their own dedicated issues:

  • Make ChunkedArrayResolver constructable from std::vectors of other chunk array types (eg std::shared_ptr<Arrow>, std::shared_ptr<ArrayData> instead of just const Array
  • Make that construction step zero-copy

Component(s)

C++

@felipecrv felipecrv self-assigned this Feb 28, 2024
felipecrv added a commit that referenced this issue Feb 29, 2024
…es instead of entire class (#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: #40280

Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>
@felipecrv felipecrv added this to the 16.0.0 milestone Feb 29, 2024
@felipecrv
Copy link
Contributor Author

Issue resolved by pull request 40281
#40281

thisisnic pushed a commit to thisisnic/arrow that referenced this issue 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
Projects
None yet
Development

No branches or pull requests

1 participant