Skip to content

Commit

Permalink
ARROW-17814: [C++] Remove make_unique reimplementation
Browse files Browse the repository at this point in the history
Use std::make_unique instead.
  • Loading branch information
wgtmac committed Sep 22, 2022
1 parent 43e66a9 commit 09b6b78
Show file tree
Hide file tree
Showing 77 changed files with 250 additions and 315 deletions.
10 changes: 5 additions & 5 deletions c_glib/arrow-flight-glib/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

#include <arrow/util/make_unique.h>
#include <memory>

#include <arrow-glib/arrow-glib.hpp>

Expand Down Expand Up @@ -239,7 +239,7 @@ gaflight_record_batch_stream_new(GArrowRecordBatchReader *reader,
} else {
arrow_options = &arrow_options_default;
}
auto stream = arrow::internal::make_unique<
auto stream = std::make_unique<
arrow::flight::RecordBatchStream>(arrow_reader, *arrow_options);
return static_cast<GAFlightRecordBatchStream *>(
g_object_new(GAFLIGHT_TYPE_RECORD_BATCH_STREAM,
Expand Down Expand Up @@ -484,7 +484,7 @@ namespace gaflight {
g_object_unref(gaflight);
}
g_list_free(gaflights);
*listing = arrow::internal::make_unique<
*listing = std::make_unique<
arrow::flight::SimpleFlightListing>(flights);
return arrow::Status::OK();
}
Expand All @@ -507,7 +507,7 @@ namespace gaflight {
arrow::StatusCode::UnknownError,
"[flight-server][get-flight-info]");
}
*info = arrow::internal::make_unique<arrow::flight::FlightInfo>(
*info = std::make_unique<arrow::flight::FlightInfo>(
*gaflight_info_get_raw(gainfo));
g_object_unref(gainfo);
return arrow::Status::OK();
Expand All @@ -531,7 +531,7 @@ namespace gaflight {
arrow::StatusCode::UnknownError,
"[flight-server][do-get]");
}
*stream = arrow::internal::make_unique<DataStream>(gastream);
*stream = std::make_unique<DataStream>(gastream);
return arrow::Status::OK();
}

Expand Down
6 changes: 3 additions & 3 deletions c_glib/arrow-flight-sql-glib/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

#include <arrow/util/make_unique.h>
#include <memory>

#include <arrow-glib/arrow-glib.hpp>
#include <arrow-flight-glib/common.hpp>
Expand Down Expand Up @@ -225,7 +225,7 @@ namespace gaflightsql {
arrow::StatusCode::UnknownError,
context);
}
return arrow::internal::make_unique<arrow::flight::FlightInfo>(
return std::make_unique<arrow::flight::FlightInfo>(
*gaflight_info_get_raw(gainfo));
}

Expand All @@ -247,7 +247,7 @@ namespace gaflightsql {
arrow::StatusCode::UnknownError,
"[flight-sql-server][do-get-statement]");
}
return arrow::internal::make_unique<gaflight::DataStream>(gastream);
return std::make_unique<gaflight::DataStream>(gastream);
}

private:
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "arrow/status.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/make_unique.h"

namespace arrow {

Expand Down Expand Up @@ -162,7 +161,7 @@ Result<std::unique_ptr<Buffer>> MyMemoryManager::CopyNonOwnedFrom(
ARROW_ASSIGN_OR_RAISE(auto dest,
MemoryManager::CopyNonOwned(buf, default_cpu_memory_manager()));
// 2. Wrap CPU buffer result
return internal::make_unique<MyBuffer>(shared_from_this(), std::move(dest));
return std::make_unique<MyBuffer>(shared_from_this(), std::move(dest));
}
return nullptr;
}
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/arrow/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "arrow/builder.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>
Expand All @@ -25,7 +26,6 @@
#include "arrow/type.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/hashing.h"
#include "arrow/util/make_unique.h"
#include "arrow/visit_type_inline.h"

namespace arrow {
Expand Down Expand Up @@ -54,28 +54,28 @@ class ARROW_EXPORT TypeErasedIntBuilder : public ArrayBuilder {
DCHECK(is_integer(type_id_));
switch (type_id_) {
case Type::UINT8:
builder_ = internal::make_unique<UInt8Builder>(pool);
builder_ = std::make_unique<UInt8Builder>(pool);
break;
case Type::INT8:
builder_ = internal::make_unique<Int8Builder>(pool);
builder_ = std::make_unique<Int8Builder>(pool);
break;
case Type::UINT16:
builder_ = internal::make_unique<UInt16Builder>(pool);
builder_ = std::make_unique<UInt16Builder>(pool);
break;
case Type::INT16:
builder_ = internal::make_unique<Int16Builder>(pool);
builder_ = std::make_unique<Int16Builder>(pool);
break;
case Type::UINT32:
builder_ = internal::make_unique<UInt32Builder>(pool);
builder_ = std::make_unique<UInt32Builder>(pool);
break;
case Type::INT32:
builder_ = internal::make_unique<Int32Builder>(pool);
builder_ = std::make_unique<Int32Builder>(pool);
break;
case Type::UINT64:
builder_ = internal::make_unique<UInt64Builder>(pool);
builder_ = std::make_unique<UInt64Builder>(pool);
break;
case Type::INT64:
builder_ = internal::make_unique<Int64Builder>(pool);
builder_ = std::make_unique<Int64Builder>(pool);
break;
default:
DCHECK(false);
Expand Down
7 changes: 3 additions & 4 deletions cpp/src/arrow/compute/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/cpu_info.h"
#include "arrow/util/logging.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/vector.h"

namespace arrow {
Expand Down Expand Up @@ -1187,15 +1186,15 @@ void PropagateNullsSpans(const ExecSpan& batch, ArraySpan* out) {
}

std::unique_ptr<KernelExecutor> KernelExecutor::MakeScalar() {
return ::arrow::internal::make_unique<detail::ScalarExecutor>();
return std::make_unique<detail::ScalarExecutor>();
}

std::unique_ptr<KernelExecutor> KernelExecutor::MakeVector() {
return ::arrow::internal::make_unique<detail::VectorExecutor>();
return std::make_unique<detail::VectorExecutor>();
}

std::unique_ptr<KernelExecutor> KernelExecutor::MakeScalarAggregate() {
return ::arrow::internal::make_unique<detail::ScalarAggExecutor>();
return std::make_unique<detail::ScalarAggExecutor>();
}

int64_t InferBatchLength(const std::vector<Datum>& values, bool* all_same) {
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/compute/exec/asof_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#include <condition_variable>
#include <memory>
#include <mutex>
#include <optional>
#include <string_view>
Expand All @@ -37,7 +38,6 @@
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/future.h"
#include "arrow/util/make_unique.h"

namespace arrow {
namespace compute {
Expand Down Expand Up @@ -850,7 +850,7 @@ class AsofJoinNode : public ExecNode {
auto inputs = this->inputs();
for (size_t i = 0; i < inputs.size(); i++) {
RETURN_NOT_OK(key_hashers_[i]->Init(plan()->exec_context(), output_schema()));
state_.push_back(::arrow::internal::make_unique<InputState>(
state_.push_back(std::make_unique<InputState>(
must_hash_, may_rehash_, key_hashers_[i].get(), inputs[i]->output_schema(),
indices_of_on_key_[i], indices_of_by_key_[i]));
}
Expand Down Expand Up @@ -1060,7 +1060,7 @@ class AsofJoinNode : public ExecNode {
std::vector<std::unique_ptr<KeyHasher>> key_hashers;
for (size_t i = 0; i < n_input; i++) {
key_hashers.push_back(
::arrow::internal::make_unique<KeyHasher>(indices_of_by_key[i]));
std::make_unique<KeyHasher>(indices_of_by_key[i]));
}
bool must_hash =
n_by > 1 ||
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/exec/asof_join_node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <gmock/gmock-matchers.h>

#include <chrono>
#include <memory>
#include <numeric>
#include <random>
#include <string_view>
Expand All @@ -34,7 +35,6 @@
#include "arrow/testing/matchers.h"
#include "arrow/testing/random.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/thread_pool.h"

#define TRACED_TEST(t_class, t_name, t_body) \
Expand Down Expand Up @@ -210,7 +210,7 @@ void CheckRunOutput(const BatchesWithSchema& l_batches,
const BatchesWithSchema& exp_batches,
const AsofJoinNodeOptions join_options) {
auto exec_ctx =
arrow::internal::make_unique<ExecContext>(default_memory_pool(), nullptr);
std::make_unique<ExecContext>(default_memory_pool(), nullptr);
ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));

Declaration join{"asofjoin", join_options};
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/exec/expression_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "arrow/compute/function_internal.h"
#include "arrow/compute/registry.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/util/make_unique.h"

using testing::HasSubstr;
using testing::UnorderedElementsAreArray;
Expand Down Expand Up @@ -242,7 +241,7 @@ class WidgetifyOptionsType : public FunctionOptionsType {
}
std::unique_ptr<FunctionOptions> Copy(const FunctionOptions& options) const override {
const auto& opts = static_cast<const WidgetifyOptions&>(options);
return arrow::internal::make_unique<WidgetifyOptions>(opts.really);
return std::make_unique<WidgetifyOptions>(opts.really);
}
};
WidgetifyOptions::WidgetifyOptions(bool really)
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/compute/exec/hash_join_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "arrow/compute/exec/util.h"
#include "arrow/compute/kernels/row_encoder.h"
#include "arrow/testing/random.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/thread_pool.h"

#include <cstdint>
Expand Down Expand Up @@ -126,10 +125,10 @@ class JoinBenchmark {

stats_.num_probe_rows = settings.num_probe_batches * settings.batch_size;

ctx_ = arrow::internal::make_unique<ExecContext>(default_memory_pool(),
ctx_ = std::make_unique<ExecContext>(default_memory_pool(),
arrow::internal::GetCpuThreadPool());

schema_mgr_ = arrow::internal::make_unique<HashJoinSchema>();
schema_mgr_ = std::make_unique<HashJoinSchema>();
Expression filter = literal(true);
DCHECK_OK(schema_mgr_->Init(settings.join_type, *l_batches_with_schema.schema,
left_keys, *r_batches_with_schema.schema, right_keys,
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include <memory>
#include <mutex>
#include <unordered_set>
#include <utility>
Expand All @@ -29,7 +30,6 @@
#include "arrow/compute/exec/util.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/future.h"
#include "arrow/util/make_unique.h"
#include "arrow/util/thread_pool.h"
#include "arrow/util/tracing_internal.h"

Expand Down Expand Up @@ -580,7 +580,7 @@ struct BloomFilterPushdownContext {
selected.data());
}
auto selected_buffer =
arrow::internal::make_unique<Buffer>(selected.data(), bit_vector_bytes);
std::make_unique<Buffer>(selected.data(), bit_vector_bytes);
ArrayData selected_arraydata(boolean(), batch.length,
{nullptr, std::move(selected_buffer)});
Datum selected_datum(selected_arraydata);
Expand Down Expand Up @@ -716,7 +716,7 @@ class HashJoinNode : public ExecNode {
RETURN_NOT_OK(ValidateExecNodeInputs(plan, inputs, 2, "HashJoinNode"));

std::unique_ptr<HashJoinSchema> schema_mgr =
::arrow::internal::make_unique<HashJoinSchema>();
std::make_unique<HashJoinSchema>();

const auto& join_options = checked_cast<const HashJoinNodeOptions&>(options);
RETURN_NOT_OK(ValidateHashJoinNodeOptions(join_options));
Expand Down Expand Up @@ -1093,7 +1093,7 @@ void BloomFilterPushdownContext::Init(
eval_.all_received_callback_ = std::move(on_bloom_filters_received);
if (!disable_bloom_filter_) {
ARROW_CHECK(push_.pushdown_target_);
push_.bloom_filter_ = arrow::internal::make_unique<BlockedBloomFilter>();
push_.bloom_filter_ = std::make_unique<BlockedBloomFilter>();
push_.pushdown_target_->pushdown_context_.ExpectBloomFilter();

build_.builder_ = BloomFilterBuilder::Make(
Expand Down
Loading

0 comments on commit 09b6b78

Please sign in to comment.