Skip to content

Commit

Permalink
GH-43143: [C++][Parquet] Default initialize some parquet metadata var…
Browse files Browse the repository at this point in the history
…iables (#43144)

### Rationale for this change

Default initialize some parquet metadata variables

### What changes are included in this PR?

Default initialize some parquet metadata variables

### Are these changes tested?

Covered by existing

### Are there any user-facing changes?

no

* GitHub Issue: #43143

Authored-by: mwish <maplewish117@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
mapleFU authored Jul 10, 2024
1 parent 89fd566 commit 031497d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cpp/src/parquet/metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1360,9 +1360,9 @@ class ApplicationVersionParser {
// For parsing.
std::string spaces_;
std::string digits_;
size_t version_parsing_position_;
size_t version_start_;
size_t version_end_;
size_t version_parsing_position_{0};
size_t version_start_{0};
size_t version_end_{0};
std::string version_string_;
};
} // namespace
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/parquet/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ class SchemaVisitor : public Node::ConstVisitor {
void Visit(const Node* node) override {
format::SchemaElement element;
node->ToParquet(&element);
elements_->push_back(element);
elements_->push_back(std::move(element));

if (node->is_group()) {
const GroupNode* group_node = static_cast<const GroupNode*>(node);
Expand Down Expand Up @@ -671,7 +671,7 @@ static void PrintType(const PrimitiveNode* node, std::ostream& stream) {

static void PrintConvertedType(const PrimitiveNode* node, std::ostream& stream) {
auto lt = node->converted_type();
auto la = node->logical_type();
const auto& la = node->logical_type();
if (la && la->is_valid() && !la->is_none()) {
stream << " (" << la->ToString() << ")";
} else if (lt == ConvertedType::DECIMAL) {
Expand Down Expand Up @@ -718,7 +718,7 @@ struct SchemaPrinter : public Node::ConstVisitor {
stream_ << " group "
<< "field_id=" << node->field_id() << " " << node->name();
auto lt = node->converted_type();
auto la = node->logical_type();
const auto& la = node->logical_type();
if (la && la->is_valid() && !la->is_none()) {
stream_ << " (" << la->ToString() << ")";
} else if (lt != ConvertedType::NONE) {
Expand Down
12 changes: 7 additions & 5 deletions cpp/src/parquet/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PARQUET_EXPORT Node {
Node::type type_;
std::string name_;
Repetition::type repetition_;
ConvertedType::type converted_type_;
ConvertedType::type converted_type_{ConvertedType::NONE};
std::shared_ptr<const LogicalType> logical_type_;
int field_id_;
// Nodes should not be shared, they have a single parent.
Expand Down Expand Up @@ -280,7 +280,8 @@ class PARQUET_EXPORT GroupNode : public Node {
const NodeVector& fields,
std::shared_ptr<const LogicalType> logical_type,
int field_id = -1) {
return NodePtr(new GroupNode(name, repetition, fields, logical_type, field_id));
return NodePtr(
new GroupNode(name, repetition, fields, std::move(logical_type), field_id));
}

bool Equals(const Node* other) const override;
Expand Down Expand Up @@ -376,7 +377,7 @@ class PARQUET_EXPORT ColumnDescriptor {
ColumnOrder column_order() const { return primitive_node_->column_order(); }

SortOrder::type sort_order() const {
auto la = logical_type();
const auto& la = logical_type();
auto pt = physical_type();
return la ? GetSortOrder(la, pt) : GetSortOrder(converted_type(), pt);
}
Expand Down Expand Up @@ -416,8 +417,8 @@ class PARQUET_EXPORT ColumnDescriptor {
// TODO(wesm): this object can be recomputed from a Schema
class PARQUET_EXPORT SchemaDescriptor {
public:
SchemaDescriptor() {}
~SchemaDescriptor() {}
SchemaDescriptor() = default;
~SchemaDescriptor() = default;

// Analyze the schema
void Init(std::unique_ptr<schema::Node> schema);
Expand Down Expand Up @@ -464,6 +465,7 @@ class PARQUET_EXPORT SchemaDescriptor {
// Root Node
schema::NodePtr schema_;
// Root Node
// Would never be NULLPTR.
const schema::GroupNode* group_node_;

void BuildTree(const schema::NodePtr& node, int16_t max_def_level,
Expand Down

0 comments on commit 031497d

Please sign in to comment.