This is an automated email from the ASF dual-hosted git repository.
gangwu 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 836aa1e5cc GH-36970: [C++][Parquet] Minor style fix for parquet
metadata (#36971)
836aa1e5cc is described below
commit 836aa1e5ccaa20fb5d3b4b7f44adc84642ff0e56
Author: mwish <[email protected]>
AuthorDate: Wed Aug 2 11:23:44 2023 +0800
GH-36970: [C++][Parquet] Minor style fix for parquet metadata (#36971)
### Rationale for this change
Minor style fix
### What changes are included in this PR?
1. Change `new` to `make_unique` or `make_shared`
2. Add a reserve for `column_order`
### Are these changes tested?
Not required.
### Are there any user-facing changes?
no
* Closes: #36970
Authored-by: mwish <[email protected]>
Signed-off-by: Gang Wu <[email protected]>
---
cpp/src/parquet/metadata.cc | 15 ++++++++-------
cpp/src/parquet/thrift_internal.h | 3 +--
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc
index 541bcc18b8..8aedf5b926 100644
--- a/cpp/src/parquet/metadata.cc
+++ b/cpp/src/parquet/metadata.cc
@@ -593,13 +593,13 @@ class FileMetaData::FileMetaDataImpl {
FileMetaDataImpl() = default;
explicit FileMetaDataImpl(
- const void* metadata, uint32_t* metadata_len, const ReaderProperties&
properties,
+ const void* metadata, uint32_t* metadata_len, ReaderProperties
properties,
std::shared_ptr<InternalFileDecryptor> file_decryptor = nullptr)
- : properties_(properties), file_decryptor_(file_decryptor) {
- metadata_.reset(new format::FileMetaData);
+ : properties_(std::move(properties)),
file_decryptor_(std::move(file_decryptor)) {
+ metadata_ = std::make_unique<format::FileMetaData>();
auto footer_decryptor =
- file_decryptor_ != nullptr ? file_decryptor->GetFooterDecryptor() :
nullptr;
+ file_decryptor_ != nullptr ? file_decryptor_->GetFooterDecryptor() :
nullptr;
ThriftDeserializer deserializer(properties_);
deserializer.DeserializeMessage(reinterpret_cast<const uint8_t*>(metadata),
@@ -779,8 +779,8 @@ class FileMetaData::FileMetaDataImpl {
}
std::shared_ptr<FileMetaData> out(new FileMetaData());
- out->impl_.reset(new FileMetaDataImpl());
- out->impl_->metadata_.reset(new format::FileMetaData());
+ out->impl_ = std::make_unique<FileMetaDataImpl>();
+ out->impl_->metadata_ = std::make_unique<format::FileMetaData>();
auto metadata = out->impl_->metadata_.get();
metadata->version = metadata_->version;
@@ -834,6 +834,7 @@ class FileMetaData::FileMetaDataImpl {
// update ColumnOrder
std::vector<parquet::ColumnOrder> column_orders;
if (metadata_->__isset.column_orders) {
+ column_orders.reserve(metadata_->column_orders.size());
for (auto column_order : metadata_->column_orders) {
if (column_order.__isset.TYPE_ORDER) {
column_orders.push_back(ColumnOrder::type_defined_);
@@ -865,7 +866,7 @@ std::shared_ptr<FileMetaData> FileMetaData::Make(
std::shared_ptr<InternalFileDecryptor> file_decryptor) {
// This FileMetaData ctor is private, not compatible with std::make_shared
return std::shared_ptr<FileMetaData>(
- new FileMetaData(metadata, metadata_len, properties, file_decryptor));
+ new FileMetaData(metadata, metadata_len, properties,
std::move(file_decryptor)));
}
std::shared_ptr<FileMetaData> FileMetaData::Make(
diff --git a/cpp/src/parquet/thrift_internal.h
b/cpp/src/parquet/thrift_internal.h
index e9b859541b..5824a82d5b 100644
--- a/cpp/src/parquet/thrift_internal.h
+++ b/cpp/src/parquet/thrift_internal.h
@@ -435,8 +435,7 @@ class ThriftDeserializer {
#if PARQUET_THRIFT_VERSION_MAJOR > 0 || PARQUET_THRIFT_VERSION_MINOR >= 14
auto conf = std::make_shared<apache::thrift::TConfiguration>();
conf->setMaxMessageSize(std::numeric_limits<int>::max());
- return std::shared_ptr<ThriftBuffer>(
- new ThriftBuffer(buf, len, ThriftBuffer::OBSERVE, conf));
+ return std::make_shared<ThriftBuffer>(buf, len, ThriftBuffer::OBSERVE,
conf);
#else
return std::make_shared<ThriftBuffer>(buf, len);
#endif