diff --git a/cpp/src/arrow/acero/asof_join_benchmark.cc b/cpp/src/arrow/acero/asof_join_benchmark.cc index ed2ac2258eb6..f2cd10468e64 100644 --- a/cpp/src/arrow/acero/asof_join_benchmark.cc +++ b/cpp/src/arrow/acero/asof_join_benchmark.cc @@ -54,7 +54,7 @@ static void TableJoinOverhead(benchmark::State& state, TableGenerationProperties right_table_properties, int batch_size, int num_right_tables, std::string factory_name, - std::shared_ptr options) { + const std::shared_ptr& options) { left_table_properties.column_prefix = "lt"; left_table_properties.seed = 0; ASSERT_OK_AND_ASSIGN(TableStats left_table_stats, MakeTable(left_table_properties)); diff --git a/cpp/src/arrow/acero/asof_join_node.cc b/cpp/src/arrow/acero/asof_join_node.cc index 3970050e5022..2ba03f32f87e 100644 --- a/cpp/src/arrow/acero/asof_join_node.cc +++ b/cpp/src/arrow/acero/asof_join_node.cc @@ -237,7 +237,7 @@ struct MemoStore { struct Entry { Entry() = default; - Entry(OnType time, std::shared_ptr batch, row_index_t row) + Entry(OnType time, const std::shared_ptr& batch, row_index_t row) : time(time), batch(batch), row(row) {} void swap(Entry& other) { diff --git a/cpp/src/arrow/acero/asof_join_node_test.cc b/cpp/src/arrow/acero/asof_join_node_test.cc index 59a9b4ebba12..3c19d0aacb8b 100644 --- a/cpp/src/arrow/acero/asof_join_node_test.cc +++ b/cpp/src/arrow/acero/asof_join_node_test.cc @@ -1396,7 +1396,7 @@ struct BackpressureCountingNode : public MapNode { } BackpressureCountingNode(ExecPlan* plan, std::vector inputs, - std::shared_ptr output_schema, + const std::shared_ptr& output_schema, const BackpressureCountingNodeOptions& options) : MapNode(plan, inputs, output_schema), counters(options.counters) {} diff --git a/cpp/src/arrow/acero/exec_plan.cc b/cpp/src/arrow/acero/exec_plan.cc index 2aa5532a0cdf..afbb53d4ff25 100644 --- a/cpp/src/arrow/acero/exec_plan.cc +++ b/cpp/src/arrow/acero/exec_plan.cc @@ -1150,10 +1150,10 @@ ExecFactoryRegistry* default_exec_factory_registry() { } Result>()>> MakeReaderGenerator( - std::shared_ptr reader, ::arrow::internal::Executor* io_executor, + const std::shared_ptr& reader, ::arrow::internal::Executor* io_executor, int max_q, int q_restart) { auto batch_it = MakeMapIterator( - [](std::shared_ptr batch) { + [](const std::shared_ptr& batch) { return std::make_optional(ExecBatch(*batch)); }, MakeIteratorFromReader(reader)); diff --git a/cpp/src/arrow/acero/exec_plan.h b/cpp/src/arrow/acero/exec_plan.h index dba6c64ddc83..522af746d504 100644 --- a/cpp/src/arrow/acero/exec_plan.h +++ b/cpp/src/arrow/acero/exec_plan.h @@ -812,7 +812,7 @@ constexpr int kDefaultBackgroundQRestart = 16; /// Useful as a source node for an Exec plan ARROW_ACERO_EXPORT Result>()>> MakeReaderGenerator( - std::shared_ptr reader, arrow::internal::Executor* io_executor, + const std::shared_ptr& reader, arrow::internal::Executor* io_executor, int max_q = kDefaultBackgroundMaxQ, int q_restart = kDefaultBackgroundQRestart); } // namespace acero diff --git a/cpp/src/arrow/acero/hash_aggregate_test.cc b/cpp/src/arrow/acero/hash_aggregate_test.cc index 2f498f3a7bb2..ad66481db4a9 100644 --- a/cpp/src/arrow/acero/hash_aggregate_test.cc +++ b/cpp/src/arrow/acero/hash_aggregate_test.cc @@ -227,7 +227,7 @@ Result NaiveGroupBy(std::vector arguments, std::vector keys } Result MakeGroupByOutput(const std::vector& output_batches, - const std::shared_ptr output_schema, + const std::shared_ptr& output_schema, size_t num_aggregates, size_t num_keys, bool naive) { ArrayVector out_arrays(num_aggregates + num_keys); for (size_t i = 0; i < out_arrays.size(); ++i) { diff --git a/cpp/src/arrow/acero/source_node.cc b/cpp/src/arrow/acero/source_node.cc index ed3723d249da..c3592e1deb69 100644 --- a/cpp/src/arrow/acero/source_node.cc +++ b/cpp/src/arrow/acero/source_node.cc @@ -301,7 +301,7 @@ struct SourceNode : ExecNode, public TracedNode { }; struct TableSourceNode : public SourceNode { - TableSourceNode(ExecPlan* plan, std::shared_ptr table, int64_t batch_size) + TableSourceNode(ExecPlan* plan, const std::shared_ptr
& table, int64_t batch_size) : SourceNode(plan, table->schema(), TableGenerator(*table, batch_size), Ordering::Implicit()) {} @@ -319,7 +319,7 @@ struct TableSourceNode : public SourceNode { const char* kind_name() const override { return "TableSourceNode"; } - static arrow::Status ValidateTableSourceNodeInput(const std::shared_ptr
table, + static arrow::Status ValidateTableSourceNodeInput(const std::shared_ptr
& table, const int64_t batch_size) { if (table == nullptr) { return Status::Invalid("TableSourceNode requires table which is not null"); @@ -370,7 +370,7 @@ struct TableSourceNode : public SourceNode { template struct SchemaSourceNode : public SourceNode { - SchemaSourceNode(ExecPlan* plan, std::shared_ptr schema, + SchemaSourceNode(ExecPlan* plan, const std::shared_ptr& schema, arrow::AsyncGenerator> generator) : SourceNode(plan, schema, generator, Ordering::Implicit()) {} @@ -406,7 +406,7 @@ struct SchemaSourceNode : public SourceNode { }; struct RecordBatchReaderSourceNode : public SourceNode { - RecordBatchReaderSourceNode(ExecPlan* plan, std::shared_ptr schema, + RecordBatchReaderSourceNode(ExecPlan* plan, const std::shared_ptr& schema, arrow::AsyncGenerator> generator) : SourceNode(plan, schema, generator, Ordering::Implicit()) {} diff --git a/cpp/src/arrow/acero/source_node_test.cc b/cpp/src/arrow/acero/source_node_test.cc index 79ff5852815c..9c627355caf3 100644 --- a/cpp/src/arrow/acero/source_node_test.cc +++ b/cpp/src/arrow/acero/source_node_test.cc @@ -35,7 +35,7 @@ struct PauseThenStopNodeOptions : public ExecNodeOptions { template struct PauseThenStopNode : public MapNode { PauseThenStopNode(ExecPlan* plan, std::vector inputs, - std::shared_ptr output_schema, + const std::shared_ptr& output_schema, const PauseThenStopNodeOptions& options) : MapNode(plan, inputs, output_schema), num_pass(options.num_pass) {} diff --git a/cpp/src/arrow/acero/test_nodes.cc b/cpp/src/arrow/acero/test_nodes.cc index d95c22ca4510..bd32ec223726 100644 --- a/cpp/src/arrow/acero/test_nodes.cc +++ b/cpp/src/arrow/acero/test_nodes.cc @@ -274,7 +274,7 @@ struct GatedNode : public ExecNode, public TracedNode { } GatedNode(ExecPlan* plan, std::vector inputs, - std::shared_ptr output_schema, const GatedNodeOptions& options) + const std::shared_ptr& output_schema, const GatedNodeOptions& options) : ExecNode(plan, inputs, {"input"}, output_schema), TracedNode(this), gate_(options.gate) {} diff --git a/cpp/src/arrow/acero/unmaterialized_table_internal.h b/cpp/src/arrow/acero/unmaterialized_table_internal.h index 86b1a763a603..e1331fb96208 100644 --- a/cpp/src/arrow/acero/unmaterialized_table_internal.h +++ b/cpp/src/arrow/acero/unmaterialized_table_internal.h @@ -242,7 +242,7 @@ class UnmaterializedSliceBuilder { UnmaterializedCompositeTable* table_) : table(table_) {} - void AddEntry(std::shared_ptr rb, uint64_t start, uint64_t end) { + void AddEntry(const std::shared_ptr& rb, uint64_t start, uint64_t end) { if (rb) { table->AddRecordBatchRef(rb); } diff --git a/cpp/src/arrow/adapters/orc/adapter.cc b/cpp/src/arrow/adapters/orc/adapter.cc index 51cca497485c..02200db24d99 100644 --- a/cpp/src/arrow/adapters/orc/adapter.cc +++ b/cpp/src/arrow/adapters/orc/adapter.cc @@ -135,7 +135,7 @@ constexpr int64_t kReadRowsBatch = 1000; class OrcStripeReader : public RecordBatchReader { public: OrcStripeReader(std::unique_ptr row_reader, - std::shared_ptr schema, int64_t batch_size, MemoryPool* pool) + const std::shared_ptr& schema, int64_t batch_size, MemoryPool* pool) : row_reader_(std::move(row_reader)), schema_(schema), pool_(pool), diff --git a/cpp/src/arrow/adapters/orc/adapter_test.cc b/cpp/src/arrow/adapters/orc/adapter_test.cc index 3cbb6d7828f1..ef1038fc7c5a 100644 --- a/cpp/src/arrow/adapters/orc/adapter_test.cc +++ b/cpp/src/arrow/adapters/orc/adapter_test.cc @@ -103,7 +103,7 @@ std::shared_ptr GenerateFixedDifferenceBuffer(int32_t fixed_length, } std::shared_ptr CastFixedSizeBinaryArrayToBinaryArray( - std::shared_ptr array) { + const std::shared_ptr& array) { auto fixed_size_binary_array = checked_pointer_cast(array); std::shared_ptr value_offsets = GenerateFixedDifferenceBuffer( fixed_size_binary_array->byte_width(), array->length() + 1); @@ -114,7 +114,7 @@ std::shared_ptr CastFixedSizeBinaryArrayToBinaryArray( template std::shared_ptr CastInt64ArrayToTemporalArray( - const std::shared_ptr& type, std::shared_ptr array) { + const std::shared_ptr& type, const std::shared_ptr& array) { std::shared_ptr new_array_data = ArrayData::Make(type, array->length(), array->data()->buffers); return std::make_shared(new_array_data); @@ -128,7 +128,7 @@ Result> GenerateRandomDate64Array(int64_t size, } Result> GenerateRandomTimestampArray( - int64_t size, std::shared_ptr type, double null_probability) { + int64_t size, const std::shared_ptr& type, double null_probability) { random::RandomArrayGenerator rand(kRandomSeed); switch (type->unit()) { case TimeUnit::type::SECOND: { @@ -1049,7 +1049,7 @@ namespace { // read them back and compare equality in the unit test). Because the orc reader // fills unselected values to nulls when reading from the file. So flattening // the SparseUnionArray before writing makes it easy for the array equality check. -std::shared_ptr FlattenSparseUnionArray(std::shared_ptr array) { +std::shared_ptr FlattenSparseUnionArray(const std::shared_ptr& array) { auto union_array = checked_pointer_cast(array); ArrayVector children; for (int i = 0; i < array->num_fields(); ++i) { @@ -1061,7 +1061,7 @@ std::shared_ptr FlattenSparseUnionArray(std::shared_ptr array) { union_array->type_codes(), array->offset()); } -void TestUnionConversion(std::shared_ptr array) { +void TestUnionConversion(const std::shared_ptr& array) { auto length = array->length(); auto orc_type = liborc::Type::buildTypeFromString("uniontype"); diff --git a/cpp/src/arrow/adapters/tensorflow/convert.h b/cpp/src/arrow/adapters/tensorflow/convert.h index 9d093eddf6b5..521ffdb1c0be 100644 --- a/cpp/src/arrow/adapters/tensorflow/convert.h +++ b/cpp/src/arrow/adapters/tensorflow/convert.h @@ -77,7 +77,7 @@ Status GetArrowType(::tensorflow::DataType dtype, std::shared_ptr* out return Status::OK(); } -Status GetTensorFlowType(std::shared_ptr dtype, ::tensorflow::DataType* out) { +Status GetTensorFlowType(const std::shared_ptr& dtype, ::tensorflow::DataType* out) { switch (dtype->id()) { case Type::BOOL: *out = ::tensorflow::DT_BOOL; diff --git a/cpp/src/arrow/array/array_dict.cc b/cpp/src/arrow/array/array_dict.cc index 6b3511721d28..27e0f2388a07 100644 --- a/cpp/src/arrow/array/array_dict.cc +++ b/cpp/src/arrow/array/array_dict.cc @@ -517,7 +517,7 @@ struct RecursiveUnifier { } // namespace Result> DictionaryUnifier::Make( - std::shared_ptr value_type, MemoryPool* pool) { + const std::shared_ptr& value_type, MemoryPool* pool) { MakeUnifier maker(pool, value_type); RETURN_NOT_OK(VisitTypeInline(*value_type, &maker)); return std::move(maker.result); diff --git a/cpp/src/arrow/array/array_dict.h b/cpp/src/arrow/array/array_dict.h index 5844585734d6..3317382d1a9f 100644 --- a/cpp/src/arrow/array/array_dict.h +++ b/cpp/src/arrow/array/array_dict.h @@ -134,7 +134,7 @@ class ARROW_EXPORT DictionaryUnifier { /// \param[in] value_type the data type of the dictionaries /// \param[in] pool MemoryPool to use for memory allocations static Result> Make( - std::shared_ptr value_type, MemoryPool* pool = default_memory_pool()); + const std::shared_ptr& value_type, MemoryPool* pool = default_memory_pool()); /// \brief Unify dictionaries across array chunks /// diff --git a/cpp/src/arrow/array/array_dict_test.cc b/cpp/src/arrow/array/array_dict_test.cc index 23335ebb008a..deff89631ce8 100644 --- a/cpp/src/arrow/array/array_dict_test.cc +++ b/cpp/src/arrow/array/array_dict_test.cc @@ -873,7 +873,7 @@ TEST(TestFixedSizeBinaryDictionaryBuilder, AppendArrayInvalidType) { #endif template -void TestDecimalDictionaryBuilderBasic(std::shared_ptr decimal_type) { +void TestDecimalDictionaryBuilderBasic(const std::shared_ptr& decimal_type) { // Build the dictionary Array DictionaryBuilder builder(decimal_type); @@ -903,7 +903,7 @@ TEST(TestDecimal256DictionaryBuilder, Basic) { } void TestDecimalDictionaryBuilderDoubleTableSize( - std::shared_ptr decimal_type, FixedSizeBinaryBuilder& decimal_builder) { + const std::shared_ptr& decimal_type, FixedSizeBinaryBuilder& decimal_builder) { // Build the dictionary Array DictionaryBuilder dict_builder(decimal_type); @@ -1488,8 +1488,8 @@ TEST(TestDictionary, ListOfDictionary) { } TEST(TestDictionary, CanCompareIndices) { - auto make_dict = [](std::shared_ptr index_type, - std::shared_ptr value_type, std::string dictionary_json) { + auto make_dict = [](const std::shared_ptr& index_type, + const std::shared_ptr& value_type, std::string dictionary_json) { std::shared_ptr out; ARROW_EXPECT_OK( DictionaryArray::FromArrays(dictionary(index_type, value_type), diff --git a/cpp/src/arrow/array/array_list_test.cc b/cpp/src/arrow/array/array_list_test.cc index 4901a1e6fa6a..8a10032578f3 100644 --- a/cpp/src/arrow/array/array_list_test.cc +++ b/cpp/src/arrow/array/array_list_test.cc @@ -262,7 +262,7 @@ class TestListArray : public ::testing::Test { private: Result> FromArrays(const Array& offsets, const Array& sizes, const Array& values, - std::shared_ptr null_bitmap = NULLPTR, + const std::shared_ptr& null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount) { if constexpr (kTypeClassIsListView) { return ArrayType::FromArrays(offsets, sizes, values, pool_, null_bitmap, diff --git a/cpp/src/arrow/array/array_nested.cc b/cpp/src/arrow/array/array_nested.cc index 6849aca089b7..e532dd7bf614 100644 --- a/cpp/src/arrow/array/array_nested.cc +++ b/cpp/src/arrow/array/array_nested.cc @@ -102,7 +102,7 @@ Result CleanListOffsets(const std::shared_ptr& validity_bu template Result::ArrayType>> ListArrayFromArrays( - std::shared_ptr type, const Array& offsets, const Array& values, + const std::shared_ptr& type, const Array& offsets, const Array& values, MemoryPool* pool, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount) { using offset_type = typename TYPE::offset_type; @@ -145,7 +145,7 @@ Result::ArrayType>> ListArrayFromArray template Result::ArrayType>> ListViewArrayFromArrays( - std::shared_ptr type, const Array& offsets, const Array& sizes, + const std::shared_ptr& type, const Array& offsets, const Array& sizes, const Array& values, MemoryPool* pool, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount) { using offset_type = typename TYPE::offset_type; @@ -524,7 +524,7 @@ ListArray::ListArray(std::shared_ptr data) { } ListArray::ListArray(std::shared_ptr type, int64_t length, - std::shared_ptr value_offsets, std::shared_ptr values, + std::shared_ptr value_offsets, const std::shared_ptr& values, std::shared_ptr null_bitmap, int64_t null_count, int64_t offset) { ARROW_CHECK_EQ(type->id(), Type::LIST); @@ -644,7 +644,7 @@ ListViewArray::ListViewArray(std::shared_ptr data) { ListViewArray::ListViewArray(std::shared_ptr type, int64_t length, std::shared_ptr value_offsets, std::shared_ptr value_sizes, - std::shared_ptr values, + const std::shared_ptr& values, std::shared_ptr null_bitmap, int64_t null_count, int64_t offset) { ListViewArray::SetData(ArrayData::Make( @@ -719,7 +719,7 @@ LargeListViewArray::LargeListViewArray(std::shared_ptr data) { LargeListViewArray::LargeListViewArray(std::shared_ptr type, int64_t length, std::shared_ptr value_offsets, std::shared_ptr value_sizes, - std::shared_ptr values, + const std::shared_ptr& values, std::shared_ptr null_bitmap, int64_t null_count, int64_t offset) { LargeListViewArray::SetData(ArrayData::Make( diff --git a/cpp/src/arrow/array/array_nested.h b/cpp/src/arrow/array/array_nested.h index 57c87f900c6c..0a750506edf7 100644 --- a/cpp/src/arrow/array/array_nested.h +++ b/cpp/src/arrow/array/array_nested.h @@ -160,7 +160,7 @@ class ARROW_EXPORT ListArray : public BaseListArray { explicit ListArray(std::shared_ptr data); ListArray(std::shared_ptr type, int64_t length, - std::shared_ptr value_offsets, std::shared_ptr values, + std::shared_ptr value_offsets, const std::shared_ptr& values, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount, int64_t offset = 0); @@ -319,7 +319,7 @@ class ARROW_EXPORT ListViewArray : public BaseListViewArray { ListViewArray(std::shared_ptr type, int64_t length, std::shared_ptr value_offsets, - std::shared_ptr value_sizes, std::shared_ptr values, + std::shared_ptr value_sizes, const std::shared_ptr& values, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount, int64_t offset = 0); @@ -407,7 +407,7 @@ class ARROW_EXPORT LargeListViewArray : public BaseListViewArray type, int64_t length, std::shared_ptr value_offsets, - std::shared_ptr value_sizes, std::shared_ptr values, + std::shared_ptr value_sizes, const std::shared_ptr& values, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount, int64_t offset = 0); diff --git a/cpp/src/arrow/array/array_run_end_test.cc b/cpp/src/arrow/array/array_run_end_test.cc index 6cf50ccade19..b81fdfae7cde 100644 --- a/cpp/src/arrow/array/array_run_end_test.cc +++ b/cpp/src/arrow/array/array_run_end_test.cc @@ -68,7 +68,7 @@ class TestRunEndEncodedArray } std::shared_ptr RunEndEncodedArrayFromJSON( - int64_t logical_length, std::shared_ptr value_type, + int64_t logical_length, const std::shared_ptr& value_type, std::string_view run_ends_json, std::string_view values_json, int64_t logical_offset = 0) { auto run_ends = ArrayFromJSON(run_end_type, run_ends_json); diff --git a/cpp/src/arrow/array/array_union_test.cc b/cpp/src/arrow/array/array_union_test.cc index ec93329d0839..8e279ec26218 100644 --- a/cpp/src/arrow/array/array_union_test.cc +++ b/cpp/src/arrow/array/array_union_test.cc @@ -39,7 +39,7 @@ TEST(TestUnionArray, TestSliceEquals) { std::shared_ptr batch; ASSERT_OK(ipc::test::MakeUnion(&batch)); - auto CheckUnion = [](std::shared_ptr array) { + auto CheckUnion = [](const std::shared_ptr& array) { const int64_t size = array->length(); std::shared_ptr slice, slice2; slice = array->Slice(2); diff --git a/cpp/src/arrow/array/builder_run_end.cc b/cpp/src/arrow/array/builder_run_end.cc index 2edeaff504d2..798b395b507b 100644 --- a/cpp/src/arrow/array/builder_run_end.cc +++ b/cpp/src/arrow/array/builder_run_end.cc @@ -34,7 +34,7 @@ namespace internal { RunCompressorBuilder::RunCompressorBuilder(MemoryPool* pool, std::shared_ptr inner_builder, - std::shared_ptr type) + const std::shared_ptr& type) : ArrayBuilder(pool), inner_builder_(std::move(inner_builder)) {} RunCompressorBuilder::~RunCompressorBuilder() = default; @@ -166,7 +166,7 @@ RunEndEncodedBuilder::ValueRunBuilder::ValueRunBuilder( RunEndEncodedBuilder::RunEndEncodedBuilder( MemoryPool* pool, const std::shared_ptr& run_end_builder, - const std::shared_ptr& value_builder, std::shared_ptr type) + const std::shared_ptr& value_builder, const std::shared_ptr& type) : ArrayBuilder(pool), type_(internal::checked_pointer_cast(type)) { auto value_run_builder = std::make_shared(pool, value_builder, type_->value_type(), *this); diff --git a/cpp/src/arrow/array/builder_run_end.h b/cpp/src/arrow/array/builder_run_end.h index ac92efbd0dbe..4872e14c9567 100644 --- a/cpp/src/arrow/array/builder_run_end.h +++ b/cpp/src/arrow/array/builder_run_end.h @@ -60,7 +60,7 @@ namespace internal { class RunCompressorBuilder : public ArrayBuilder { public: RunCompressorBuilder(MemoryPool* pool, std::shared_ptr inner_builder, - std::shared_ptr type); + const std::shared_ptr& type); ~RunCompressorBuilder() override; @@ -202,7 +202,7 @@ class ARROW_EXPORT RunEndEncodedBuilder : public ArrayBuilder { RunEndEncodedBuilder(MemoryPool* pool, const std::shared_ptr& run_end_builder, const std::shared_ptr& value_builder, - std::shared_ptr type); + const std::shared_ptr& type); /// \brief Allocate enough memory for a given number of array elements. /// diff --git a/cpp/src/arrow/array/builder_time.h b/cpp/src/arrow/array/builder_time.h index b471e9621cd4..689362634202 100644 --- a/cpp/src/arrow/array/builder_time.h +++ b/cpp/src/arrow/array/builder_time.h @@ -38,7 +38,7 @@ class ARROW_EXPORT DayTimeIntervalBuilder : public NumericBuilder type, + explicit DayTimeIntervalBuilder(const std::shared_ptr& type, MemoryPool* pool = default_memory_pool(), int64_t alignment = kDefaultBufferAlignment) : NumericBuilder(type, pool, alignment) {} @@ -53,7 +53,7 @@ class ARROW_EXPORT MonthDayNanoIntervalBuilder int64_t alignment = kDefaultBufferAlignment) : MonthDayNanoIntervalBuilder(month_day_nano_interval(), pool, alignment) {} - explicit MonthDayNanoIntervalBuilder(std::shared_ptr type, + explicit MonthDayNanoIntervalBuilder(const std::shared_ptr& type, MemoryPool* pool = default_memory_pool(), int64_t alignment = kDefaultBufferAlignment) : NumericBuilder(type, pool, alignment) {} diff --git a/cpp/src/arrow/array/diff_test.cc b/cpp/src/arrow/array/diff_test.cc index 76f4202992f3..958ba10ffdaf 100644 --- a/cpp/src/arrow/array/diff_test.cc +++ b/cpp/src/arrow/array/diff_test.cc @@ -115,7 +115,7 @@ class DiffTest : public ::testing::Test { /*verbose=*/true); } - void BaseAndTargetFromRandomFilter(std::shared_ptr values, + void BaseAndTargetFromRandomFilter(const std::shared_ptr& values, double filter_probability) { std::shared_ptr base_filter, target_filter; do { diff --git a/cpp/src/arrow/buffer.cc b/cpp/src/arrow/buffer.cc index 17e745204640..e951cd0fd93e 100644 --- a/cpp/src/arrow/buffer.cc +++ b/cpp/src/arrow/buffer.cc @@ -124,7 +124,7 @@ Result> Buffer::GetWriter(std::shared_ptrmemory_manager_->GetBufferWriter(std::move(buf)); } -Result> Buffer::Copy(std::shared_ptr source, +Result> Buffer::Copy(const std::shared_ptr& source, const std::shared_ptr& to) { return MemoryManager::CopyBuffer(source, to); } @@ -134,13 +134,13 @@ Result> Buffer::CopyNonOwned( return MemoryManager::CopyNonOwned(source, to); } -Result> Buffer::View(std::shared_ptr source, +Result> Buffer::View(const std::shared_ptr& source, const std::shared_ptr& to) { return MemoryManager::ViewBuffer(source, to); } Result> Buffer::ViewOrCopy( - std::shared_ptr source, const std::shared_ptr& to) { + const std::shared_ptr& source, const std::shared_ptr& to) { auto maybe_buffer = MemoryManager::ViewBuffer(source, to); if (maybe_buffer.ok()) { return maybe_buffer; diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h index 07f9931eba73..4cd76062b4ad 100644 --- a/cpp/src/arrow/buffer.h +++ b/cpp/src/arrow/buffer.h @@ -328,7 +328,7 @@ class ARROW_EXPORT Buffer { /// /// The buffer contents will be copied into a new buffer allocated by the /// given MemoryManager. This function supports cross-device copies. - static Result> Copy(std::shared_ptr source, + static Result> Copy(const std::shared_ptr& source, const std::shared_ptr& to); /// \brief Copy a non-owned buffer @@ -349,7 +349,7 @@ class ARROW_EXPORT Buffer { /// If a non-copy view is unsupported for the buffer on the given device, /// nullptr is returned. An error can be returned if some low-level /// operation fails (such as an out-of-memory condition). - static Result> View(std::shared_ptr source, + static Result> View(const std::shared_ptr& source, const std::shared_ptr& to); /// \brief View or copy buffer @@ -357,7 +357,7 @@ class ARROW_EXPORT Buffer { /// Try to view buffer contents on the given MemoryManager's device, but /// fall back to copying if a no-copy view isn't supported. static Result> ViewOrCopy( - std::shared_ptr source, const std::shared_ptr& to); + const std::shared_ptr& source, const std::shared_ptr& to); virtual std::shared_ptr device_sync_event() const { return NULLPTR; } diff --git a/cpp/src/arrow/buffer_test.cc b/cpp/src/arrow/buffer_test.cc index 4dd210076ed1..b3c7d84a41bf 100644 --- a/cpp/src/arrow/buffer_test.cc +++ b/cpp/src/arrow/buffer_test.cc @@ -87,7 +87,7 @@ class MyDevice : public Device { class MyMemoryManager : public MemoryManager { public: - explicit MyMemoryManager(std::shared_ptr device) : MemoryManager(device) {} + explicit MyMemoryManager(const std::shared_ptr& device) : MemoryManager(device) {} bool allow_copy() const { return checked_cast(*device()).allow_copy(); @@ -132,7 +132,7 @@ class MyMemoryManager : public MemoryManager { class MyBuffer : public Buffer { public: - MyBuffer(std::shared_ptr mm, const std::shared_ptr& parent) + MyBuffer(const std::shared_ptr& mm, const std::shared_ptr& parent) : Buffer(parent->data(), parent->size()) { parent_ = parent; SetMemoryManager(mm); diff --git a/cpp/src/arrow/c/bridge.cc b/cpp/src/arrow/c/bridge.cc index 184be3ab8eb9..75daee9126c9 100644 --- a/cpp/src/arrow/c/bridge.cc +++ b/cpp/src/arrow/c/bridge.cc @@ -1506,7 +1506,7 @@ class ImportedBuffer : public Buffer { std::shared_ptr import) : Buffer(data, size), import_(std::move(import)) {} - ImportedBuffer(const uint8_t* data, int64_t size, std::shared_ptr mm, + ImportedBuffer(const uint8_t* data, int64_t size, const std::shared_ptr& mm, DeviceAllocationType device_type, std::shared_ptr import) : Buffer(data, size, mm, nullptr, device_type), import_(std::move(import)) {} @@ -1960,7 +1960,7 @@ struct ArrayImporter { } // namespace Result> ImportArray(struct ArrowArray* array, - std::shared_ptr type) { + const std::shared_ptr& type) { ArrayImporter importer(type); RETURN_NOT_OK(importer.Import(array)); return importer.MakeArray(); @@ -2002,7 +2002,7 @@ Result> DefaultDeviceMemoryMapper( } Result> ImportDeviceArray(struct ArrowDeviceArray* array, - std::shared_ptr type, + const std::shared_ptr& type, const DeviceMemoryMapper& mapper) { ArrayImporter importer(type); RETURN_NOT_OK(importer.Import(array, mapper)); @@ -2287,22 +2287,22 @@ class ArrayStreamReader { } Result> ImportRecordBatchInternal( - struct ArrowArray* array, std::shared_ptr schema) { + struct ArrowArray* array, const std::shared_ptr& schema) { return ImportRecordBatch(array, schema); } Result> ImportRecordBatchInternal( - struct ArrowDeviceArray* array, std::shared_ptr schema) { + struct ArrowDeviceArray* array, const std::shared_ptr& schema) { return ImportDeviceRecordBatch(array, schema, mapper_); } Result> ImportArrayInternal( - struct ArrowArray* array, std::shared_ptr type) { + struct ArrowArray* array, const std::shared_ptr& type) { return ImportArray(array, type); } Result> ImportArrayInternal( - struct ArrowDeviceArray* array, std::shared_ptr type) { + struct ArrowDeviceArray* array, const std::shared_ptr& type) { return ImportDeviceArray(array, type, mapper_); } @@ -2835,7 +2835,7 @@ Future CreateAsyncDeviceStreamHandler( } Future<> ExportAsyncRecordBatchReader( - std::shared_ptr schema, + const std::shared_ptr& schema, AsyncGenerator> generator, DeviceAllocationType device_type, struct ArrowAsyncDeviceStreamHandler* handler) { if (!schema) { diff --git a/cpp/src/arrow/c/bridge.h b/cpp/src/arrow/c/bridge.h index 78860e0650e7..496bb740bf94 100644 --- a/cpp/src/arrow/c/bridge.h +++ b/cpp/src/arrow/c/bridge.h @@ -126,7 +126,7 @@ Result> ImportSchema(struct ArrowSchema* schema); /// \return Imported array object ARROW_EXPORT Result> ImportArray(struct ArrowArray* array, - std::shared_ptr type); + const std::shared_ptr& type); /// \brief Import C++ array and its type from the C data interface. /// @@ -236,7 +236,7 @@ Result> DefaultDeviceMemoryMapper( /// \return Imported array object ARROW_EXPORT Result> ImportDeviceArray( - struct ArrowDeviceArray* array, std::shared_ptr type, + struct ArrowDeviceArray* array, const std::shared_ptr& type, const DeviceMemoryMapper& mapper = DefaultDeviceMemoryMapper); /// \brief EXPERIMENTAL: Import C++ device array and its type from the C data interface. @@ -480,7 +480,7 @@ Future CreateAsyncDeviceStreamHandler( /// \return Future that will resolve once the generator is exhausted or an error occurs ARROW_EXPORT Future<> ExportAsyncRecordBatchReader( - std::shared_ptr schema, + const std::shared_ptr& schema, AsyncGenerator> generator, DeviceAllocationType device_type, struct ArrowAsyncDeviceStreamHandler* handler); diff --git a/cpp/src/arrow/c/bridge_test.cc b/cpp/src/arrow/c/bridge_test.cc index 9a4d104d0004..f91ebdf43959 100644 --- a/cpp/src/arrow/c/bridge_test.cc +++ b/cpp/src/arrow/c/bridge_test.cc @@ -681,7 +681,7 @@ class TestArrayExport : public ::testing::Test { void SetUp() override { pool_ = default_memory_pool(); } static std::function>()> JSONArrayFactory( - std::shared_ptr type, const char* json) { + const std::shared_ptr& type, const char* json) { return [=]() { return ArrayFromJSON(type, json); }; } @@ -1458,7 +1458,7 @@ class TestDeviceArrayExport : public ::testing::Test { } static std::function>()> JSONArrayFactory( - const std::shared_ptr& mm, std::shared_ptr type, + const std::shared_ptr& mm, const std::shared_ptr& type, const char* json) { return [=]() { return ToDevice(mm, *ArrayFromJSON(type, json)->data()); }; } @@ -3912,7 +3912,7 @@ class TestArrayRoundtrip : public ::testing::Test { void SetUp() override { pool_ = default_memory_pool(); } - static ArrayFactory JSONArrayFactory(std::shared_ptr type, const char* json) { + static ArrayFactory JSONArrayFactory(const std::shared_ptr& type, const char* json) { return [=]() { return ArrayFromJSON(type, json); }; } @@ -4015,11 +4015,11 @@ class TestArrayRoundtrip : public ::testing::Test { ASSERT_EQ(pool_->bytes_allocated(), orig_bytes); } - void TestWithJSON(std::shared_ptr type, const char* json) { + void TestWithJSON(const std::shared_ptr& type, const char* json) { TestWithArrayFactory(JSONArrayFactory(type, json)); } - void TestWithJSONSliced(std::shared_ptr type, const char* json) { + void TestWithJSONSliced(const std::shared_ptr& type, const char* json) { TestWithArrayFactory(SlicedArrayFactory(JSONArrayFactory(type, json))); } @@ -4352,7 +4352,7 @@ class TestDeviceArrayRoundtrip : public ::testing::Test { } static ArrayFactory JSONArrayFactory(const std::shared_ptr& mm, - std::shared_ptr type, const char* json) { + const std::shared_ptr& type, const char* json) { return [=]() { return ToDevice(mm, *ArrayFromJSON(type, json)->data()); }; } @@ -4463,12 +4463,12 @@ class TestDeviceArrayRoundtrip : public ::testing::Test { } void TestWithJSON(const std::shared_ptr& mm, - std::shared_ptr type, const char* json) { + const std::shared_ptr& type, const char* json) { TestWithArrayFactory(JSONArrayFactory(mm, type, json)); } void TestWithJSONSliced(const std::shared_ptr& mm, - std::shared_ptr type, const char* json) { + const std::shared_ptr& type, const char* json) { TestWithArrayFactory(SlicedArrayFactory(JSONArrayFactory(mm, type, json))); } @@ -4519,7 +4519,7 @@ class BaseArrayStreamTest : public ::testing::Test { void TearDown() override { ASSERT_EQ(pool_->bytes_allocated(), orig_allocated_); } - RecordBatchVector MakeBatches(std::shared_ptr schema, ArrayVector arrays) { + RecordBatchVector MakeBatches(const std::shared_ptr& schema, ArrayVector arrays) { DCHECK_EQ(schema->num_fields(), 1); RecordBatchVector batches; for (const auto& array : arrays) { diff --git a/cpp/src/arrow/compute/exec_test.cc b/cpp/src/arrow/compute/exec_test.cc index 9c361366e310..3202cb14229f 100644 --- a/cpp/src/arrow/compute/exec_test.cc +++ b/cpp/src/arrow/compute/exec_test.cc @@ -1220,7 +1220,7 @@ void TestCallScalarFunctionPreallocationCases::DoTest(FunctionCallerMaker caller auto arr = GetUInt8Array(100, null_prob); - auto CheckFunction = [&](std::shared_ptr test_copy) { + auto CheckFunction = [&](const std::shared_ptr& test_copy) { ResetContexts(); // The default should be a single array output @@ -1307,7 +1307,7 @@ void TestCallScalarFunctionBasicNonStandardCases::DoTest( auto arr = GetUInt8Array(1000, null_prob); std::vector args = {Datum(arr)}; - auto CheckFunction = [&](std::shared_ptr test_nopre) { + auto CheckFunction = [&](const std::shared_ptr& test_nopre) { ResetContexts(); // The default should be a single array output diff --git a/cpp/src/arrow/compute/expression_test.cc b/cpp/src/arrow/compute/expression_test.cc index b4ae405b35a9..3807a465c143 100644 --- a/cpp/src/arrow/compute/expression_test.cc +++ b/cpp/src/arrow/compute/expression_test.cc @@ -177,7 +177,7 @@ TEST(ExpressionUtils, StripOrderPreservingCasts) { } TEST(ExpressionUtils, MakeExecBatch) { - auto Expect = [](std::shared_ptr partial_batch) { + auto Expect = [](const std::shared_ptr& partial_batch) { SCOPED_TRACE(partial_batch->ToString()); ASSERT_OK_AND_ASSIGN(auto batch, MakeExecBatch(*kBoringSchema, partial_batch)); @@ -696,9 +696,9 @@ TEST(Expression, BindWithDecimalArithmeticOps) { TEST(Expression, BindWithDecimalDivision) { auto expect_decimal_division_type = [](std::string name, - std::shared_ptr dividend, - std::shared_ptr divisor, - std::shared_ptr expected) { + const std::shared_ptr& dividend, + const std::shared_ptr& divisor, + const std::shared_ptr& expected) { auto schema = arrow::schema({field("dividend", dividend), field("divisor", divisor)}); auto expr = call(name, {field_ref("dividend"), field_ref("divisor")}); ASSERT_OK_AND_ASSIGN(auto bound, expr.Bind(*schema)); @@ -1920,7 +1920,7 @@ TEST(Expression, SimplifyWithComparisonAndNullableCaveat) { } TEST(Expression, SimplifyIsIn) { - auto is_in = [](Expression field, std::shared_ptr value_set_type, + auto is_in = [](Expression field, const std::shared_ptr& value_set_type, std::string json_array, SetLookupOptions::NullMatchingBehavior null_matching_behavior) { SetLookupOptions options{ArrayFromJSON(value_set_type, json_array), diff --git a/cpp/src/arrow/compute/function_benchmark.cc b/cpp/src/arrow/compute/function_benchmark.cc index 3dfd590c7e30..1c35fa5b6225 100644 --- a/cpp/src/arrow/compute/function_benchmark.cc +++ b/cpp/src/arrow/compute/function_benchmark.cc @@ -37,7 +37,7 @@ namespace compute { constexpr int32_t kSeed = 0xfede4a7e; constexpr int64_t kScalarCount = 1 << 10; -inline ScalarVector ToScalars(std::shared_ptr arr) { +inline ScalarVector ToScalars(const std::shared_ptr& arr) { ScalarVector scalars{static_cast(arr->length())}; int64_t i = 0; for (auto& scalar : scalars) { diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.cc index f7ff72bc114a..225231f95d4c 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_basic.cc @@ -316,7 +316,7 @@ struct ProductImpl : public ScalarAggregator { using ProductType = typename TypeTraits::CType; using OutputType = typename TypeTraits::ScalarType; - explicit ProductImpl(std::shared_ptr out_type, + explicit ProductImpl(const std::shared_ptr& out_type, const ScalarAggregateOptions& options) : out_type(out_type), options(options), @@ -398,7 +398,7 @@ struct ProductInit { std::shared_ptr type; const ScalarAggregateOptions& options; - ProductInit(KernelContext* ctx, std::shared_ptr type, + ProductInit(KernelContext* ctx, const std::shared_ptr& type, const ScalarAggregateOptions& options) : ctx(ctx), type(type), options(options) {} @@ -844,7 +844,7 @@ struct IndexInit { void AddBasicAggKernels(KernelInit init, const std::vector>& types, - std::shared_ptr out_ty, ScalarAggregateFunction* func, + const std::shared_ptr& out_ty, ScalarAggregateFunction* func, SimdLevel::type simd_level) { for (const auto& ty : types) { // array[InT] -> scalar[OutT] @@ -857,7 +857,7 @@ namespace { void AddScalarAggKernels(KernelInit init, const std::vector>& types, - std::shared_ptr out_ty, + const std::shared_ptr& out_ty, ScalarAggregateFunction* func) { for (const auto& ty : types) { auto sig = KernelSignature::Make({ty->id()}, out_ty); @@ -867,7 +867,7 @@ void AddScalarAggKernels(KernelInit init, void AddArrayScalarAggKernels(KernelInit init, const std::vector>& types, - std::shared_ptr out_ty, + const std::shared_ptr& out_ty, ScalarAggregateFunction* func, SimdLevel::type simd_level = SimdLevel::NONE) { AddBasicAggKernels(init, types, out_ty, func, simd_level); diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc index 3733f415a048..88c57a3b6fd5 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc @@ -164,7 +164,7 @@ struct SumLikeInit { std::shared_ptr type; const ScalarAggregateOptions& options; - SumLikeInit(KernelContext* ctx, std::shared_ptr type, + SumLikeInit(KernelContext* ctx, const std::shared_ptr& type, const ScalarAggregateOptions& options) : ctx(ctx), type(type), options(options) {} @@ -287,7 +287,7 @@ struct MeanImpl class KernelClass> struct MeanKernelInit : public SumLikeInit { - MeanKernelInit(KernelContext* ctx, std::shared_ptr type, + MeanKernelInit(KernelContext* ctx, const std::shared_ptr& type, const ScalarAggregateOptions& options) : SumLikeInit(ctx, type, options) {} diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic_internal.h b/cpp/src/arrow/compute/kernels/aggregate_basic_internal.h index 5cc3a558b1ef..d927d8a982e2 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic_internal.h +++ b/cpp/src/arrow/compute/kernels/aggregate_basic_internal.h @@ -31,7 +31,7 @@ namespace arrow::compute::internal { void AddBasicAggKernels(KernelInit init, const std::vector>& types, - std::shared_ptr out_ty, ScalarAggregateFunction* func, + const std::shared_ptr& out_ty, ScalarAggregateFunction* func, SimdLevel::type simd_level = SimdLevel::NONE); void AddMinMaxKernels(KernelInit init, diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.cc b/cpp/src/arrow/compute/kernels/codegen_internal.cc index 99a9173041fc..f53f0011e991 100644 --- a/cpp/src/arrow/compute/kernels/codegen_internal.cc +++ b/cpp/src/arrow/compute/kernels/codegen_internal.cc @@ -545,7 +545,7 @@ Status CastDecimalArgs(TypeHolder* begin, size_t count) { } Result> WidenDecimalToMaxPrecision( - std::shared_ptr type) { + const std::shared_ptr& type) { DCHECK(is_decimal(type->id())); auto cast_type = checked_pointer_cast(type); switch (type->id()) { diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.h b/cpp/src/arrow/compute/kernels/codegen_internal.h index bfc529dc0a46..d79fcff3e4d1 100644 --- a/cpp/src/arrow/compute/kernels/codegen_internal.h +++ b/cpp/src/arrow/compute/kernels/codegen_internal.h @@ -1481,7 +1481,7 @@ Status CastDecimalArgs(TypeHolder* begin, size_t count); /// and the maximum precision for that DecimalType. ARROW_EXPORT Result> WidenDecimalToMaxPrecision( - std::shared_ptr type); + const std::shared_ptr& type); ARROW_EXPORT bool HasDecimal(const std::vector& types); diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc b/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc index 030a862afc09..a3e3dc5323b9 100644 --- a/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc +++ b/cpp/src/arrow/compute/kernels/hash_aggregate_pivot.cc @@ -333,7 +333,7 @@ struct GroupedPivotAccumulator { return Status::OK(); } - Status MergeColumn(std::shared_ptr* column, std::shared_ptr other_column, + Status MergeColumn(std::shared_ptr* column, const std::shared_ptr& other_column, const ColumnTransform& transform = {}) { if (other_column->null_count() == other_column->length()) { // Avoid paying for the transform step below, since merging will be a no-op anyway. diff --git a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc index cd60d5280b1c..0af861a310ba 100644 --- a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc +++ b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc @@ -1059,7 +1059,7 @@ std::shared_ptr MakeArithmeticFunctionFloatingPointNotNull( } template