Skip to content

Commit

Permalink
ARROW-14382: [C++][Compute] Remove duplicated ThreadIndexer definition
Browse files Browse the repository at this point in the history
apache#11350 moved ThreadIndexer from `aggregate_node.cc` to `compute/exec/util.h` to allow usage from the join node and incremented its capacity, but did not remove the original implementation.

Closes apache#11463 from bkietz/remove-duplicated-ThreadIndexer

Authored-by: Benjamin Kietzman <[email protected]>
Signed-off-by: David Li <[email protected]>
  • Loading branch information
bkietz authored and lidavidm committed Oct 19, 2021
1 parent 11a45be commit 54d2bd8
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions cpp/src/arrow/compute/exec/aggregate_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,6 @@ Result<FieldVector> ResolveKernels(

namespace {

class ThreadIndexer {
public:
size_t operator()() {
auto id = std::this_thread::get_id();

std::unique_lock<std::mutex> lock(mutex_);
const auto& id_index = *id_to_index_.emplace(id, id_to_index_.size()).first;

return Check(id_index.second);
}

static size_t Capacity() {
static size_t max_size = arrow::internal::ThreadPool::DefaultCapacity();
return max_size;
}

private:
size_t Check(size_t thread_index) {
DCHECK_LT(thread_index, Capacity()) << "thread index " << thread_index
<< " is out of range [0, " << Capacity() << ")";

return thread_index;
}

std::mutex mutex_;
std::unordered_map<std::thread::id, size_t> id_to_index_;
};

void AggregatesToString(
std::stringstream* ss, const Schema& input_schema,
const std::vector<internal::Aggregate>& aggs,
Expand Down

0 comments on commit 54d2bd8

Please sign in to comment.