Skip to content

Commit

Permalink
ARROW-17814: [C++] Fix style (#14218)
Browse files Browse the repository at this point in the history
This is a follow-up of #14204.

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
  • Loading branch information
kou committed Sep 23, 2022
1 parent dfdd0ce commit 356e7f8
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 92 deletions.
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/exec/asof_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,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(
std::make_unique<KeyHasher>(indices_of_by_key[i]));
key_hashers.push_back(std::make_unique<KeyHasher>(indices_of_by_key[i]));
}
bool must_hash =
n_by > 1 ||
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/exec/asof_join_node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ void CheckRunOutput(const BatchesWithSchema& l_batches,
const BatchesWithSchema& r1_batches,
const BatchesWithSchema& exp_batches,
const AsofJoinNodeOptions join_options) {
auto exec_ctx =
std::make_unique<ExecContext>(default_memory_pool(), nullptr);
auto exec_ctx = 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
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/exec/hash_join_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class JoinBenchmark {
stats_.num_probe_rows = settings.num_probe_batches * settings.batch_size;

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

schema_mgr_ = std::make_unique<HashJoinSchema>();
Expression filter = literal(true);
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ struct BloomFilterPushdownContext {
arrow::internal::BitmapAnd(bv.data(), 0, selected.data(), 0, key_batch.length, 0,
selected.data());
}
auto selected_buffer =
std::make_unique<Buffer>(selected.data(), bit_vector_bytes);
auto selected_buffer = 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 @@ -715,8 +714,7 @@ class HashJoinNode : public ExecNode {
// Number of input exec nodes must be 2
RETURN_NOT_OK(ValidateExecNodeInputs(plan, inputs, 2, "HashJoinNode"));

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

const auto& join_options = checked_cast<const HashJoinNodeOptions&>(options);
RETURN_NOT_OK(ValidateHashJoinNodeOptions(join_options));
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/compute/exec/hash_join_node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,7 @@ TEST(HashJoin, DictNegative) {
ExecBatch::Make({i == 2 ? datumSecondB : datumSecondA,
i == 3 ? datumSecondB : datumSecondA}));

auto exec_ctx =
std::make_unique<ExecContext>(default_memory_pool(), nullptr);
auto exec_ctx = std::make_unique<ExecContext>(default_memory_pool(), nullptr);
ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));
ASSERT_OK_AND_ASSIGN(
ExecNode * l_source,
Expand Down Expand Up @@ -1911,8 +1910,7 @@ TEST(HashJoin, ExtensionTypesHashJoin) {
}

TEST(HashJoin, CheckHashJoinNodeOptionsValidation) {
auto exec_ctx =
std::make_unique<ExecContext>(default_memory_pool(), nullptr);
auto exec_ctx = std::make_unique<ExecContext>(default_memory_pool(), nullptr);
ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_ctx.get()));

BatchesWithSchema input_left;
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/kernels/aggregate_basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ struct CountImpl : public ScalarAggregator {

Result<std::unique_ptr<KernelState>> CountInit(KernelContext*,
const KernelInitArgs& args) {
return std::make_unique<CountImpl>(
static_cast<const CountOptions&>(*args.options));
return std::make_unique<CountImpl>(static_cast<const CountOptions&>(*args.options));
}

// ----------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/kernels/codegen_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ struct KernelStateFromFunctionOptions : public KernelState {
static Result<std::unique_ptr<KernelState>> Init(KernelContext* ctx,
const KernelInitArgs& args) {
if (auto options = static_cast<const OptionsType*>(args.options)) {
return std::make_unique<KernelStateFromFunctionOptions>(ctx,
*options);
return std::make_unique<KernelStateFromFunctionOptions>(ctx, *options);
}

return Status::Invalid(
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1308,8 +1308,7 @@ struct RegexSubstringMatcher {

static Result<std::unique_ptr<RegexSubstringMatcher>> Make(
const MatchSubstringOptions& options, bool is_utf8 = true, bool literal = false) {
auto matcher =
std::make_unique<RegexSubstringMatcher>(options, is_utf8, literal);
auto matcher = std::make_unique<RegexSubstringMatcher>(options, is_utf8, literal);
RETURN_NOT_OK(RegexStatus(matcher->regex_match_));
return std::move(matcher);
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/kernels/vector_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ template <typename Type, typename Action>
Result<std::unique_ptr<HashKernel>> HashInitImpl(KernelContext* ctx,
const KernelInitArgs& args) {
using HashKernelType = typename HashKernelTraits<Type, Action>::HashKernel;
auto result = std::make_unique<HashKernelType>(
args.inputs[0].GetSharedPtr(), args.options, ctx->memory_pool());
auto result = std::make_unique<HashKernelType>(args.inputs[0].GetSharedPtr(),
args.options, ctx->memory_pool());
RETURN_NOT_OK(result->Reset());
return std::move(result);
}
Expand Down Expand Up @@ -614,8 +614,8 @@ Result<std::unique_ptr<KernelState>> DictionaryHashInit(KernelContext* ctx,
break;
}
RETURN_NOT_OK(indices_hasher);
return std::make_unique<DictionaryHashKernel>(
std::move(indices_hasher.ValueOrDie()), dict_type.value_type());
return std::make_unique<DictionaryHashKernel>(std::move(indices_hasher.ValueOrDie()),
dict_type.value_type());
}

Status HashExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
Expand Down
16 changes: 6 additions & 10 deletions cpp/src/arrow/compute/row/grouper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,30 @@ struct GrouperImpl : Grouper {
std::shared_ptr<DataType> key = key_types[i].GetSharedPtr();

if (key->id() == Type::BOOL) {
impl->encoders_[i] =
std::make_unique<internal::BooleanKeyEncoder>();
impl->encoders_[i] = std::make_unique<internal::BooleanKeyEncoder>();
continue;
}

if (key->id() == Type::DICTIONARY) {
impl->encoders_[i] =
std::make_unique<internal::DictionaryKeyEncoder>(
key, ctx->memory_pool());
std::make_unique<internal::DictionaryKeyEncoder>(key, ctx->memory_pool());
continue;
}

if (is_fixed_width(key->id())) {
impl->encoders_[i] =
std::make_unique<internal::FixedWidthKeyEncoder>(key);
impl->encoders_[i] = std::make_unique<internal::FixedWidthKeyEncoder>(key);
continue;
}

if (is_binary_like(key->id())) {
impl->encoders_[i] =
std::make_unique<internal::VarLengthKeyEncoder<BinaryType>>(
key);
std::make_unique<internal::VarLengthKeyEncoder<BinaryType>>(key);
continue;
}

if (is_large_binary_like(key->id())) {
impl->encoders_[i] = std::make_unique<
internal::VarLengthKeyEncoder<LargeBinaryType>>(key);
impl->encoders_[i] =
std::make_unique<internal::VarLengthKeyEncoder<LargeBinaryType>>(key);
continue;
}

Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/dataset/dataset_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ class DatasetWriterDirectoryQueue {
}

Result<DatasetWriterFileQueue*> OpenFileQueue(const std::string& filename) {
auto file_queue = std::make_unique<DatasetWriterFileQueue>(
schema_, write_options_, writer_state_);
auto file_queue =
std::make_unique<DatasetWriterFileQueue>(schema_, write_options_, writer_state_);
DatasetWriterFileQueue* file_queue_view = file_queue.get();
std::unique_ptr<util::AsyncTaskScheduler::Throttle> throttle =
util::AsyncTaskScheduler::MakeThrottle(1);
Expand Down Expand Up @@ -566,8 +566,8 @@ class DatasetWriter::DatasetWriterImpl {
DatasetWriter::DatasetWriter(FileSystemDatasetWriteOptions write_options,
util::AsyncTaskScheduler* scheduler,
uint64_t max_rows_queued)
: impl_(std::make_unique<DatasetWriterImpl>(
std::move(write_options), scheduler, max_rows_queued)) {}
: impl_(std::make_unique<DatasetWriterImpl>(std::move(write_options), scheduler,
max_rows_queued)) {}

Result<std::unique_ptr<DatasetWriter>> DatasetWriter::Make(
FileSystemDatasetWriteOptions write_options, util::AsyncTaskScheduler* scheduler,
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/dataset/file_csv_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class TestCsvFileFormat : public FileFormatFixtureMixin<CsvFormatHelper>,

std::unique_ptr<FileSource> GetFileSource(std::string csv) {
if (GetCompression() == Compression::UNCOMPRESSED) {
return std::make_unique<FileSource>(
Buffer::FromString(std::move(csv)));
return std::make_unique<FileSource>(Buffer::FromString(std::move(csv)));
}
std::string path = "test.csv";
switch (GetCompression()) {
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/dataset/partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,7 @@ class KeyValuePartitioningFactory : public PartitioningFactory {
}

std::unique_ptr<DictionaryMemoTable> MakeMemo() {
return std::make_unique<DictionaryMemoTable>(default_memory_pool(),
utf8());
return std::make_unique<DictionaryMemoTable>(default_memory_pool(), utf8());
}

Status InspectPartitionSegments(std::vector<std::string> segments,
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/dataset/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class GeneratedRecordBatch : public RecordBatchReader {
template <typename Gen>
std::unique_ptr<GeneratedRecordBatch<Gen>> MakeGeneratedRecordBatch(
std::shared_ptr<Schema> schema, Gen&& gen) {
return std::make_unique<GeneratedRecordBatch<Gen>>(
schema, std::forward<Gen>(gen));
return std::make_unique<GeneratedRecordBatch<Gen>>(schema, std::forward<Gen>(gen));
}

std::unique_ptr<RecordBatchReader> MakeGeneratedRecordBatch(
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/engine/substrait/expression_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include "arrow/engine/substrait/expression_internal.h"

#include <utility>
#include <memory>
#include <utility>

#include "arrow/builder.h"
#include "arrow/compute/exec/expression.h"
Expand Down
4 changes: 1 addition & 3 deletions cpp/src/arrow/engine/substrait/extension_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ class IdStorageImpl : public IdStorage {
std::list<std::string> owned_names_;
};

std::unique_ptr<IdStorage> IdStorage::Make() {
return std::make_unique<IdStorageImpl>();
}
std::unique_ptr<IdStorage> IdStorage::Make() { return std::make_unique<IdStorageImpl>(); }

Result<std::optional<std::string_view>> SubstraitCall::GetEnumArg(uint32_t index) const {
if (index >= size_) {
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/flight/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,8 @@ arrow::Result<std::unique_ptr<FlightStreamReader>> FlightClient::DoGet(
std::unique_ptr<internal::ClientDataStream> remote_stream;
RETURN_NOT_OK(transport_->DoGet(options, ticket, &remote_stream));
std::unique_ptr<FlightStreamReader> stream_reader =
std::make_unique<ClientStreamReader>(
std::move(remote_stream), options.read_options, options.stop_token,
options.memory_manager);
std::make_unique<ClientStreamReader>(std::move(remote_stream), options.read_options,
options.stop_token, options.memory_manager);
// Eagerly read the schema
RETURN_NOT_OK(
static_cast<ClientStreamReader*>(stream_reader.get())->EnsureDataStarted());
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/flight/flight_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ class PropagatingClientMiddlewareFactory : public ClientMiddlewareFactory {
public:
void StartCall(const CallInfo& info, std::unique_ptr<ClientMiddleware>* middleware) {
recorded_calls_.push_back(info.method);
*middleware = std::make_unique<PropagatingClientMiddleware>(
&received_headers_, &recorded_status_);
*middleware = std::make_unique<PropagatingClientMiddleware>(&received_headers_,
&recorded_status_);
}

void Reset() {
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/flight/transport/ucx/ucx_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,7 @@ class UcxClientImpl : public arrow::flight::internal::ClientTransport {

auto status = driver->StartCall(kMethodDoExchange);
if (ARROW_PREDICT_TRUE(status.ok())) {
*out =
std::make_unique<ExchangeClientStream>(this, std::move(connection));
*out = std::make_unique<ExchangeClientStream>(this, std::move(connection));
return Status::OK();
}
return MergeStatuses(std::move(status), ReturnConnection(std::move(connection)));
Expand All @@ -620,8 +619,7 @@ class UcxClientImpl : public arrow::flight::internal::ClientTransport {
RETURN_NOT_OK(driver->SendFrame(FrameType::kBuffer,
reinterpret_cast<const uint8_t*>(payload.data()),
static_cast<int64_t>(payload.size())));
*stream =
std::make_unique<GetClientStream>(this, std::move(connection));
*stream = std::make_unique<GetClientStream>(this, std::move(connection));
return Status::OK();
};

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/flight/transport/ucx/ucx_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ class UcpCallDriver::Impl {
// never use Then/AddCallback on a Future<> from ReadFrameAsync,
// because we might run the callback synchronously (which might
// free the buffer) when we call Push here.
frame->buffer =
std::make_unique<UcxDataBuffer>(worker_, data, data_length);
frame->buffer = std::make_unique<UcxDataBuffer>(worker_, data, data_length);
Push(std::move(frame));
return UCS_INPROGRESS;
}
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/gpu/cuda_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,7 @@ CudaContext::~CudaContext() {}
Result<std::unique_ptr<CudaBuffer>> CudaContext::Allocate(int64_t nbytes) {
uint8_t* data = nullptr;
RETURN_NOT_OK(impl_->Allocate(nbytes, &data));
return std::make_unique<CudaBuffer>(data, nbytes, this->shared_from_this(),
true);
return std::make_unique<CudaBuffer>(data, nbytes, this->shared_from_this(), true);
}

Result<std::shared_ptr<CudaBuffer>> CudaContext::View(uint8_t* data, int64_t nbytes) {
Expand Down
23 changes: 10 additions & 13 deletions cpp/src/arrow/ipc/writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1328,17 +1328,16 @@ Result<std::shared_ptr<RecordBatchWriter>> MakeStreamWriter(
io::OutputStream* sink, const std::shared_ptr<Schema>& schema,
const IpcWriteOptions& options) {
return std::make_shared<internal::IpcFormatWriter>(
std::make_unique<internal::PayloadStreamWriter>(sink, options),
schema, options, /*is_file_format=*/false);
std::make_unique<internal::PayloadStreamWriter>(sink, options), schema, options,
/*is_file_format=*/false);
}

Result<std::shared_ptr<RecordBatchWriter>> MakeStreamWriter(
std::shared_ptr<io::OutputStream> sink, const std::shared_ptr<Schema>& schema,
const IpcWriteOptions& options) {
return std::make_shared<internal::IpcFormatWriter>(
std::make_unique<internal::PayloadStreamWriter>(std::move(sink),
options),
schema, options, /*is_file_format=*/false);
std::make_unique<internal::PayloadStreamWriter>(std::move(sink), options), schema,
options, /*is_file_format=*/false);
}

Result<std::shared_ptr<RecordBatchWriter>> NewStreamWriter(
Expand All @@ -1352,8 +1351,7 @@ Result<std::shared_ptr<RecordBatchWriter>> MakeFileWriter(
const IpcWriteOptions& options,
const std::shared_ptr<const KeyValueMetadata>& metadata) {
return std::make_shared<internal::IpcFormatWriter>(
std::make_unique<internal::PayloadFileWriter>(options, schema,
metadata, sink),
std::make_unique<internal::PayloadFileWriter>(options, schema, metadata, sink),
schema, options, /*is_file_format=*/true);
}

Expand All @@ -1362,8 +1360,8 @@ Result<std::shared_ptr<RecordBatchWriter>> MakeFileWriter(
const IpcWriteOptions& options,
const std::shared_ptr<const KeyValueMetadata>& metadata) {
return std::make_shared<internal::IpcFormatWriter>(
std::make_unique<internal::PayloadFileWriter>(
options, schema, metadata, std::move(sink)),
std::make_unique<internal::PayloadFileWriter>(options, schema, metadata,
std::move(sink)),
schema, options, /*is_file_format=*/true);
}

Expand Down Expand Up @@ -1394,8 +1392,7 @@ Result<std::unique_ptr<IpcPayloadWriter>> MakePayloadFileWriter(
io::OutputStream* sink, const std::shared_ptr<Schema>& schema,
const IpcWriteOptions& options,
const std::shared_ptr<const KeyValueMetadata>& metadata) {
return std::make_unique<internal::PayloadFileWriter>(options, schema,
metadata, sink);
return std::make_unique<internal::PayloadFileWriter>(options, schema, metadata, sink);
}

} // namespace internal
Expand Down Expand Up @@ -1446,8 +1443,8 @@ Result<std::shared_ptr<Buffer>> SerializeSchema(const Schema& schema, MemoryPool
auto options = IpcWriteOptions::Defaults();
const bool is_file_format = false; // indifferent as we don't write dictionaries
internal::IpcFormatWriter writer(
std::make_unique<internal::PayloadStreamWriter>(stream.get()), schema,
options, is_file_format);
std::make_unique<internal::PayloadStreamWriter>(stream.get()), schema, options,
is_file_format);
RETURN_NOT_OK(writer.Start());
return stream->Finish();
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/arrow/json/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ class Handler<UnexpectedFieldBehavior::InferType> : public HandlerBase {
/// will probably trigger promotion of this field from null
bool Key(const char* key, rj::SizeType len, ...) {
bool duplicate_keys = false;
if (ARROW_PREDICT_TRUE(SetFieldBuilder(std::string_view(key, len), &duplicate_keys))) {
if (ARROW_PREDICT_TRUE(
SetFieldBuilder(std::string_view(key, len), &duplicate_keys))) {
return true;
}
if (ARROW_PREDICT_FALSE(duplicate_keys)) {
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,7 @@ SchemaBuilder::SchemaBuilder(ConflictPolicy policy,
SchemaBuilder::SchemaBuilder(std::vector<std::shared_ptr<Field>> fields,
ConflictPolicy policy,
Field::MergeOptions field_merge_options) {
impl_ = std::make_unique<Impl>(std::move(fields), nullptr, policy,
field_merge_options);
impl_ = std::make_unique<Impl>(std::move(fields), nullptr, policy, field_merge_options);
}

SchemaBuilder::SchemaBuilder(const std::shared_ptr<Schema>& schema, ConflictPolicy policy,
Expand All @@ -1735,7 +1734,7 @@ SchemaBuilder::SchemaBuilder(const std::shared_ptr<Schema>& schema, ConflictPoli
}

impl_ = std::make_unique<Impl>(schema->fields(), std::move(metadata), policy,
field_merge_options);
field_merge_options);
}

SchemaBuilder::~SchemaBuilder() {}
Expand Down
Loading

0 comments on commit 356e7f8

Please sign in to comment.