This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 68a30f6433 GH-36342: [C++] Add missing move semantic to RecordBatch
(#36343)
68a30f6433 is described below
commit 68a30f6433e65879d118707745aaed4e1a3dbd58
Author: zhjwpku <[email protected]>
AuthorDate: Wed Jun 28 18:39:17 2023 +0800
GH-36342: [C++] Add missing move semantic to RecordBatch (#36343)
### Rationale for this change
In file record_batch.cc there are some places that using move semantic can
avoid coping vector or increasing reference count of shared_ptr.
### What changes are included in this PR?
add std::move at some proper places
### Are these changes tested?
Yes, run `ctest -R arrow-table-test` locally.
### Are there any user-facing changes?
No
* Closes: #36342
Authored-by: Zhao Junwang <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
---
cpp/src/arrow/record_batch.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/cpp/src/arrow/record_batch.cc b/cpp/src/arrow/record_batch.cc
index facc912399..3ce99d6f84 100644
--- a/cpp/src/arrow/record_batch.cc
+++ b/cpp/src/arrow/record_batch.cc
@@ -176,7 +176,8 @@ std::shared_ptr<RecordBatch> RecordBatch::Make(
std::shared_ptr<Schema> schema, int64_t num_rows,
std::vector<std::shared_ptr<Array>> columns) {
DCHECK_EQ(schema->num_fields(), static_cast<int>(columns.size()));
- return std::make_shared<SimpleRecordBatch>(std::move(schema), num_rows,
columns);
+ return std::make_shared<SimpleRecordBatch>(std::move(schema), num_rows,
+ std::move(columns));
}
std::shared_ptr<RecordBatch> RecordBatch::Make(
@@ -194,7 +195,7 @@ Result<std::shared_ptr<RecordBatch>> RecordBatch::MakeEmpty(
ARROW_ASSIGN_OR_RAISE(empty_batch[i],
MakeEmptyArray(schema->field(i)->type(),
memory_pool));
}
- return RecordBatch::Make(schema, 0, empty_batch);
+ return RecordBatch::Make(std::move(schema), 0, std::move(empty_batch));
}
Result<std::shared_ptr<RecordBatch>> RecordBatch::FromStructArray(
@@ -391,7 +392,7 @@ Result<std::shared_ptr<RecordBatchReader>>
RecordBatchReader::Make(
schema = batches[0]->schema();
}
- return std::make_shared<SimpleRecordBatchReader>(std::move(batches), schema);
+ return std::make_shared<SimpleRecordBatchReader>(std::move(batches),
std::move(schema));
}
Result<std::shared_ptr<RecordBatchReader>> RecordBatchReader::MakeFromIterator(
@@ -400,7 +401,7 @@ Result<std::shared_ptr<RecordBatchReader>>
RecordBatchReader::MakeFromIterator(
return Status::Invalid("Schema cannot be nullptr");
}
- return std::make_shared<SimpleRecordBatchReader>(std::move(batches), schema);
+ return std::make_shared<SimpleRecordBatchReader>(std::move(batches),
std::move(schema));
}
RecordBatchReader::~RecordBatchReader() {