zeroshade commented on a change in pull request #10071: URL: https://github.com/apache/arrow/pull/10071#discussion_r617009627
########## File path: go/parquet/schema/column.go ########## @@ -0,0 +1,125 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "fmt" + "strings" + + "github.com/apache/arrow/go/parquet" + format "github.com/apache/arrow/go/parquet/internal/gen-go/parquet" +) + +// Column encapsulates the information necessary to interpret primitive +// column data in the context of a particular schema. We have to examine +// the node structure of a column's path to the root in the schema tree +// to be able to reassemble the nested structure from the repetition and +// definition levels. +type Column struct { + pnode *PrimitiveNode + maxDefLvl int16 + maxRepLvl int16 +} + +func (c *Column) hasSpacedValues() bool { + if c.maxRepLvl > 0 { + // repeated + flat case + return c.pnode.RepetitionType() != parquet.Repetitions.Required + } + + // non-repeated+nested case + // find if a node forces nulls in the lowest level along the hierarchy + var n Node = c.pnode + for n != nil { + if n.RepetitionType() == parquet.Repetitions.Optional { + return true + } + n = n.Parent() + } + return false +} + +// NewColumn returns a new column object for the given node with the provided +// maximum definition and repetition levels. +// +// n MUST be a PrimitiveNode, otherwise this will panic. +func NewColumn(n Node, maxDefinitionLvl, maxRepetitionLvl int16) *Column { + if n.Type() != Primitive { + panic("parquet: Column must be a primitive type") + } + return &Column{n.(*PrimitiveNode), maxDefinitionLvl, maxRepetitionLvl} +} + +// Name is the column's name +func (c *Column) Name() string { return c.pnode.Name() } + +// ColumnPath returns the full path to this column from the root of the schema +func (c *Column) ColumnPath() parquet.ColumnPath { return c.pnode.columnPath() } + +// Path is equivalent to ColumnPath().String() returning the dot-string version of the path +func (c *Column) Path() string { return c.pnode.Path() } + +// TypeLength is -1 if not a FixedLenByteArray, otherwise it is the length for the column Review comment: fixed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org