vibhatha commented on code in PR #13700:
URL: https://github.com/apache/arrow/pull/13700#discussion_r959149860
##########
cpp/src/arrow/compute/exec/order_by_impl.cc:
##########
@@ -86,6 +86,45 @@ class SelectKBasicImpl : public SortBasicImpl {
const SelectKOptions options_;
};
+class FetchBasicImpl : public SortBasicImpl {
+ public:
+ FetchBasicImpl(ExecContext* ctx, const std::shared_ptr<Schema>&
output_schema,
+ int64_t offset, int64_t count, SortOptions sort_options)
+ : SortBasicImpl(ctx, output_schema),
+ offset_(offset),
+ count_(count),
+ sort_options_(sort_options) {}
+
+ Result<Datum> DoFinish() override {
+ std::unique_lock<std::mutex> lock(mutex_);
+ ARROW_ASSIGN_OR_RAISE(auto table,
+ Table::FromRecordBatches(output_schema_,
std::move(batches_)));
+ if (sort_options_.sort_keys.size() > 0) {
+ ARROW_ASSIGN_OR_RAISE(auto indices,
+ SortIndices(table, std::move(sort_options_),
ctx_));
+ ARROW_ASSIGN_OR_RAISE(auto sorted_table,
+ Take(table, indices, TakeOptions::NoBoundsCheck(),
ctx_));
+ return sorted_table.table()->Slice(offset_, count_);
Review Comment:
Thanks for noting this. Changes included.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]