-
Notifications
You must be signed in to change notification settings - Fork 188
PARQUET-583: Parquet to Thrift schema conversion #87
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,10 @@ void PrimitiveNode::Visit(Node::Visitor* visitor) { | |
| visitor->Visit(this); | ||
| } | ||
|
|
||
| void PrimitiveNode::VisitConst(Node::ConstVisitor* visitor) const { | ||
| visitor->Visit(this); | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Group node | ||
|
|
||
|
|
@@ -232,6 +236,10 @@ void GroupNode::Visit(Node::Visitor* visitor) { | |
| visitor->Visit(this); | ||
| } | ||
|
|
||
| void GroupNode::VisitConst(Node::ConstVisitor* visitor) const { | ||
| visitor->Visit(this); | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Node construction from Parquet metadata | ||
|
|
||
|
|
@@ -280,6 +288,35 @@ std::unique_ptr<Node> PrimitiveNode::FromParquet(const void* opaque_element, | |
| return std::unique_ptr<Node>(result.release()); | ||
| } | ||
|
|
||
| void GroupNode::ToParquet(void* opaque_element) const { | ||
| format::SchemaElement* element = | ||
| static_cast<format::SchemaElement*>(opaque_element); | ||
| element->__set_name(name_); | ||
| element->__set_num_children(field_count()); | ||
| element->__set_repetition_type(ToThrift(repetition_)); | ||
| if (logical_type_ != LogicalType::NONE) { | ||
| element->__set_converted_type(ToThrift(logical_type_)); | ||
| } | ||
| // FIXME: SchemaFlattener does this for us: element->__set_field_id(id_); | ||
| } | ||
|
|
||
| void PrimitiveNode::ToParquet(void* opaque_element) const { | ||
| format::SchemaElement* element = | ||
| static_cast<format::SchemaElement*>(opaque_element); | ||
|
|
||
| element->__set_name(name_); | ||
| element->__set_num_children(0); | ||
| element->__set_repetition_type(ToThrift(repetition_)); | ||
| if (logical_type_ != LogicalType::NONE) { | ||
| element->__set_converted_type(ToThrift(logical_type_)); | ||
| } | ||
| element->__set_type(ToThrift(physical_type_)); | ||
| // FIXME: SchemaFlattener does this for us: element->__set_field_id(id_); | ||
| element->__set_type_length(type_length_); | ||
| element->__set_precision(decimal_metadata_.precision); | ||
| element->__set_scale(decimal_metadata_.scale); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only set these for DECIMAL annotation?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked any on
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| } // namespace schema | ||
|
|
||
| } // namespace parquet | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future cases, I believe it's OK to use
autoin conjunction withstatic_cast<const T*>