Skip to content

Commit 4cb7b50

Browse files
authored
ARROW-17814: [C++] Remove make_unique reimplementation (#14204)
Use std::make_unique instead. Authored-by: Gang Wu <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent 0310add commit 4cb7b50

77 files changed

Lines changed: 283 additions & 365 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎c_glib/arrow-flight-glib/server.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
#include <arrow/util/make_unique.h>
20+
#include <memory>
2121

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

@@ -239,7 +239,7 @@ gaflight_record_batch_stream_new(GArrowRecordBatchReader *reader,
239239
} else {
240240
arrow_options = &arrow_options_default;
241241
}
242-
auto stream = arrow::internal::make_unique<
242+
auto stream = std::make_unique<
243243
arrow::flight::RecordBatchStream>(arrow_reader, *arrow_options);
244244
return static_cast<GAFlightRecordBatchStream *>(
245245
g_object_new(GAFLIGHT_TYPE_RECORD_BATCH_STREAM,
@@ -484,7 +484,7 @@ namespace gaflight {
484484
g_object_unref(gaflight);
485485
}
486486
g_list_free(gaflights);
487-
*listing = arrow::internal::make_unique<
487+
*listing = std::make_unique<
488488
arrow::flight::SimpleFlightListing>(flights);
489489
return arrow::Status::OK();
490490
}
@@ -507,7 +507,7 @@ namespace gaflight {
507507
arrow::StatusCode::UnknownError,
508508
"[flight-server][get-flight-info]");
509509
}
510-
*info = arrow::internal::make_unique<arrow::flight::FlightInfo>(
510+
*info = std::make_unique<arrow::flight::FlightInfo>(
511511
*gaflight_info_get_raw(gainfo));
512512
g_object_unref(gainfo);
513513
return arrow::Status::OK();
@@ -531,7 +531,7 @@ namespace gaflight {
531531
arrow::StatusCode::UnknownError,
532532
"[flight-server][do-get]");
533533
}
534-
*stream = arrow::internal::make_unique<DataStream>(gastream);
534+
*stream = std::make_unique<DataStream>(gastream);
535535
return arrow::Status::OK();
536536
}
537537

‎c_glib/arrow-flight-sql-glib/server.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
#include <arrow/util/make_unique.h>
20+
#include <memory>
2121

2222
#include <arrow-glib/arrow-glib.hpp>
2323
#include <arrow-flight-glib/common.hpp>
@@ -225,7 +225,7 @@ namespace gaflightsql {
225225
arrow::StatusCode::UnknownError,
226226
context);
227227
}
228-
return arrow::internal::make_unique<arrow::flight::FlightInfo>(
228+
return std::make_unique<arrow::flight::FlightInfo>(
229229
*gaflight_info_get_raw(gainfo));
230230
}
231231

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

253253
private:

‎cpp/src/arrow/buffer_test.cc‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "arrow/status.h"
3535
#include "arrow/testing/gtest_util.h"
3636
#include "arrow/util/checked_cast.h"
37-
#include "arrow/util/make_unique.h"
3837

3938
namespace arrow {
4039

@@ -162,7 +161,7 @@ Result<std::unique_ptr<Buffer>> MyMemoryManager::CopyNonOwnedFrom(
162161
ARROW_ASSIGN_OR_RAISE(auto dest,
163162
MemoryManager::CopyNonOwned(buf, default_cpu_memory_manager()));
164163
// 2. Wrap CPU buffer result
165-
return internal::make_unique<MyBuffer>(shared_from_this(), std::move(dest));
164+
return std::make_unique<MyBuffer>(shared_from_this(), std::move(dest));
166165
}
167166
return nullptr;
168167
}

‎cpp/src/arrow/builder.cc‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "arrow/builder.h"
1919

20+
#include <memory>
2021
#include <string>
2122
#include <utility>
2223
#include <vector>
@@ -25,7 +26,6 @@
2526
#include "arrow/type.h"
2627
#include "arrow/util/checked_cast.h"
2728
#include "arrow/util/hashing.h"
28-
#include "arrow/util/make_unique.h"
2929
#include "arrow/visit_type_inline.h"
3030

3131
namespace arrow {
@@ -54,28 +54,28 @@ class ARROW_EXPORT TypeErasedIntBuilder : public ArrayBuilder {
5454
DCHECK(is_integer(type_id_));
5555
switch (type_id_) {
5656
case Type::UINT8:
57-
builder_ = internal::make_unique<UInt8Builder>(pool);
57+
builder_ = std::make_unique<UInt8Builder>(pool);
5858
break;
5959
case Type::INT8:
60-
builder_ = internal::make_unique<Int8Builder>(pool);
60+
builder_ = std::make_unique<Int8Builder>(pool);
6161
break;
6262
case Type::UINT16:
63-
builder_ = internal::make_unique<UInt16Builder>(pool);
63+
builder_ = std::make_unique<UInt16Builder>(pool);
6464
break;
6565
case Type::INT16:
66-
builder_ = internal::make_unique<Int16Builder>(pool);
66+
builder_ = std::make_unique<Int16Builder>(pool);
6767
break;
6868
case Type::UINT32:
69-
builder_ = internal::make_unique<UInt32Builder>(pool);
69+
builder_ = std::make_unique<UInt32Builder>(pool);
7070
break;
7171
case Type::INT32:
72-
builder_ = internal::make_unique<Int32Builder>(pool);
72+
builder_ = std::make_unique<Int32Builder>(pool);
7373
break;
7474
case Type::UINT64:
75-
builder_ = internal::make_unique<UInt64Builder>(pool);
75+
builder_ = std::make_unique<UInt64Builder>(pool);
7676
break;
7777
case Type::INT64:
78-
builder_ = internal::make_unique<Int64Builder>(pool);
78+
builder_ = std::make_unique<Int64Builder>(pool);
7979
break;
8080
default:
8181
DCHECK(false);

‎cpp/src/arrow/compute/exec.cc‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include "arrow/util/checked_cast.h"
4848
#include "arrow/util/cpu_info.h"
4949
#include "arrow/util/logging.h"
50-
#include "arrow/util/make_unique.h"
5150
#include "arrow/util/vector.h"
5251

5352
namespace arrow {
@@ -1187,15 +1186,15 @@ void PropagateNullsSpans(const ExecSpan& batch, ArraySpan* out) {
11871186
}
11881187

11891188
std::unique_ptr<KernelExecutor> KernelExecutor::MakeScalar() {
1190-
return ::arrow::internal::make_unique<detail::ScalarExecutor>();
1189+
return std::make_unique<detail::ScalarExecutor>();
11911190
}
11921191

11931192
std::unique_ptr<KernelExecutor> KernelExecutor::MakeVector() {
1194-
return ::arrow::internal::make_unique<detail::VectorExecutor>();
1193+
return std::make_unique<detail::VectorExecutor>();
11951194
}
11961195

11971196
std::unique_ptr<KernelExecutor> KernelExecutor::MakeScalarAggregate() {
1198-
return ::arrow::internal::make_unique<detail::ScalarAggExecutor>();
1197+
return std::make_unique<detail::ScalarAggExecutor>();
11991198
}
12001199

12011200
int64_t InferBatchLength(const std::vector<Datum>& values, bool* all_same) {

‎cpp/src/arrow/compute/exec/asof_join_node.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
#include <condition_variable>
19+
#include <memory>
1920
#include <mutex>
2021
#include <optional>
2122
#include <string_view>
@@ -37,7 +38,6 @@
3738
#include "arrow/type_traits.h"
3839
#include "arrow/util/checked_cast.h"
3940
#include "arrow/util/future.h"
40-
#include "arrow/util/make_unique.h"
4141

4242
namespace arrow {
4343
namespace compute {
@@ -850,7 +850,7 @@ class AsofJoinNode : public ExecNode {
850850
auto inputs = this->inputs();
851851
for (size_t i = 0; i < inputs.size(); i++) {
852852
RETURN_NOT_OK(key_hashers_[i]->Init(plan()->exec_context(), output_schema()));
853-
state_.push_back(::arrow::internal::make_unique<InputState>(
853+
state_.push_back(std::make_unique<InputState>(
854854
must_hash_, may_rehash_, key_hashers_[i].get(), inputs[i]->output_schema(),
855855
indices_of_on_key_[i], indices_of_by_key_[i]));
856856
}
@@ -1060,7 +1060,7 @@ class AsofJoinNode : public ExecNode {
10601060
std::vector<std::unique_ptr<KeyHasher>> key_hashers;
10611061
for (size_t i = 0; i < n_input; i++) {
10621062
key_hashers.push_back(
1063-
::arrow::internal::make_unique<KeyHasher>(indices_of_by_key[i]));
1063+
std::make_unique<KeyHasher>(indices_of_by_key[i]));
10641064
}
10651065
bool must_hash =
10661066
n_by > 1 ||

‎cpp/src/arrow/compute/exec/asof_join_node_test.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <gmock/gmock-matchers.h>
1919

2020
#include <chrono>
21+
#include <memory>
2122
#include <numeric>
2223
#include <random>
2324
#include <string_view>
@@ -34,7 +35,6 @@
3435
#include "arrow/testing/matchers.h"
3536
#include "arrow/testing/random.h"
3637
#include "arrow/util/checked_cast.h"
37-
#include "arrow/util/make_unique.h"
3838
#include "arrow/util/thread_pool.h"
3939

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

216216
Declaration join{"asofjoin", join_options};

‎cpp/src/arrow/compute/exec/expression_test.cc‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "arrow/compute/function_internal.h"
3131
#include "arrow/compute/registry.h"
3232
#include "arrow/testing/gtest_util.h"
33-
#include "arrow/util/make_unique.h"
3433

3534
using testing::HasSubstr;
3635
using testing::UnorderedElementsAreArray;
@@ -242,7 +241,7 @@ class WidgetifyOptionsType : public FunctionOptionsType {
242241
}
243242
std::unique_ptr<FunctionOptions> Copy(const FunctionOptions& options) const override {
244243
const auto& opts = static_cast<const WidgetifyOptions&>(options);
245-
return arrow::internal::make_unique<WidgetifyOptions>(opts.really);
244+
return std::make_unique<WidgetifyOptions>(opts.really);
246245
}
247246
};
248247
WidgetifyOptions::WidgetifyOptions(bool really)

‎cpp/src/arrow/compute/exec/hash_join_benchmark.cc‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "arrow/compute/exec/util.h"
2626
#include "arrow/compute/kernels/row_encoder.h"
2727
#include "arrow/testing/random.h"
28-
#include "arrow/util/make_unique.h"
2928
#include "arrow/util/thread_pool.h"
3029

3130
#include <cstdint>
@@ -126,10 +125,10 @@ class JoinBenchmark {
126125

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

129-
ctx_ = arrow::internal::make_unique<ExecContext>(default_memory_pool(),
128+
ctx_ = std::make_unique<ExecContext>(default_memory_pool(),
130129
arrow::internal::GetCpuThreadPool());
131130

132-
schema_mgr_ = arrow::internal::make_unique<HashJoinSchema>();
131+
schema_mgr_ = std::make_unique<HashJoinSchema>();
133132
Expression filter = literal(true);
134133
DCHECK_OK(schema_mgr_->Init(settings.join_type, *l_batches_with_schema.schema,
135134
left_keys, *r_batches_with_schema.schema, right_keys,

‎cpp/src/arrow/compute/exec/hash_join_node.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
#include <memory>
1819
#include <mutex>
1920
#include <unordered_set>
2021
#include <utility>
@@ -29,7 +30,6 @@
2930
#include "arrow/compute/exec/util.h"
3031
#include "arrow/util/checked_cast.h"
3132
#include "arrow/util/future.h"
32-
#include "arrow/util/make_unique.h"
3333
#include "arrow/util/thread_pool.h"
3434
#include "arrow/util/tracing_internal.h"
3535

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

718718
std::unique_ptr<HashJoinSchema> schema_mgr =
719-
::arrow::internal::make_unique<HashJoinSchema>();
719+
std::make_unique<HashJoinSchema>();
720720

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

10991099
build_.builder_ = BloomFilterBuilder::Make(

0 commit comments

Comments
 (0)