1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17// Code generated by the FlatBuffers compiler. DO NOT EDIT.
18
19package flatbuf
20
21import (
22	flatbuffers "github.com/google/flatbuffers/go"
23)
24
25/// ----------------------------------------------------------------------
26/// A field represents a named column in a record / row batch or child of a
27/// nested type.
28type Field struct {
29	_tab flatbuffers.Table
30}
31
32func GetRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field {
33	n := flatbuffers.GetUOffsetT(buf[offset:])
34	x := &Field{}
35	x.Init(buf, n+offset)
36	return x
37}
38
39func (rcv *Field) Init(buf []byte, i flatbuffers.UOffsetT) {
40	rcv._tab.Bytes = buf
41	rcv._tab.Pos = i
42}
43
44func (rcv *Field) Table() flatbuffers.Table {
45	return rcv._tab
46}
47
48/// Name is not required, in i.e. a List
49func (rcv *Field) Name() []byte {
50	o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
51	if o != 0 {
52		return rcv._tab.ByteVector(o + rcv._tab.Pos)
53	}
54	return nil
55}
56
57/// Name is not required, in i.e. a List
58/// Whether or not this field can contain nulls. Should be true in general.
59func (rcv *Field) Nullable() bool {
60	o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
61	if o != 0 {
62		return rcv._tab.GetBool(o + rcv._tab.Pos)
63	}
64	return false
65}
66
67/// Whether or not this field can contain nulls. Should be true in general.
68func (rcv *Field) MutateNullable(n bool) bool {
69	return rcv._tab.MutateBoolSlot(6, n)
70}
71
72func (rcv *Field) TypeType() Type {
73	o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
74	if o != 0 {
75		return Type(rcv._tab.GetByte(o + rcv._tab.Pos))
76	}
77	return 0
78}
79
80func (rcv *Field) MutateTypeType(n Type) bool {
81	return rcv._tab.MutateByteSlot(8, byte(n))
82}
83
84/// This is the type of the decoded value if the field is dictionary encoded.
85func (rcv *Field) Type(obj *flatbuffers.Table) bool {
86	o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
87	if o != 0 {
88		rcv._tab.Union(obj, o)
89		return true
90	}
91	return false
92}
93
94/// This is the type of the decoded value if the field is dictionary encoded.
95/// Present only if the field is dictionary encoded.
96func (rcv *Field) Dictionary(obj *DictionaryEncoding) *DictionaryEncoding {
97	o := flatbuffers.UOffsetT(rcv._tab.Offset(12))
98	if o != 0 {
99		x := rcv._tab.Indirect(o + rcv._tab.Pos)
100		if obj == nil {
101			obj = new(DictionaryEncoding)
102		}
103		obj.Init(rcv._tab.Bytes, x)
104		return obj
105	}
106	return nil
107}
108
109/// Present only if the field is dictionary encoded.
110/// children apply only to nested data types like Struct, List and Union. For
111/// primitive types children will have length 0.
112func (rcv *Field) Children(obj *Field, j int) bool {
113	o := flatbuffers.UOffsetT(rcv._tab.Offset(14))
114	if o != 0 {
115		x := rcv._tab.Vector(o)
116		x += flatbuffers.UOffsetT(j) * 4
117		x = rcv._tab.Indirect(x)
118		obj.Init(rcv._tab.Bytes, x)
119		return true
120	}
121	return false
122}
123
124func (rcv *Field) ChildrenLength() int {
125	o := flatbuffers.UOffsetT(rcv._tab.Offset(14))
126	if o != 0 {
127		return rcv._tab.VectorLen(o)
128	}
129	return 0
130}
131
132/// children apply only to nested data types like Struct, List and Union. For
133/// primitive types children will have length 0.
134/// User-defined metadata
135func (rcv *Field) CustomMetadata(obj *KeyValue, j int) bool {
136	o := flatbuffers.UOffsetT(rcv._tab.Offset(16))
137	if o != 0 {
138		x := rcv._tab.Vector(o)
139		x += flatbuffers.UOffsetT(j) * 4
140		x = rcv._tab.Indirect(x)
141		obj.Init(rcv._tab.Bytes, x)
142		return true
143	}
144	return false
145}
146
147func (rcv *Field) CustomMetadataLength() int {
148	o := flatbuffers.UOffsetT(rcv._tab.Offset(16))
149	if o != 0 {
150		return rcv._tab.VectorLen(o)
151	}
152	return 0
153}
154
155/// User-defined metadata
156func FieldStart(builder *flatbuffers.Builder) {
157	builder.StartObject(7)
158}
159func FieldAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) {
160	builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0)
161}
162func FieldAddNullable(builder *flatbuffers.Builder, nullable bool) {
163	builder.PrependBoolSlot(1, nullable, false)
164}
165func FieldAddTypeType(builder *flatbuffers.Builder, typeType Type) {
166	builder.PrependByteSlot(2, byte(typeType), 0)
167}
168func FieldAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) {
169	builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(type_), 0)
170}
171func FieldAddDictionary(builder *flatbuffers.Builder, dictionary flatbuffers.UOffsetT) {
172	builder.PrependUOffsetTSlot(4, flatbuffers.UOffsetT(dictionary), 0)
173}
174func FieldAddChildren(builder *flatbuffers.Builder, children flatbuffers.UOffsetT) {
175	builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(children), 0)
176}
177func FieldStartChildrenVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
178	return builder.StartVector(4, numElems, 4)
179}
180func FieldAddCustomMetadata(builder *flatbuffers.Builder, customMetadata flatbuffers.UOffsetT) {
181	builder.PrependUOffsetTSlot(6, flatbuffers.UOffsetT(customMetadata), 0)
182}
183func FieldStartCustomMetadataVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
184	return builder.StartVector(4, numElems, 4)
185}
186func FieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
187	return builder.EndObject()
188}
189