// 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 schemaimport ()// ListOf is a convenience helper function to create a properly structured// list structure according to the Parquet Spec.//// <list-repetition> group <name> (LIST) {// repeated group list {// <element-repetition> <element-type> element;// }// }//// <list-repetition> can only be optional or required.// <element-repetition> can only be optional or required.func ( Node, parquet.Repetition, int32) (*GroupNode, error) {returnListOfWithName(.Name(), , , )}// ListOf is a convenience helper function to create a properly structured// list structure according to the Parquet Spec.//// <list-repetition> group <name> (LIST) {// repeated group list {// <element-repetition> <element-type> element;// }// }//// <list-repetition> can only be optional or required.// <element-repetition> can only be optional or required.func ( string, Node, parquet.Repetition, int32) (*GroupNode, error) {if == parquet.Repetitions.Repeated {returnnil, xerrors.Errorf("parquet: listof repetition must not be repeated, got :%s", ) }if .RepetitionType() == parquet.Repetitions.Repeated {returnnil, xerrors.Errorf("parquet: element repetition must not be repeated, got: %s", .RepetitionType()) }switch n := .(type) {case *PrimitiveNode: .name = "element"case *GroupNode: .name = "element" } , := NewGroupNode("list"/* name */, parquet.Repetitions.Repeated, FieldList{}, -1/* fieldID */)if != nil {returnnil, }returnNewGroupNodeLogical(, , FieldList{}, ListLogicalType{}, )}// MapOf is a convenience helper function to create a properly structured// parquet map node setup according to the Parquet Spec.//// <map-repetition> group <name> (MAP) {// repeated group key_value {// required <key-type> key;// <value-repetition> <value-type> value;// }// }//// key node will be renamed to "key", value node if not nil will be renamed to "value"//// <map-repetition> must be only optional or required. panics if repeated is passed.//// the key node *must* be required repetition. panics if optional or repeated//// value node can be nil (omitted) or have a repetition of required or optional *only*.func ( string, Node, Node, parquet.Repetition, int32) (*GroupNode, error) {if == parquet.Repetitions.Repeated {returnnil, xerrors.Errorf("parquet: map repetition cannot be Repeated, got: %s", ) }if .RepetitionType() != parquet.Repetitions.Required {returnnil, xerrors.Errorf("parquet: map key repetition must be Required, got: %s", .RepetitionType()) }if != nil {if .RepetitionType() == parquet.Repetitions.Repeated {returnnil, xerrors.New("parquet: map value cannot have repetition Repeated") }switch value := .(type) {case *PrimitiveNode: .name = "value"case *GroupNode: .name = "value" } }switch key := .(type) {case *PrimitiveNode: .name = "key"case *GroupNode: .name = "key" } := FieldList{}if != nil { = append(, ) } , := NewGroupNode("key_value"/* name */, parquet.Repetitions.Repeated, , -1/* fieldID */)if != nil {returnnil, }returnNewGroupNodeLogical(, , FieldList{}, MapLogicalType{}, )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.