westonpace commented on code in PR #14227: URL: https://github.com/apache/arrow/pull/14227#discussion_r1045250550
########## cpp/src/arrow/compute/exec/query_context.cc: ########## @@ -0,0 +1,96 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "arrow/compute/exec/query_context.h" +#include "arrow/util/cpu_info.h" +#include "arrow/util/io_util.h" + +namespace arrow { +using internal::CpuInfo; +namespace compute { +QueryOptions::QueryOptions() + : max_memory_bytes( + static_cast<size_t>(0.75f * ::arrow::internal::GetTotalMemoryBytes())), + use_legacy_batching(false) {} + +QueryContext::QueryContext(QueryOptions opts, ExecContext exec_context) + : options_(opts), + exec_context_(exec_context), + io_context_(exec_context_.memory_pool()) {} + +const CpuInfo* QueryContext::cpu_info() const { return CpuInfo::GetInstance(); } + +Status QueryContext::Init(size_t max_num_threads) { + tld_.resize(max_num_threads); + return Status::OK(); +} + +size_t QueryContext::GetThreadIndex() { return thread_indexer_(); } + +size_t QueryContext::max_concurrency() const { return thread_indexer_.Capacity(); } Review Comment: It shouldn't have to be but `Capacity` is based on the default I/O and default CPU pools. That being said, it is only used for a safety check and having a too-large capacity is not a problem. However, if the user provided a CPU executor with many more threads than the default CPU executor it would lead to problems. -- 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]
