fields

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Type           string
	Name           string
	ColumnName     string
	RepetitionType RepetitionType
	Parent         *Field
	Children       []Field
	Embedded       bool
	NthChild       int
	Defined        bool
}

Field holds metadata that is required by parquetgen in order to generate code.

func Reverse

func Reverse(out []Field) []Field

func (Field) Category

func (f Field) Category() string

func (Field) Chain

func (f Field) Chain() []Field

func (Field) Child

func (f Field) Child(i int) Field

Child returns a sub-field based on i

func (Field) ColumnNames

func (f Field) ColumnNames() []string

func (Field) DefIndex

func (f Field) DefIndex(def int) int

DefIndex calculates the index of the nested field with the given definition level.

func (Field) FieldNames

func (f Field) FieldNames() []string

func (Field) FieldType

func (f Field) FieldType() string

func (Field) FieldTypes

func (f Field) FieldTypes() []string

func (Field) Fields

func (f Field) Fields() []Field

func (Field) Init

func (f Field) Init(def, rep int) string

Init is called by parquetgen's templates to generate the code that writes to a struct's field

example: x.Friend.Hobby = &Item{}

func (Field) IsRep

func (f Field) IsRep(rep int) bool

IsRep is true if this fields is one being repeated

func (Field) IsRoot

func (f Field) IsRoot() bool

func (Field) MaxDef

func (f Field) MaxDef() int

MaxDef cacluates the largest possible definition level for the nested field.

func (Field) MaxRep

func (f Field) MaxRep() int

MaxRep cacluates the largest possible repetition level for the nested field.

func (Field) MaxRepForDef

func (f Field) MaxRepForDef(def int) int

MaxRepForDef cacluates the largest possible repetition level for the nested field at the given definition level.

func (Field) NilField

func (f Field) NilField(n int) (string, RepetitionType, int, int)

NilField finds the nth field that is optional and returns some information about it.

func (Field) Optional

func (f Field) Optional() bool

Optional wraps RepetitionTypes.Optional()

func (Field) ParquetType

func (f Field) ParquetType() string

func (Field) Path

func (f Field) Path() string

Path creates gocode for initializing a string slice in a go template

func (Field) Primitive

func (f Field) Primitive() bool

func (Field) RepCases

func (f Field) RepCases(def int) RepCases

RepCases returns a RepCase slice based on the field types and what sub-fields have already been seen.

func (Field) Repeated

func (f Field) Repeated() bool

Repeated wraps RepetitionTypes.Repeated()

func (Field) RepetitionTypes

func (f Field) RepetitionTypes() RepetitionTypes

func (Field) Required

func (f Field) Required() bool

Required wraps RepetitionTypes.Required()

func (Field) StructType

func (f Field) StructType() string

func (Field) TypeName

func (f Field) TypeName() string

type RepCase

type RepCase struct {
	// Case is the code for a switch case (for example: case 0:)
	Reps []int
	// Rep is the repetition level that is handled by the switch case.
	Rep int

	// Repeated is true if any of the fields (including the one at the def level) were repeated
	// This allows the def case to not have a rep case for fields that have a repetition somewhere
	// in the chain.
	Repeated bool
}

RepCase is used by parquetgen to generate code.

func (RepCase) Case

func (r RepCase) Case() string

type RepCases

type RepCases []RepCase

func (RepCases) UseRepCase

func (r RepCases) UseRepCase(f Field, def int) bool

type RepetitionType

type RepetitionType int

RepetitionType is an enum of the possible parquet repetition types

const (
	Unseen   RepetitionType = -1
	Required RepetitionType = 0
	Optional RepetitionType = 1
	Repeated RepetitionType = 2
)

func (RepetitionType) Prefix

func (r RepetitionType) Prefix() string

type RepetitionTypes

type RepetitionTypes []RepetitionType

RepetitionTypes provides several functions used by parquetgen's go templates to generate code.

func (RepetitionTypes) Def

func (r RepetitionTypes) Def(def int) RepetitionType

Def returns the repetition type for the definition level

func (RepetitionTypes) MaxDef

func (r RepetitionTypes) MaxDef() uint8

MaxDef returns the largest definition level

func (RepetitionTypes) MaxRep

func (r RepetitionTypes) MaxRep() uint8

MaxRep returns the largest repetition level

func (RepetitionTypes) NRepeated

func (r RepetitionTypes) NRepeated(i int) bool

NRepeated figures out if the sub-field at position i is repeated.

func (RepetitionTypes) Optional

func (r RepetitionTypes) Optional() bool

Optional figures out if there is an optional field

func (RepetitionTypes) Repeated

func (r RepetitionTypes) Repeated() bool

Repeated figures out if there is a repeated field

func (RepetitionTypes) Required

func (r RepetitionTypes) Required() bool

Required figures out if there are no optional or repeated fields

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL