-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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-42126: [C++] Move TakeXXX free functions into TakeMetaFunction and make them private #42127
Conversation
|
TakeCAA will be used from TakeCCC soon.
246382a
to
2a682cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is only moving code around? In which case LGTM (but a question below).
cpp/src/arrow/compute/kernels/vector_selection_take_internal.cc
Outdated
Show resolved
Hide resolved
TakeAAA(batch.column(j)->data(), indices.data(), options, ctx)); | ||
columns[j] = MakeArray(col_data); | ||
static Result<std::shared_ptr<ChunkedArray>> TakeCAC( | ||
const std::shared_ptr<ChunkedArray>& values, const Array& indices, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious: is there a particular reason for taking the first arg as shared_ptr-const-ref, and the second only as value-const-ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Driven by the signatures of the Datum
constructors [1]. Originally, they were almost all by simple &
, then I tried making all of them shared_ptr&
but that got overwhelming, so I settled on this mixed combination driven by the need (Array
holds shared_ptr<ArrayData>
which is what Datum
cares about).
[1]
/// \brief Construct from a Scalar
Datum(std::shared_ptr<Scalar> value) // NOLINT implicit conversion
: value(std::move(value)) {}
/// \brief Construct from an ArrayData
Datum(std::shared_ptr<ArrayData> value) // NOLINT implicit conversion
: value(std::move(value)) {}
/// \brief Construct from an ArrayData
Datum(ArrayData arg) // NOLINT implicit conversion
: value(std::make_shared<ArrayData>(std::move(arg))) {}
/// \brief Construct from an Array
Datum(const Array& value); // NOLINT implicit conversion
/// \brief Construct from an Array
Datum(const std::shared_ptr<Array>& value); // NOLINT implicit conversion
/// \brief Construct from a ChunkedArray
Datum(std::shared_ptr<ChunkedArray> value); // NOLINT implicit conversion
/// \brief Construct from a RecordBatch
Datum(std::shared_ptr<RecordBatch> value); // NOLINT implicit conversion
/// \brief Construct from a Table
Datum(std::shared_ptr<Table> value); // NOLINT implicit conversion
/// \brief Construct from a ChunkedArray.
///
/// This can be expensive, prefer the shared_ptr<ChunkedArray> constructor
explicit Datum(const ChunkedArray& value);
/// \brief Construct from a RecordBatch.
///
/// This can be expensive, prefer the shared_ptr<RecordBatch> constructor
explicit Datum(const RecordBatch& value);
/// \brief Construct from a Table.
///
/// This can be expensive, prefer the shared_ptr<Table> constructor
explicit Datum(const Table& value);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to simplify these signatures further in the next PR as less will actually have to be handled by the "take"
MetaFunction as "array_take"
learns to handle chunked arrays by itself.
I'm away next week, feel free to merge without waiting for me or @bkietz . |
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 7d84c1e. There were 3 benchmark results indicating a performance regression:
The full Conbench report has more details. It also includes information about 18 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
Move TakeXXX free functions into
TakeMetaFunction
and make them privateWhat changes are included in this PR?
Code move and some small refactorings in preparation for #41700.
Are these changes tested?
By existing tests.