diff --git a/go/arrow/internal/flatbuf/Block.go b/go/arrow/internal/flatbuf/Block.go index 91727789828..57a697b1968 100644 --- a/go/arrow/internal/flatbuf/Block.go +++ b/go/arrow/internal/flatbuf/Block.go @@ -54,12 +54,12 @@ func (rcv *Block) MutateMetaDataLength(n int32) bool { } /// Length of the data (this is aligned so there can be a gap between this and -/// the metatdata). +/// the metadata). func (rcv *Block) BodyLength() int64 { return rcv._tab.GetInt64(rcv._tab.Pos + flatbuffers.UOffsetT(16)) } /// Length of the data (this is aligned so there can be a gap between this and -/// the metatdata). +/// the metadata). func (rcv *Block) MutateBodyLength(n int64) bool { return rcv._tab.MutateInt64(rcv._tab.Pos+flatbuffers.UOffsetT(16), n) } diff --git a/go/arrow/internal/flatbuf/BodyCompression.go b/go/arrow/internal/flatbuf/BodyCompression.go new file mode 100644 index 00000000000..a0efeb1ba9d --- /dev/null +++ b/go/arrow/internal/flatbuf/BodyCompression.go @@ -0,0 +1,87 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Optional compression for the memory buffers constituting IPC message +/// bodies. Intended for use with RecordBatch but could be used for other +/// message types +type BodyCompression struct { + _tab flatbuffers.Table +} + +func GetRootAsBodyCompression(buf []byte, offset flatbuffers.UOffsetT) *BodyCompression { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &BodyCompression{} + x.Init(buf, n+offset) + return x +} + +func (rcv *BodyCompression) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *BodyCompression) Table() flatbuffers.Table { + return rcv._tab +} + +/// Compressor library +func (rcv *BodyCompression) Codec() CompressionType { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return CompressionType(rcv._tab.GetInt8(o + rcv._tab.Pos)) + } + return 0 +} + +/// Compressor library +func (rcv *BodyCompression) MutateCodec(n CompressionType) bool { + return rcv._tab.MutateInt8Slot(4, int8(n)) +} + +/// Indicates the way the record batch body was compressed +func (rcv *BodyCompression) Method() BodyCompressionMethod { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return BodyCompressionMethod(rcv._tab.GetInt8(o + rcv._tab.Pos)) + } + return 0 +} + +/// Indicates the way the record batch body was compressed +func (rcv *BodyCompression) MutateMethod(n BodyCompressionMethod) bool { + return rcv._tab.MutateInt8Slot(6, int8(n)) +} + +func BodyCompressionStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func BodyCompressionAddCodec(builder *flatbuffers.Builder, codec CompressionType) { + builder.PrependInt8Slot(0, int8(codec), 0) +} +func BodyCompressionAddMethod(builder *flatbuffers.Builder, method BodyCompressionMethod) { + builder.PrependInt8Slot(1, int8(method), 0) +} +func BodyCompressionEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/BodyCompressionMethod.go b/go/arrow/internal/flatbuf/BodyCompressionMethod.go new file mode 100644 index 00000000000..108ab3e07fb --- /dev/null +++ b/go/arrow/internal/flatbuf/BodyCompressionMethod.go @@ -0,0 +1,52 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import "strconv" + +/// Provided for forward compatibility in case we need to support different +/// strategies for compressing the IPC message body (like whole-body +/// compression rather than buffer-level) in the future +type BodyCompressionMethod int8 + +const ( + /// Each constituent buffer is first compressed with the indicated + /// compressor, and then written with the uncompressed length in the first 8 + /// bytes as a 64-bit little-endian signed integer followed by the compressed + /// buffer bytes (and then padding as required by the protocol). The + /// uncompressed length may be set to -1 to indicate that the data that + /// follows is not compressed, which can be useful for cases where + /// compression does not yield appreciable savings. + BodyCompressionMethodBUFFER BodyCompressionMethod = 0 +) + +var EnumNamesBodyCompressionMethod = map[BodyCompressionMethod]string{ + BodyCompressionMethodBUFFER: "BUFFER", +} + +var EnumValuesBodyCompressionMethod = map[string]BodyCompressionMethod{ + "BUFFER": BodyCompressionMethodBUFFER, +} + +func (v BodyCompressionMethod) String() string { + if s, ok := EnumNamesBodyCompressionMethod[v]; ok { + return s + } + return "BodyCompressionMethod(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/CompressionType.go b/go/arrow/internal/flatbuf/CompressionType.go new file mode 100644 index 00000000000..96e9df0721c --- /dev/null +++ b/go/arrow/internal/flatbuf/CompressionType.go @@ -0,0 +1,45 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import "strconv" + +type CompressionType int8 + +const ( + CompressionTypeLZ4_FRAME CompressionType = 0 + CompressionTypeZSTD CompressionType = 1 +) + +var EnumNamesCompressionType = map[CompressionType]string{ + CompressionTypeLZ4_FRAME: "LZ4_FRAME", + CompressionTypeZSTD: "ZSTD", +} + +var EnumValuesCompressionType = map[string]CompressionType{ + "LZ4_FRAME": CompressionTypeLZ4_FRAME, + "ZSTD": CompressionTypeZSTD, +} + +func (v CompressionType) String() string { + if s, ok := EnumNamesCompressionType[v]; ok { + return s + } + return "CompressionType(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Date.go b/go/arrow/internal/flatbuf/Date.go index 476aa03ce7e..fc1913252aa 100644 --- a/go/arrow/internal/flatbuf/Date.go +++ b/go/arrow/internal/flatbuf/Date.go @@ -51,20 +51,20 @@ func (rcv *Date) Table() flatbuffers.Table { func (rcv *Date) Unit() DateUnit { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return DateUnit(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 1 } func (rcv *Date) MutateUnit(n DateUnit) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func DateStart(builder *flatbuffers.Builder) { builder.StartObject(1) } -func DateAddUnit(builder *flatbuffers.Builder, unit int16) { - builder.PrependInt16Slot(0, unit, 1) +func DateAddUnit(builder *flatbuffers.Builder, unit DateUnit) { + builder.PrependInt16Slot(0, int16(unit), 1) } func DateEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() diff --git a/go/arrow/internal/flatbuf/DateUnit.go b/go/arrow/internal/flatbuf/DateUnit.go index bb49f287e68..8a12eec175f 100644 --- a/go/arrow/internal/flatbuf/DateUnit.go +++ b/go/arrow/internal/flatbuf/DateUnit.go @@ -18,14 +18,28 @@ package flatbuf -type DateUnit = int16 +import "strconv" + +type DateUnit int16 + const ( - DateUnitDAY DateUnit = 0 + DateUnitDAY DateUnit = 0 DateUnitMILLISECOND DateUnit = 1 ) var EnumNamesDateUnit = map[DateUnit]string{ - DateUnitDAY:"DAY", - DateUnitMILLISECOND:"MILLISECOND", + DateUnitDAY: "DAY", + DateUnitMILLISECOND: "MILLISECOND", } +var EnumValuesDateUnit = map[string]DateUnit{ + "DAY": DateUnitDAY, + "MILLISECOND": DateUnitMILLISECOND, +} + +func (v DateUnit) String() string { + if s, ok := EnumNamesDateUnit[v]; ok { + return s + } + return "DateUnit(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Decimal.go b/go/arrow/internal/flatbuf/Decimal.go index a0a9b5019c5..c9de254d1dc 100644 --- a/go/arrow/internal/flatbuf/Decimal.go +++ b/go/arrow/internal/flatbuf/Decimal.go @@ -22,6 +22,10 @@ import ( flatbuffers "github.com/google/flatbuffers/go" ) +/// Exact decimal value represented as an integer value in two's +/// complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers +/// are used. The representation uses the endianness indicated +/// in the Schema. type Decimal struct { _tab flatbuffers.Table } @@ -70,8 +74,24 @@ func (rcv *Decimal) MutateScale(n int32) bool { return rcv._tab.MutateInt32Slot(6, n) } +/// Number of bits per value. The only accepted widths are 128 and 256. +/// We use bitWidth for consistency with Int::bitWidth. +func (rcv *Decimal) BitWidth() int32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.GetInt32(o + rcv._tab.Pos) + } + return 128 +} + +/// Number of bits per value. The only accepted widths are 128 and 256. +/// We use bitWidth for consistency with Int::bitWidth. +func (rcv *Decimal) MutateBitWidth(n int32) bool { + return rcv._tab.MutateInt32Slot(8, n) +} + func DecimalStart(builder *flatbuffers.Builder) { - builder.StartObject(2) + builder.StartObject(3) } func DecimalAddPrecision(builder *flatbuffers.Builder, precision int32) { builder.PrependInt32Slot(0, precision, 0) @@ -79,6 +99,9 @@ func DecimalAddPrecision(builder *flatbuffers.Builder, precision int32) { func DecimalAddScale(builder *flatbuffers.Builder, scale int32) { builder.PrependInt32Slot(1, scale, 0) } +func DecimalAddBitWidth(builder *flatbuffers.Builder, bitWidth int32) { + builder.PrependInt32Slot(2, bitWidth, 128) +} func DecimalEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/DictionaryBatch.go b/go/arrow/internal/flatbuf/DictionaryBatch.go index 1cd63106304..25b5384e46a 100644 --- a/go/arrow/internal/flatbuf/DictionaryBatch.go +++ b/go/arrow/internal/flatbuf/DictionaryBatch.go @@ -74,7 +74,8 @@ func (rcv *DictionaryBatch) Data(obj *RecordBatch) *RecordBatch { } /// If isDelta is true the values in the dictionary are to be appended to a -/// dictionary with the indicated id +/// dictionary with the indicated id. If isDelta is false this dictionary +/// should replace the existing dictionary. func (rcv *DictionaryBatch) IsDelta() bool { o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) if o != 0 { @@ -84,7 +85,8 @@ func (rcv *DictionaryBatch) IsDelta() bool { } /// If isDelta is true the values in the dictionary are to be appended to a -/// dictionary with the indicated id +/// dictionary with the indicated id. If isDelta is false this dictionary +/// should replace the existing dictionary. func (rcv *DictionaryBatch) MutateIsDelta(n bool) bool { return rcv._tab.MutateBoolSlot(8, n) } diff --git a/go/arrow/internal/flatbuf/DictionaryEncoding.go b/go/arrow/internal/flatbuf/DictionaryEncoding.go index 592b6fcf924..a9b09530b2a 100644 --- a/go/arrow/internal/flatbuf/DictionaryEncoding.go +++ b/go/arrow/internal/flatbuf/DictionaryEncoding.go @@ -22,8 +22,6 @@ import ( flatbuffers "github.com/google/flatbuffers/go" ) -/// ---------------------------------------------------------------------- -/// Dictionary encoding metadata type DictionaryEncoding struct { _tab flatbuffers.Table } @@ -62,8 +60,11 @@ func (rcv *DictionaryEncoding) MutateId(n int64) bool { return rcv._tab.MutateInt64Slot(4, n) } -/// The dictionary indices are constrained to be positive integers. If this -/// field is null, the indices must be signed int32 +/// The dictionary indices are constrained to be non-negative integers. If +/// this field is null, the indices must be signed int32. To maximize +/// cross-language compatibility and performance, implementations are +/// recommended to prefer signed integer types over unsigned integer types +/// and to avoid uint64 indices unless they are required by an application. func (rcv *DictionaryEncoding) IndexType(obj *Int) *Int { o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) if o != 0 { @@ -77,8 +78,11 @@ func (rcv *DictionaryEncoding) IndexType(obj *Int) *Int { return nil } -/// The dictionary indices are constrained to be positive integers. If this -/// field is null, the indices must be signed int32 +/// The dictionary indices are constrained to be non-negative integers. If +/// this field is null, the indices must be signed int32. To maximize +/// cross-language compatibility and performance, implementations are +/// recommended to prefer signed integer types over unsigned integer types +/// and to avoid uint64 indices unless they are required by an application. /// By default, dictionaries are not ordered, or the order does not have /// semantic meaning. In some statistical, applications, dictionary-encoding /// is used to represent ordered categorical data, and we provide a way to @@ -99,8 +103,20 @@ func (rcv *DictionaryEncoding) MutateIsOrdered(n bool) bool { return rcv._tab.MutateBoolSlot(8, n) } +func (rcv *DictionaryEncoding) DictionaryKind() DictionaryKind { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return DictionaryKind(rcv._tab.GetInt16(o + rcv._tab.Pos)) + } + return 0 +} + +func (rcv *DictionaryEncoding) MutateDictionaryKind(n DictionaryKind) bool { + return rcv._tab.MutateInt16Slot(10, int16(n)) +} + func DictionaryEncodingStart(builder *flatbuffers.Builder) { - builder.StartObject(3) + builder.StartObject(4) } func DictionaryEncodingAddId(builder *flatbuffers.Builder, id int64) { builder.PrependInt64Slot(0, id, 0) @@ -111,6 +127,9 @@ func DictionaryEncodingAddIndexType(builder *flatbuffers.Builder, indexType flat func DictionaryEncodingAddIsOrdered(builder *flatbuffers.Builder, isOrdered bool) { builder.PrependBoolSlot(2, isOrdered, false) } +func DictionaryEncodingAddDictionaryKind(builder *flatbuffers.Builder, dictionaryKind DictionaryKind) { + builder.PrependInt16Slot(3, int16(dictionaryKind), 0) +} func DictionaryEncodingEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/DictionaryKind.go b/go/arrow/internal/flatbuf/DictionaryKind.go new file mode 100644 index 00000000000..126ba5f7f6b --- /dev/null +++ b/go/arrow/internal/flatbuf/DictionaryKind.go @@ -0,0 +1,47 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import "strconv" + +/// ---------------------------------------------------------------------- +/// Dictionary encoding metadata +/// Maintained for forwards compatibility, in the future +/// Dictionaries might be explicit maps between integers and values +/// allowing for non-contiguous index values +type DictionaryKind int16 + +const ( + DictionaryKindDenseArray DictionaryKind = 0 +) + +var EnumNamesDictionaryKind = map[DictionaryKind]string{ + DictionaryKindDenseArray: "DenseArray", +} + +var EnumValuesDictionaryKind = map[string]DictionaryKind{ + "DenseArray": DictionaryKindDenseArray, +} + +func (v DictionaryKind) String() string { + if s, ok := EnumNamesDictionaryKind[v]; ok { + return s + } + return "DictionaryKind(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Duration.go b/go/arrow/internal/flatbuf/Duration.go index 4bb44d2ec03..57b7b2a037f 100644 --- a/go/arrow/internal/flatbuf/Duration.go +++ b/go/arrow/internal/flatbuf/Duration.go @@ -45,20 +45,20 @@ func (rcv *Duration) Table() flatbuffers.Table { func (rcv *Duration) Unit() TimeUnit { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return TimeUnit(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 1 } func (rcv *Duration) MutateUnit(n TimeUnit) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func DurationStart(builder *flatbuffers.Builder) { builder.StartObject(1) } -func DurationAddUnit(builder *flatbuffers.Builder, unit int16) { - builder.PrependInt16Slot(0, unit, 1) +func DurationAddUnit(builder *flatbuffers.Builder, unit TimeUnit) { + builder.PrependInt16Slot(0, int16(unit), 1) } func DurationEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() diff --git a/go/arrow/internal/flatbuf/Endianness.go b/go/arrow/internal/flatbuf/Endianness.go index 22e349e2798..cefa2ff9c06 100644 --- a/go/arrow/internal/flatbuf/Endianness.go +++ b/go/arrow/internal/flatbuf/Endianness.go @@ -18,16 +18,30 @@ package flatbuf +import "strconv" + /// ---------------------------------------------------------------------- /// Endianness of the platform producing the data -type Endianness = int16 +type Endianness int16 + const ( EndiannessLittle Endianness = 0 - EndiannessBig Endianness = 1 + EndiannessBig Endianness = 1 ) var EnumNamesEndianness = map[Endianness]string{ - EndiannessLittle:"Little", - EndiannessBig:"Big", + EndiannessLittle: "Little", + EndiannessBig: "Big", } +var EnumValuesEndianness = map[string]Endianness{ + "Little": EndiannessLittle, + "Big": EndiannessBig, +} + +func (v Endianness) String() string { + if s, ok := EnumNamesEndianness[v]; ok { + return s + } + return "Endianness(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Feature.go b/go/arrow/internal/flatbuf/Feature.go new file mode 100644 index 00000000000..ae5a0398b60 --- /dev/null +++ b/go/arrow/internal/flatbuf/Feature.go @@ -0,0 +1,71 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import "strconv" + +/// Represents Arrow Features that might not have full support +/// within implementations. This is intended to be used in +/// two scenarios: +/// 1. A mechanism for readers of Arrow Streams +/// and files to understand that the stream or file makes +/// use of a feature that isn't supported or unknown to +/// the implementation (and therefore can meet the Arrow +/// forward compatibility guarantees). +/// 2. A means of negotiating between a client and server +/// what features a stream is allowed to use. The enums +/// values here are intented to represent higher level +/// features, additional details maybe negotiated +/// with key-value pairs specific to the protocol. +/// +/// Enums added to this list should be assigned power-of-two values +/// to facilitate exchanging and comparing bitmaps for supported +/// features. +type Feature int64 + +const ( + /// Needed to make flatbuffers happy. + FeatureUNUSED Feature = 0 + /// The stream makes use of multiple full dictionaries with the + /// same ID and assumes clients implement dictionary replacement + /// correctly. + FeatureDICTIONARY_REPLACEMENT Feature = 1 + /// The stream makes use of compressed bodies as described + /// in Message.fbs. + FeatureCOMPRESSED_BODY Feature = 2 +) + +var EnumNamesFeature = map[Feature]string{ + FeatureUNUSED: "UNUSED", + FeatureDICTIONARY_REPLACEMENT: "DICTIONARY_REPLACEMENT", + FeatureCOMPRESSED_BODY: "COMPRESSED_BODY", +} + +var EnumValuesFeature = map[string]Feature{ + "UNUSED": FeatureUNUSED, + "DICTIONARY_REPLACEMENT": FeatureDICTIONARY_REPLACEMENT, + "COMPRESSED_BODY": FeatureCOMPRESSED_BODY, +} + +func (v Feature) String() string { + if s, ok := EnumNamesFeature[v]; ok { + return s + } + return "Feature(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Field.go b/go/arrow/internal/flatbuf/Field.go index d63df246b71..c03cf2f878b 100644 --- a/go/arrow/internal/flatbuf/Field.go +++ b/go/arrow/internal/flatbuf/Field.go @@ -69,16 +69,16 @@ func (rcv *Field) MutateNullable(n bool) bool { return rcv._tab.MutateBoolSlot(6, n) } -func (rcv *Field) TypeType() byte { +func (rcv *Field) TypeType() Type { o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) + return Type(rcv._tab.GetByte(o + rcv._tab.Pos)) } return 0 } -func (rcv *Field) MutateTypeType(n byte) bool { - return rcv._tab.MutateByteSlot(8, n) +func (rcv *Field) MutateTypeType(n Type) bool { + return rcv._tab.MutateByteSlot(8, byte(n)) } /// This is the type of the decoded value if the field is dictionary encoded. @@ -162,8 +162,8 @@ func FieldAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { func FieldAddNullable(builder *flatbuffers.Builder, nullable bool) { builder.PrependBoolSlot(1, nullable, false) } -func FieldAddTypeType(builder *flatbuffers.Builder, typeType byte) { - builder.PrependByteSlot(2, typeType, 0) +func FieldAddTypeType(builder *flatbuffers.Builder, typeType Type) { + builder.PrependByteSlot(2, byte(typeType), 0) } func FieldAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(type_), 0) diff --git a/go/arrow/internal/flatbuf/FieldNode.go b/go/arrow/internal/flatbuf/FieldNode.go index b8d711540ab..606b30bfebb 100644 --- a/go/arrow/internal/flatbuf/FieldNode.go +++ b/go/arrow/internal/flatbuf/FieldNode.go @@ -28,7 +28,7 @@ import ( /// Metadata about a field at some level of a nested type tree (but not /// its children). /// -/// For example, a List with values [[1, 2, 3], null, [4], [5, 6], null] +/// For example, a List with values `[[1, 2, 3], null, [4], [5, 6], null]` /// would have {length: 5, null_count: 2} for its List node, and {length: 6, /// null_count: 0} for its Int16 node, as separate FieldNode structs type FieldNode struct { diff --git a/go/arrow/internal/flatbuf/FloatingPoint.go b/go/arrow/internal/flatbuf/FloatingPoint.go index 975a52dbe0a..241d448dcf9 100644 --- a/go/arrow/internal/flatbuf/FloatingPoint.go +++ b/go/arrow/internal/flatbuf/FloatingPoint.go @@ -45,20 +45,20 @@ func (rcv *FloatingPoint) Table() flatbuffers.Table { func (rcv *FloatingPoint) Precision() Precision { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return Precision(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *FloatingPoint) MutatePrecision(n Precision) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func FloatingPointStart(builder *flatbuffers.Builder) { builder.StartObject(1) } -func FloatingPointAddPrecision(builder *flatbuffers.Builder, precision int16) { - builder.PrependInt16Slot(0, precision, 0) +func FloatingPointAddPrecision(builder *flatbuffers.Builder, precision Precision) { + builder.PrependInt16Slot(0, int16(precision), 0) } func FloatingPointEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() diff --git a/go/arrow/internal/flatbuf/Footer.go b/go/arrow/internal/flatbuf/Footer.go index 6802e77c032..65b0ff09546 100644 --- a/go/arrow/internal/flatbuf/Footer.go +++ b/go/arrow/internal/flatbuf/Footer.go @@ -48,13 +48,13 @@ func (rcv *Footer) Table() flatbuffers.Table { func (rcv *Footer) Version() MetadataVersion { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return MetadataVersion(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *Footer) MutateVersion(n MetadataVersion) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func (rcv *Footer) Schema(obj *Schema) *Schema { @@ -108,11 +108,33 @@ func (rcv *Footer) RecordBatchesLength() int { return 0 } +/// User-defined metadata +func (rcv *Footer) CustomMetadata(obj *KeyValue, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Footer) CustomMetadataLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +/// User-defined metadata func FooterStart(builder *flatbuffers.Builder) { - builder.StartObject(4) + builder.StartObject(5) } -func FooterAddVersion(builder *flatbuffers.Builder, version int16) { - builder.PrependInt16Slot(0, version, 0) +func FooterAddVersion(builder *flatbuffers.Builder, version MetadataVersion) { + builder.PrependInt16Slot(0, int16(version), 0) } func FooterAddSchema(builder *flatbuffers.Builder, schema flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(schema), 0) @@ -129,6 +151,12 @@ func FooterAddRecordBatches(builder *flatbuffers.Builder, recordBatches flatbuff func FooterStartRecordBatchesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { return builder.StartVector(24, numElems, 8) } +func FooterAddCustomMetadata(builder *flatbuffers.Builder, customMetadata flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(4, flatbuffers.UOffsetT(customMetadata), 0) +} +func FooterStartCustomMetadataVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} func FooterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/Interval.go b/go/arrow/internal/flatbuf/Interval.go index 21970ef1080..12c56d5c210 100644 --- a/go/arrow/internal/flatbuf/Interval.go +++ b/go/arrow/internal/flatbuf/Interval.go @@ -45,20 +45,20 @@ func (rcv *Interval) Table() flatbuffers.Table { func (rcv *Interval) Unit() IntervalUnit { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return IntervalUnit(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *Interval) MutateUnit(n IntervalUnit) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func IntervalStart(builder *flatbuffers.Builder) { builder.StartObject(1) } -func IntervalAddUnit(builder *flatbuffers.Builder, unit int16) { - builder.PrependInt16Slot(0, unit, 0) +func IntervalAddUnit(builder *flatbuffers.Builder, unit IntervalUnit) { + builder.PrependInt16Slot(0, int16(unit), 0) } func IntervalEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() diff --git a/go/arrow/internal/flatbuf/IntervalUnit.go b/go/arrow/internal/flatbuf/IntervalUnit.go index 62baea99117..5c6aeec3e79 100644 --- a/go/arrow/internal/flatbuf/IntervalUnit.go +++ b/go/arrow/internal/flatbuf/IntervalUnit.go @@ -18,14 +18,28 @@ package flatbuf -type IntervalUnit = int16 +import "strconv" + +type IntervalUnit int16 + const ( IntervalUnitYEAR_MONTH IntervalUnit = 0 - IntervalUnitDAY_TIME IntervalUnit = 1 + IntervalUnitDAY_TIME IntervalUnit = 1 ) var EnumNamesIntervalUnit = map[IntervalUnit]string{ - IntervalUnitYEAR_MONTH:"YEAR_MONTH", - IntervalUnitDAY_TIME:"DAY_TIME", + IntervalUnitYEAR_MONTH: "YEAR_MONTH", + IntervalUnitDAY_TIME: "DAY_TIME", } +var EnumValuesIntervalUnit = map[string]IntervalUnit{ + "YEAR_MONTH": IntervalUnitYEAR_MONTH, + "DAY_TIME": IntervalUnitDAY_TIME, +} + +func (v IntervalUnit) String() string { + if s, ok := EnumNamesIntervalUnit[v]; ok { + return s + } + return "IntervalUnit(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/LargeBinary.go b/go/arrow/internal/flatbuf/LargeBinary.go new file mode 100644 index 00000000000..2c3befcc16f --- /dev/null +++ b/go/arrow/internal/flatbuf/LargeBinary.go @@ -0,0 +1,52 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Same as Binary, but with 64-bit offsets, allowing to represent +/// extremely large data values. +type LargeBinary struct { + _tab flatbuffers.Table +} + +func GetRootAsLargeBinary(buf []byte, offset flatbuffers.UOffsetT) *LargeBinary { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &LargeBinary{} + x.Init(buf, n+offset) + return x +} + +func (rcv *LargeBinary) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *LargeBinary) Table() flatbuffers.Table { + return rcv._tab +} + +func LargeBinaryStart(builder *flatbuffers.Builder) { + builder.StartObject(0) +} +func LargeBinaryEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/LargeList.go b/go/arrow/internal/flatbuf/LargeList.go new file mode 100644 index 00000000000..92f22845874 --- /dev/null +++ b/go/arrow/internal/flatbuf/LargeList.go @@ -0,0 +1,52 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Same as List, but with 64-bit offsets, allowing to represent +/// extremely large data values. +type LargeList struct { + _tab flatbuffers.Table +} + +func GetRootAsLargeList(buf []byte, offset flatbuffers.UOffsetT) *LargeList { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &LargeList{} + x.Init(buf, n+offset) + return x +} + +func (rcv *LargeList) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *LargeList) Table() flatbuffers.Table { + return rcv._tab +} + +func LargeListStart(builder *flatbuffers.Builder) { + builder.StartObject(0) +} +func LargeListEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/LargeUtf8.go b/go/arrow/internal/flatbuf/LargeUtf8.go new file mode 100644 index 00000000000..e78b33e1100 --- /dev/null +++ b/go/arrow/internal/flatbuf/LargeUtf8.go @@ -0,0 +1,52 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Same as Utf8, but with 64-bit offsets, allowing to represent +/// extremely large data values. +type LargeUtf8 struct { + _tab flatbuffers.Table +} + +func GetRootAsLargeUtf8(buf []byte, offset flatbuffers.UOffsetT) *LargeUtf8 { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &LargeUtf8{} + x.Init(buf, n+offset) + return x +} + +func (rcv *LargeUtf8) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *LargeUtf8) Table() flatbuffers.Table { + return rcv._tab +} + +func LargeUtf8Start(builder *flatbuffers.Builder) { + builder.StartObject(0) +} +func LargeUtf8End(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/Map.go b/go/arrow/internal/flatbuf/Map.go index d540fc75703..8802aba1ebd 100644 --- a/go/arrow/internal/flatbuf/Map.go +++ b/go/arrow/internal/flatbuf/Map.go @@ -37,10 +37,11 @@ import ( /// not enforced. /// /// Map +/// ```text /// - child[0] entries: Struct /// - child[0] key: K /// - child[1] value: V -/// +/// ``` /// Neither the "entries" field nor the "key" field may be nullable. /// /// The metadata is structured so that Arrow systems without special handling diff --git a/go/arrow/internal/flatbuf/Message.go b/go/arrow/internal/flatbuf/Message.go index 76fcc389d1d..f4b4a0ff80e 100644 --- a/go/arrow/internal/flatbuf/Message.go +++ b/go/arrow/internal/flatbuf/Message.go @@ -45,25 +45,25 @@ func (rcv *Message) Table() flatbuffers.Table { func (rcv *Message) Version() MetadataVersion { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return MetadataVersion(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *Message) MutateVersion(n MetadataVersion) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } -func (rcv *Message) HeaderType() byte { +func (rcv *Message) HeaderType() MessageHeader { o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) + return MessageHeader(rcv._tab.GetByte(o + rcv._tab.Pos)) } return 0 } -func (rcv *Message) MutateHeaderType(n byte) bool { - return rcv._tab.MutateByteSlot(6, n) +func (rcv *Message) MutateHeaderType(n MessageHeader) bool { + return rcv._tab.MutateByteSlot(6, byte(n)) } func (rcv *Message) Header(obj *flatbuffers.Table) bool { @@ -110,11 +110,11 @@ func (rcv *Message) CustomMetadataLength() int { func MessageStart(builder *flatbuffers.Builder) { builder.StartObject(5) } -func MessageAddVersion(builder *flatbuffers.Builder, version int16) { - builder.PrependInt16Slot(0, version, 0) +func MessageAddVersion(builder *flatbuffers.Builder, version MetadataVersion) { + builder.PrependInt16Slot(0, int16(version), 0) } -func MessageAddHeaderType(builder *flatbuffers.Builder, headerType byte) { - builder.PrependByteSlot(1, headerType, 0) +func MessageAddHeaderType(builder *flatbuffers.Builder, headerType MessageHeader) { + builder.PrependByteSlot(1, byte(headerType), 0) } func MessageAddHeader(builder *flatbuffers.Builder, header flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(header), 0) diff --git a/go/arrow/internal/flatbuf/MessageHeader.go b/go/arrow/internal/flatbuf/MessageHeader.go index 18730bed59f..c12fc105811 100644 --- a/go/arrow/internal/flatbuf/MessageHeader.go +++ b/go/arrow/internal/flatbuf/MessageHeader.go @@ -18,6 +18,8 @@ package flatbuf +import "strconv" + /// ---------------------------------------------------------------------- /// The root Message type /// This union enables us to easily send different message types without @@ -26,22 +28,38 @@ package flatbuf /// Arrow implementations do not need to implement all of the message types, /// which may include experimental metadata types. For maximum compatibility, /// it is best to send data using RecordBatch -type MessageHeader = byte +type MessageHeader byte + const ( - MessageHeaderNONE MessageHeader = 0 - MessageHeaderSchema MessageHeader = 1 + MessageHeaderNONE MessageHeader = 0 + MessageHeaderSchema MessageHeader = 1 MessageHeaderDictionaryBatch MessageHeader = 2 - MessageHeaderRecordBatch MessageHeader = 3 - MessageHeaderTensor MessageHeader = 4 - MessageHeaderSparseTensor MessageHeader = 5 + MessageHeaderRecordBatch MessageHeader = 3 + MessageHeaderTensor MessageHeader = 4 + MessageHeaderSparseTensor MessageHeader = 5 ) var EnumNamesMessageHeader = map[MessageHeader]string{ - MessageHeaderNONE:"NONE", - MessageHeaderSchema:"Schema", - MessageHeaderDictionaryBatch:"DictionaryBatch", - MessageHeaderRecordBatch:"RecordBatch", - MessageHeaderTensor:"Tensor", - MessageHeaderSparseTensor:"SparseTensor", + MessageHeaderNONE: "NONE", + MessageHeaderSchema: "Schema", + MessageHeaderDictionaryBatch: "DictionaryBatch", + MessageHeaderRecordBatch: "RecordBatch", + MessageHeaderTensor: "Tensor", + MessageHeaderSparseTensor: "SparseTensor", } +var EnumValuesMessageHeader = map[string]MessageHeader{ + "NONE": MessageHeaderNONE, + "Schema": MessageHeaderSchema, + "DictionaryBatch": MessageHeaderDictionaryBatch, + "RecordBatch": MessageHeaderRecordBatch, + "Tensor": MessageHeaderTensor, + "SparseTensor": MessageHeaderSparseTensor, +} + +func (v MessageHeader) String() string { + if s, ok := EnumNamesMessageHeader[v]; ok { + return s + } + return "MessageHeader(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/MetadataVersion.go b/go/arrow/internal/flatbuf/MetadataVersion.go index 0094430c750..21b234f9c2b 100644 --- a/go/arrow/internal/flatbuf/MetadataVersion.go +++ b/go/arrow/internal/flatbuf/MetadataVersion.go @@ -18,22 +18,48 @@ package flatbuf -type MetadataVersion = int16 +import "strconv" + +type MetadataVersion int16 + const ( - /// 0.1.0 + /// 0.1.0 (October 2016). MetadataVersionV1 MetadataVersion = 0 - /// 0.2.0 + /// 0.2.0 (February 2017). Non-backwards compatible with V1. MetadataVersionV2 MetadataVersion = 1 - /// 0.3.0 -> 0.7.1 + /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. MetadataVersionV3 MetadataVersion = 2 - /// >= 0.8.0 + /// >= 0.8.0 (December 2017). Non-backwards compatible with V3. MetadataVersionV4 MetadataVersion = 3 + /// >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4 + /// metadata and IPC messages). Implementations are recommended to provide a + /// V4 compatibility mode with V5 format changes disabled. + /// + /// Incompatible changes between V4 and V5: + /// - Union buffer layout has changed. In V5, Unions don't have a validity + /// bitmap buffer. + MetadataVersionV5 MetadataVersion = 4 ) var EnumNamesMetadataVersion = map[MetadataVersion]string{ - MetadataVersionV1:"V1", - MetadataVersionV2:"V2", - MetadataVersionV3:"V3", - MetadataVersionV4:"V4", + MetadataVersionV1: "V1", + MetadataVersionV2: "V2", + MetadataVersionV3: "V3", + MetadataVersionV4: "V4", + MetadataVersionV5: "V5", } +var EnumValuesMetadataVersion = map[string]MetadataVersion{ + "V1": MetadataVersionV1, + "V2": MetadataVersionV2, + "V3": MetadataVersionV3, + "V4": MetadataVersionV4, + "V5": MetadataVersionV5, +} + +func (v MetadataVersion) String() string { + if s, ok := EnumNamesMetadataVersion[v]; ok { + return s + } + return "MetadataVersion(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Precision.go b/go/arrow/internal/flatbuf/Precision.go index 417d1e788e8..d8021ccc443 100644 --- a/go/arrow/internal/flatbuf/Precision.go +++ b/go/arrow/internal/flatbuf/Precision.go @@ -18,16 +18,31 @@ package flatbuf -type Precision = int16 +import "strconv" + +type Precision int16 + const ( - PrecisionHALF Precision = 0 + PrecisionHALF Precision = 0 PrecisionSINGLE Precision = 1 PrecisionDOUBLE Precision = 2 ) var EnumNamesPrecision = map[Precision]string{ - PrecisionHALF:"HALF", - PrecisionSINGLE:"SINGLE", - PrecisionDOUBLE:"DOUBLE", + PrecisionHALF: "HALF", + PrecisionSINGLE: "SINGLE", + PrecisionDOUBLE: "DOUBLE", } +var EnumValuesPrecision = map[string]Precision{ + "HALF": PrecisionHALF, + "SINGLE": PrecisionSINGLE, + "DOUBLE": PrecisionDOUBLE, +} + +func (v Precision) String() string { + if s, ok := EnumNamesPrecision[v]; ok { + return s + } + return "Precision(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/RecordBatch.go b/go/arrow/internal/flatbuf/RecordBatch.go index b997bdf16c7..bb6aca9a061 100644 --- a/go/arrow/internal/flatbuf/RecordBatch.go +++ b/go/arrow/internal/flatbuf/RecordBatch.go @@ -113,8 +113,23 @@ func (rcv *RecordBatch) BuffersLength() int { /// example, most primitive arrays will have 2 buffers, 1 for the validity /// bitmap and 1 for the values. For struct arrays, there will only be a /// single buffer for the validity (nulls) bitmap +/// Optional compression of the message body +func (rcv *RecordBatch) Compression(obj *BodyCompression) *BodyCompression { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + x := rcv._tab.Indirect(o + rcv._tab.Pos) + if obj == nil { + obj = new(BodyCompression) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// Optional compression of the message body func RecordBatchStart(builder *flatbuffers.Builder) { - builder.StartObject(3) + builder.StartObject(4) } func RecordBatchAddLength(builder *flatbuffers.Builder, length int64) { builder.PrependInt64Slot(0, length, 0) @@ -131,6 +146,9 @@ func RecordBatchAddBuffers(builder *flatbuffers.Builder, buffers flatbuffers.UOf func RecordBatchStartBuffersVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { return builder.StartVector(16, numElems, 8) } +func RecordBatchAddCompression(builder *flatbuffers.Builder, compression flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(compression), 0) +} func RecordBatchEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/Schema.go b/go/arrow/internal/flatbuf/Schema.go index d3e27373b2e..4ee5ecc9e5e 100644 --- a/go/arrow/internal/flatbuf/Schema.go +++ b/go/arrow/internal/flatbuf/Schema.go @@ -50,7 +50,7 @@ func (rcv *Schema) Table() flatbuffers.Table { func (rcv *Schema) Endianness() Endianness { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return Endianness(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } @@ -59,7 +59,7 @@ func (rcv *Schema) Endianness() Endianness { /// it is Little Endian by default /// if endianness doesn't match the underlying system then the vectors need to be converted func (rcv *Schema) MutateEndianness(n Endianness) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func (rcv *Schema) Fields(obj *Field, j int) bool { @@ -102,11 +102,39 @@ func (rcv *Schema) CustomMetadataLength() int { return 0 } +/// Features used in the stream/file. +func (rcv *Schema) Features(j int) Feature { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + a := rcv._tab.Vector(o) + return Feature(rcv._tab.GetInt64(a + flatbuffers.UOffsetT(j*8))) + } + return 0 +} + +func (rcv *Schema) FeaturesLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +/// Features used in the stream/file. +func (rcv *Schema) MutateFeatures(j int, n Feature) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateInt64(a+flatbuffers.UOffsetT(j*8), int64(n)) + } + return false +} + func SchemaStart(builder *flatbuffers.Builder) { - builder.StartObject(3) + builder.StartObject(4) } -func SchemaAddEndianness(builder *flatbuffers.Builder, endianness int16) { - builder.PrependInt16Slot(0, endianness, 0) +func SchemaAddEndianness(builder *flatbuffers.Builder, endianness Endianness) { + builder.PrependInt16Slot(0, int16(endianness), 0) } func SchemaAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(fields), 0) @@ -120,6 +148,12 @@ func SchemaAddCustomMetadata(builder *flatbuffers.Builder, customMetadata flatbu func SchemaStartCustomMetadataVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { return builder.StartVector(4, numElems, 4) } +func SchemaAddFeatures(builder *flatbuffers.Builder, features flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(features), 0) +} +func SchemaStartFeaturesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(8, numElems, 8) +} func SchemaEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/SparseMatrixCompressedAxis.go b/go/arrow/internal/flatbuf/SparseMatrixCompressedAxis.go new file mode 100644 index 00000000000..2d86fdef785 --- /dev/null +++ b/go/arrow/internal/flatbuf/SparseMatrixCompressedAxis.go @@ -0,0 +1,45 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import "strconv" + +type SparseMatrixCompressedAxis int16 + +const ( + SparseMatrixCompressedAxisRow SparseMatrixCompressedAxis = 0 + SparseMatrixCompressedAxisColumn SparseMatrixCompressedAxis = 1 +) + +var EnumNamesSparseMatrixCompressedAxis = map[SparseMatrixCompressedAxis]string{ + SparseMatrixCompressedAxisRow: "Row", + SparseMatrixCompressedAxisColumn: "Column", +} + +var EnumValuesSparseMatrixCompressedAxis = map[string]SparseMatrixCompressedAxis{ + "Row": SparseMatrixCompressedAxisRow, + "Column": SparseMatrixCompressedAxisColumn, +} + +func (v SparseMatrixCompressedAxis) String() string { + if s, ok := EnumNamesSparseMatrixCompressedAxis[v]; ok { + return s + } + return "SparseMatrixCompressedAxis(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/SparseMatrixIndexCSX.go b/go/arrow/internal/flatbuf/SparseMatrixIndexCSX.go new file mode 100644 index 00000000000..c28cc5d082f --- /dev/null +++ b/go/arrow/internal/flatbuf/SparseMatrixIndexCSX.go @@ -0,0 +1,200 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Compressed Sparse format, that is matrix-specific. +type SparseMatrixIndexCSX struct { + _tab flatbuffers.Table +} + +func GetRootAsSparseMatrixIndexCSX(buf []byte, offset flatbuffers.UOffsetT) *SparseMatrixIndexCSX { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &SparseMatrixIndexCSX{} + x.Init(buf, n+offset) + return x +} + +func (rcv *SparseMatrixIndexCSX) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *SparseMatrixIndexCSX) Table() flatbuffers.Table { + return rcv._tab +} + +/// Which axis, row or column, is compressed +func (rcv *SparseMatrixIndexCSX) CompressedAxis() SparseMatrixCompressedAxis { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return SparseMatrixCompressedAxis(rcv._tab.GetInt16(o + rcv._tab.Pos)) + } + return 0 +} + +/// Which axis, row or column, is compressed +func (rcv *SparseMatrixIndexCSX) MutateCompressedAxis(n SparseMatrixCompressedAxis) bool { + return rcv._tab.MutateInt16Slot(4, int16(n)) +} + +/// The type of values in indptrBuffer +func (rcv *SparseMatrixIndexCSX) IndptrType(obj *Int) *Int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + x := rcv._tab.Indirect(o + rcv._tab.Pos) + if obj == nil { + obj = new(Int) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// The type of values in indptrBuffer +/// indptrBuffer stores the location and size of indptr array that +/// represents the range of the rows. +/// The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data. +/// The length of this array is 1 + (the number of rows), and the type +/// of index value is long. +/// +/// For example, let X be the following 6x4 matrix: +/// ```text +/// X := [[0, 1, 2, 0], +/// [0, 0, 3, 0], +/// [0, 4, 0, 5], +/// [0, 0, 0, 0], +/// [6, 0, 7, 8], +/// [0, 9, 0, 0]]. +/// ``` +/// The array of non-zero values in X is: +/// ```text +/// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. +/// ``` +/// And the indptr of X is: +/// ```text +/// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. +/// ``` +func (rcv *SparseMatrixIndexCSX) IndptrBuffer(obj *Buffer) *Buffer { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + x := o + rcv._tab.Pos + if obj == nil { + obj = new(Buffer) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// indptrBuffer stores the location and size of indptr array that +/// represents the range of the rows. +/// The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data. +/// The length of this array is 1 + (the number of rows), and the type +/// of index value is long. +/// +/// For example, let X be the following 6x4 matrix: +/// ```text +/// X := [[0, 1, 2, 0], +/// [0, 0, 3, 0], +/// [0, 4, 0, 5], +/// [0, 0, 0, 0], +/// [6, 0, 7, 8], +/// [0, 9, 0, 0]]. +/// ``` +/// The array of non-zero values in X is: +/// ```text +/// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9]. +/// ``` +/// And the indptr of X is: +/// ```text +/// indptr(X) = [0, 2, 3, 5, 5, 8, 10]. +/// ``` +/// The type of values in indicesBuffer +func (rcv *SparseMatrixIndexCSX) IndicesType(obj *Int) *Int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + x := rcv._tab.Indirect(o + rcv._tab.Pos) + if obj == nil { + obj = new(Int) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// The type of values in indicesBuffer +/// indicesBuffer stores the location and size of the array that +/// contains the column indices of the corresponding non-zero values. +/// The type of index value is long. +/// +/// For example, the indices of the above X is: +/// ```text +/// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. +/// ``` +/// Note that the indices are sorted in lexicographical order for each row. +func (rcv *SparseMatrixIndexCSX) IndicesBuffer(obj *Buffer) *Buffer { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + x := o + rcv._tab.Pos + if obj == nil { + obj = new(Buffer) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// indicesBuffer stores the location and size of the array that +/// contains the column indices of the corresponding non-zero values. +/// The type of index value is long. +/// +/// For example, the indices of the above X is: +/// ```text +/// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1]. +/// ``` +/// Note that the indices are sorted in lexicographical order for each row. +func SparseMatrixIndexCSXStart(builder *flatbuffers.Builder) { + builder.StartObject(5) +} +func SparseMatrixIndexCSXAddCompressedAxis(builder *flatbuffers.Builder, compressedAxis SparseMatrixCompressedAxis) { + builder.PrependInt16Slot(0, int16(compressedAxis), 0) +} +func SparseMatrixIndexCSXAddIndptrType(builder *flatbuffers.Builder, indptrType flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(indptrType), 0) +} +func SparseMatrixIndexCSXAddIndptrBuffer(builder *flatbuffers.Builder, indptrBuffer flatbuffers.UOffsetT) { + builder.PrependStructSlot(2, flatbuffers.UOffsetT(indptrBuffer), 0) +} +func SparseMatrixIndexCSXAddIndicesType(builder *flatbuffers.Builder, indicesType flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(indicesType), 0) +} +func SparseMatrixIndexCSXAddIndicesBuffer(builder *flatbuffers.Builder, indicesBuffer flatbuffers.UOffsetT) { + builder.PrependStructSlot(4, flatbuffers.UOffsetT(indicesBuffer), 0) +} +func SparseMatrixIndexCSXEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/SparseTensor.go b/go/arrow/internal/flatbuf/SparseTensor.go index 389832b95a1..6f3f55797d7 100644 --- a/go/arrow/internal/flatbuf/SparseTensor.go +++ b/go/arrow/internal/flatbuf/SparseTensor.go @@ -42,16 +42,16 @@ func (rcv *SparseTensor) Table() flatbuffers.Table { return rcv._tab } -func (rcv *SparseTensor) TypeType() byte { +func (rcv *SparseTensor) TypeType() Type { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) + return Type(rcv._tab.GetByte(o + rcv._tab.Pos)) } return 0 } -func (rcv *SparseTensor) MutateTypeType(n byte) bool { - return rcv._tab.MutateByteSlot(4, n) +func (rcv *SparseTensor) MutateTypeType(n Type) bool { + return rcv._tab.MutateByteSlot(4, byte(n)) } /// The type of data contained in a value cell. @@ -105,16 +105,16 @@ func (rcv *SparseTensor) MutateNonZeroLength(n int64) bool { return rcv._tab.MutateInt64Slot(10, n) } -func (rcv *SparseTensor) SparseIndexType() byte { +func (rcv *SparseTensor) SparseIndexType() SparseTensorIndex { o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) + return SparseTensorIndex(rcv._tab.GetByte(o + rcv._tab.Pos)) } return 0 } -func (rcv *SparseTensor) MutateSparseIndexType(n byte) bool { - return rcv._tab.MutateByteSlot(12, n) +func (rcv *SparseTensor) MutateSparseIndexType(n SparseTensorIndex) bool { + return rcv._tab.MutateByteSlot(12, byte(n)) } /// Sparse tensor index @@ -146,8 +146,8 @@ func (rcv *SparseTensor) Data(obj *Buffer) *Buffer { func SparseTensorStart(builder *flatbuffers.Builder) { builder.StartObject(7) } -func SparseTensorAddTypeType(builder *flatbuffers.Builder, typeType byte) { - builder.PrependByteSlot(0, typeType, 0) +func SparseTensorAddTypeType(builder *flatbuffers.Builder, typeType Type) { + builder.PrependByteSlot(0, byte(typeType), 0) } func SparseTensorAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(type_), 0) @@ -161,8 +161,8 @@ func SparseTensorStartShapeVector(builder *flatbuffers.Builder, numElems int) fl func SparseTensorAddNonZeroLength(builder *flatbuffers.Builder, nonZeroLength int64) { builder.PrependInt64Slot(3, nonZeroLength, 0) } -func SparseTensorAddSparseIndexType(builder *flatbuffers.Builder, sparseIndexType byte) { - builder.PrependByteSlot(4, sparseIndexType, 0) +func SparseTensorAddSparseIndexType(builder *flatbuffers.Builder, sparseIndexType SparseTensorIndex) { + builder.PrependByteSlot(4, byte(sparseIndexType), 0) } func SparseTensorAddSparseIndex(builder *flatbuffers.Builder, sparseIndex flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(sparseIndex), 0) diff --git a/go/arrow/internal/flatbuf/SparseTensorIndex.go b/go/arrow/internal/flatbuf/SparseTensorIndex.go index 4b82de7efec..42aa818b0b3 100644 --- a/go/arrow/internal/flatbuf/SparseTensorIndex.go +++ b/go/arrow/internal/flatbuf/SparseTensorIndex.go @@ -18,16 +18,34 @@ package flatbuf -type SparseTensorIndex = byte +import "strconv" + +type SparseTensorIndex byte + const ( - SparseTensorIndexNONE SparseTensorIndex = 0 + SparseTensorIndexNONE SparseTensorIndex = 0 SparseTensorIndexSparseTensorIndexCOO SparseTensorIndex = 1 - SparseTensorIndexSparseMatrixIndexCSR SparseTensorIndex = 2 + SparseTensorIndexSparseMatrixIndexCSX SparseTensorIndex = 2 + SparseTensorIndexSparseTensorIndexCSF SparseTensorIndex = 3 ) var EnumNamesSparseTensorIndex = map[SparseTensorIndex]string{ - SparseTensorIndexNONE:"NONE", - SparseTensorIndexSparseTensorIndexCOO:"SparseTensorIndexCOO", - SparseTensorIndexSparseMatrixIndexCSR:"SparseMatrixIndexCSR", + SparseTensorIndexNONE: "NONE", + SparseTensorIndexSparseTensorIndexCOO: "SparseTensorIndexCOO", + SparseTensorIndexSparseMatrixIndexCSX: "SparseMatrixIndexCSX", + SparseTensorIndexSparseTensorIndexCSF: "SparseTensorIndexCSF", } +var EnumValuesSparseTensorIndex = map[string]SparseTensorIndex{ + "NONE": SparseTensorIndexNONE, + "SparseTensorIndexCOO": SparseTensorIndexSparseTensorIndexCOO, + "SparseMatrixIndexCSX": SparseTensorIndexSparseMatrixIndexCSX, + "SparseTensorIndexCSF": SparseTensorIndexSparseTensorIndexCSF, +} + +func (v SparseTensorIndex) String() string { + if s, ok := EnumNamesSparseTensorIndex[v]; ok { + return s + } + return "SparseTensorIndex(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/SparseTensorIndexCOO.go b/go/arrow/internal/flatbuf/SparseTensorIndexCOO.go index 77c8dee902f..f8eee99fa69 100644 --- a/go/arrow/internal/flatbuf/SparseTensorIndexCOO.go +++ b/go/arrow/internal/flatbuf/SparseTensorIndexCOO.go @@ -24,7 +24,7 @@ import ( /// ---------------------------------------------------------------------- /// EXPERIMENTAL: Data structures for sparse tensors -/// Coodinate (COO) format of sparse tensor index. +/// Coordinate (COO) format of sparse tensor index. /// /// COO's index list are represented as a NxM matrix, /// where N is the number of non-zero values, @@ -36,22 +36,24 @@ import ( /// /// For example, let X be a 2x3x4x5 tensor, and it has the following /// 6 non-zero values: -/// +/// ```text /// X[0, 1, 2, 0] := 1 /// X[1, 1, 2, 3] := 2 /// X[0, 2, 1, 0] := 3 /// X[0, 1, 3, 0] := 4 /// X[0, 1, 2, 1] := 5 /// X[1, 2, 0, 4] := 6 -/// +/// ``` /// In COO format, the index matrix of X is the following 4x6 matrix: -/// +/// ```text /// [[0, 0, 0, 0, 1, 1], /// [1, 1, 1, 2, 1, 2], /// [2, 2, 3, 1, 2, 0], /// [0, 1, 0, 0, 3, 4]] -/// -/// Note that the indices are sorted in lexicographical order. +/// ``` +/// When isCanonical is true, the indices is sorted in lexicographical order +/// (row-major order), and it does not have duplicated entries. Otherwise, +/// the indices may not be sorted, or may have duplicated entries. type SparseTensorIndexCOO struct { _tab flatbuffers.Table } @@ -88,6 +90,7 @@ func (rcv *SparseTensorIndexCOO) IndicesType(obj *Int) *Int { /// The type of values in indicesBuffer /// Non-negative byte offsets to advance one value cell along each dimension +/// If omitted, default to row-major order (C-like). func (rcv *SparseTensorIndexCOO) IndicesStrides(j int) int64 { o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) if o != 0 { @@ -106,6 +109,7 @@ func (rcv *SparseTensorIndexCOO) IndicesStridesLength() int { } /// Non-negative byte offsets to advance one value cell along each dimension +/// If omitted, default to row-major order (C-like). func (rcv *SparseTensorIndexCOO) MutateIndicesStrides(j int, n int64) bool { o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) if o != 0 { @@ -130,8 +134,30 @@ func (rcv *SparseTensorIndexCOO) IndicesBuffer(obj *Buffer) *Buffer { } /// The location and size of the indices matrix's data +/// This flag is true if and only if the indices matrix is sorted in +/// row-major order, and does not have duplicated entries. +/// This sort order is the same as of Tensorflow's SparseTensor, +/// but it is inverse order of SciPy's canonical coo_matrix +/// (SciPy employs column-major order for its coo_matrix). +func (rcv *SparseTensorIndexCOO) IsCanonical() bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return rcv._tab.GetBool(o + rcv._tab.Pos) + } + return false +} + +/// This flag is true if and only if the indices matrix is sorted in +/// row-major order, and does not have duplicated entries. +/// This sort order is the same as of Tensorflow's SparseTensor, +/// but it is inverse order of SciPy's canonical coo_matrix +/// (SciPy employs column-major order for its coo_matrix). +func (rcv *SparseTensorIndexCOO) MutateIsCanonical(n bool) bool { + return rcv._tab.MutateBoolSlot(10, n) +} + func SparseTensorIndexCOOStart(builder *flatbuffers.Builder) { - builder.StartObject(3) + builder.StartObject(4) } func SparseTensorIndexCOOAddIndicesType(builder *flatbuffers.Builder, indicesType flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(indicesType), 0) @@ -145,6 +171,9 @@ func SparseTensorIndexCOOStartIndicesStridesVector(builder *flatbuffers.Builder, func SparseTensorIndexCOOAddIndicesBuffer(builder *flatbuffers.Builder, indicesBuffer flatbuffers.UOffsetT) { builder.PrependStructSlot(2, flatbuffers.UOffsetT(indicesBuffer), 0) } +func SparseTensorIndexCOOAddIsCanonical(builder *flatbuffers.Builder, isCanonical bool) { + builder.PrependBoolSlot(3, isCanonical, false) +} func SparseTensorIndexCOOEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/go/arrow/internal/flatbuf/SparseTensorIndexCSF.go b/go/arrow/internal/flatbuf/SparseTensorIndexCSF.go new file mode 100644 index 00000000000..a824c84ebfe --- /dev/null +++ b/go/arrow/internal/flatbuf/SparseTensorIndexCSF.go @@ -0,0 +1,291 @@ +// 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. + +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package flatbuf + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +/// Compressed Sparse Fiber (CSF) sparse tensor index. +type SparseTensorIndexCSF struct { + _tab flatbuffers.Table +} + +func GetRootAsSparseTensorIndexCSF(buf []byte, offset flatbuffers.UOffsetT) *SparseTensorIndexCSF { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &SparseTensorIndexCSF{} + x.Init(buf, n+offset) + return x +} + +func (rcv *SparseTensorIndexCSF) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *SparseTensorIndexCSF) Table() flatbuffers.Table { + return rcv._tab +} + +/// CSF is a generalization of compressed sparse row (CSR) index. +/// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) +/// +/// CSF index recursively compresses each dimension of a tensor into a set +/// of prefix trees. Each path from a root to leaf forms one tensor +/// non-zero index. CSF is implemented with two arrays of buffers and one +/// arrays of integers. +/// +/// For example, let X be a 2x3x4x5 tensor and let it have the following +/// 8 non-zero values: +/// ```text +/// X[0, 0, 0, 1] := 1 +/// X[0, 0, 0, 2] := 2 +/// X[0, 1, 0, 0] := 3 +/// X[0, 1, 0, 2] := 4 +/// X[0, 1, 1, 0] := 5 +/// X[1, 1, 1, 0] := 6 +/// X[1, 1, 1, 1] := 7 +/// X[1, 1, 1, 2] := 8 +/// ``` +/// As a prefix tree this would be represented as: +/// ```text +/// 0 1 +/// / \ | +/// 0 1 1 +/// / / \ | +/// 0 0 1 1 +/// /| /| | /| | +/// 1 2 0 2 0 0 1 2 +/// ``` +/// The type of values in indptrBuffers +func (rcv *SparseTensorIndexCSF) IndptrType(obj *Int) *Int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + x := rcv._tab.Indirect(o + rcv._tab.Pos) + if obj == nil { + obj = new(Int) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// CSF is a generalization of compressed sparse row (CSR) index. +/// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) +/// +/// CSF index recursively compresses each dimension of a tensor into a set +/// of prefix trees. Each path from a root to leaf forms one tensor +/// non-zero index. CSF is implemented with two arrays of buffers and one +/// arrays of integers. +/// +/// For example, let X be a 2x3x4x5 tensor and let it have the following +/// 8 non-zero values: +/// ```text +/// X[0, 0, 0, 1] := 1 +/// X[0, 0, 0, 2] := 2 +/// X[0, 1, 0, 0] := 3 +/// X[0, 1, 0, 2] := 4 +/// X[0, 1, 1, 0] := 5 +/// X[1, 1, 1, 0] := 6 +/// X[1, 1, 1, 1] := 7 +/// X[1, 1, 1, 2] := 8 +/// ``` +/// As a prefix tree this would be represented as: +/// ```text +/// 0 1 +/// / \ | +/// 0 1 1 +/// / / \ | +/// 0 0 1 1 +/// /| /| | /| | +/// 1 2 0 2 0 0 1 2 +/// ``` +/// The type of values in indptrBuffers +/// indptrBuffers stores the sparsity structure. +/// Each two consecutive dimensions in a tensor correspond to a buffer in +/// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` +/// and `indptrBuffers[dim][i + 1]` signify a range of nodes in +/// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. +/// +/// For example, the indptrBuffers for the above X is: +/// ```text +/// indptrBuffer(X) = [ +/// [0, 2, 3], +/// [0, 1, 3, 4], +/// [0, 2, 4, 5, 8] +/// ]. +/// ``` +func (rcv *SparseTensorIndexCSF) IndptrBuffers(obj *Buffer, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 16 + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *SparseTensorIndexCSF) IndptrBuffersLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +/// indptrBuffers stores the sparsity structure. +/// Each two consecutive dimensions in a tensor correspond to a buffer in +/// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` +/// and `indptrBuffers[dim][i + 1]` signify a range of nodes in +/// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. +/// +/// For example, the indptrBuffers for the above X is: +/// ```text +/// indptrBuffer(X) = [ +/// [0, 2, 3], +/// [0, 1, 3, 4], +/// [0, 2, 4, 5, 8] +/// ]. +/// ``` +/// The type of values in indicesBuffers +func (rcv *SparseTensorIndexCSF) IndicesType(obj *Int) *Int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + x := rcv._tab.Indirect(o + rcv._tab.Pos) + if obj == nil { + obj = new(Int) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +/// The type of values in indicesBuffers +/// indicesBuffers stores values of nodes. +/// Each tensor dimension corresponds to a buffer in indicesBuffers. +/// For example, the indicesBuffers for the above X is: +/// ```text +/// indicesBuffer(X) = [ +/// [0, 1], +/// [0, 1, 1], +/// [0, 0, 1, 1], +/// [1, 2, 0, 2, 0, 0, 1, 2] +/// ]. +/// ``` +func (rcv *SparseTensorIndexCSF) IndicesBuffers(obj *Buffer, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 16 + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *SparseTensorIndexCSF) IndicesBuffersLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +/// indicesBuffers stores values of nodes. +/// Each tensor dimension corresponds to a buffer in indicesBuffers. +/// For example, the indicesBuffers for the above X is: +/// ```text +/// indicesBuffer(X) = [ +/// [0, 1], +/// [0, 1, 1], +/// [0, 0, 1, 1], +/// [1, 2, 0, 2, 0, 0, 1, 2] +/// ]. +/// ``` +/// axisOrder stores the sequence in which dimensions were traversed to +/// produce the prefix tree. +/// For example, the axisOrder for the above X is: +/// ```text +/// axisOrder(X) = [0, 1, 2, 3]. +/// ``` +func (rcv *SparseTensorIndexCSF) AxisOrder(j int) int32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetInt32(a + flatbuffers.UOffsetT(j*4)) + } + return 0 +} + +func (rcv *SparseTensorIndexCSF) AxisOrderLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +/// axisOrder stores the sequence in which dimensions were traversed to +/// produce the prefix tree. +/// For example, the axisOrder for the above X is: +/// ```text +/// axisOrder(X) = [0, 1, 2, 3]. +/// ``` +func (rcv *SparseTensorIndexCSF) MutateAxisOrder(j int, n int32) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateInt32(a+flatbuffers.UOffsetT(j*4), n) + } + return false +} + +func SparseTensorIndexCSFStart(builder *flatbuffers.Builder) { + builder.StartObject(5) +} +func SparseTensorIndexCSFAddIndptrType(builder *flatbuffers.Builder, indptrType flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(indptrType), 0) +} +func SparseTensorIndexCSFAddIndptrBuffers(builder *flatbuffers.Builder, indptrBuffers flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(indptrBuffers), 0) +} +func SparseTensorIndexCSFStartIndptrBuffersVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(16, numElems, 8) +} +func SparseTensorIndexCSFAddIndicesType(builder *flatbuffers.Builder, indicesType flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(indicesType), 0) +} +func SparseTensorIndexCSFAddIndicesBuffers(builder *flatbuffers.Builder, indicesBuffers flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(indicesBuffers), 0) +} +func SparseTensorIndexCSFStartIndicesBuffersVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(16, numElems, 8) +} +func SparseTensorIndexCSFAddAxisOrder(builder *flatbuffers.Builder, axisOrder flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(4, flatbuffers.UOffsetT(axisOrder), 0) +} +func SparseTensorIndexCSFStartAxisOrderVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func SparseTensorIndexCSFEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/go/arrow/internal/flatbuf/Tensor.go b/go/arrow/internal/flatbuf/Tensor.go index f8341e02c0b..39d70e351e3 100644 --- a/go/arrow/internal/flatbuf/Tensor.go +++ b/go/arrow/internal/flatbuf/Tensor.go @@ -42,16 +42,16 @@ func (rcv *Tensor) Table() flatbuffers.Table { return rcv._tab } -func (rcv *Tensor) TypeType() byte { +func (rcv *Tensor) TypeType() Type { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) + return Type(rcv._tab.GetByte(o + rcv._tab.Pos)) } return 0 } -func (rcv *Tensor) MutateTypeType(n byte) bool { - return rcv._tab.MutateByteSlot(4, n) +func (rcv *Tensor) MutateTypeType(n Type) bool { + return rcv._tab.MutateByteSlot(4, byte(n)) } /// The type of data contained in a value cell. Currently only fixed-width @@ -90,6 +90,7 @@ func (rcv *Tensor) ShapeLength() int { /// The dimensions of the tensor, optionally named /// Non-negative byte offsets to advance one value cell along each dimension +/// If omitted, default to row-major order (C-like). func (rcv *Tensor) Strides(j int) int64 { o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) if o != 0 { @@ -108,6 +109,7 @@ func (rcv *Tensor) StridesLength() int { } /// Non-negative byte offsets to advance one value cell along each dimension +/// If omitted, default to row-major order (C-like). func (rcv *Tensor) MutateStrides(j int, n int64) bool { o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) if o != 0 { @@ -135,8 +137,8 @@ func (rcv *Tensor) Data(obj *Buffer) *Buffer { func TensorStart(builder *flatbuffers.Builder) { builder.StartObject(5) } -func TensorAddTypeType(builder *flatbuffers.Builder, typeType byte) { - builder.PrependByteSlot(0, typeType, 0) +func TensorAddTypeType(builder *flatbuffers.Builder, typeType Type) { + builder.PrependByteSlot(0, byte(typeType), 0) } func TensorAddType(builder *flatbuffers.Builder, type_ flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(type_), 0) diff --git a/go/arrow/internal/flatbuf/Time.go b/go/arrow/internal/flatbuf/Time.go index f3fa99f07b8..07b80eeb25a 100644 --- a/go/arrow/internal/flatbuf/Time.go +++ b/go/arrow/internal/flatbuf/Time.go @@ -48,13 +48,13 @@ func (rcv *Time) Table() flatbuffers.Table { func (rcv *Time) Unit() TimeUnit { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return TimeUnit(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 1 } func (rcv *Time) MutateUnit(n TimeUnit) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func (rcv *Time) BitWidth() int32 { @@ -72,8 +72,8 @@ func (rcv *Time) MutateBitWidth(n int32) bool { func TimeStart(builder *flatbuffers.Builder) { builder.StartObject(2) } -func TimeAddUnit(builder *flatbuffers.Builder, unit int16) { - builder.PrependInt16Slot(0, unit, 1) +func TimeAddUnit(builder *flatbuffers.Builder, unit TimeUnit) { + builder.PrependInt16Slot(0, int16(unit), 1) } func TimeAddBitWidth(builder *flatbuffers.Builder, bitWidth int32) { builder.PrependInt32Slot(1, bitWidth, 32) diff --git a/go/arrow/internal/flatbuf/TimeUnit.go b/go/arrow/internal/flatbuf/TimeUnit.go index cb0c7427d6c..df14ece4f18 100644 --- a/go/arrow/internal/flatbuf/TimeUnit.go +++ b/go/arrow/internal/flatbuf/TimeUnit.go @@ -18,18 +18,34 @@ package flatbuf -type TimeUnit = int16 +import "strconv" + +type TimeUnit int16 + const ( - TimeUnitSECOND TimeUnit = 0 + TimeUnitSECOND TimeUnit = 0 TimeUnitMILLISECOND TimeUnit = 1 TimeUnitMICROSECOND TimeUnit = 2 - TimeUnitNANOSECOND TimeUnit = 3 + TimeUnitNANOSECOND TimeUnit = 3 ) var EnumNamesTimeUnit = map[TimeUnit]string{ - TimeUnitSECOND:"SECOND", - TimeUnitMILLISECOND:"MILLISECOND", - TimeUnitMICROSECOND:"MICROSECOND", - TimeUnitNANOSECOND:"NANOSECOND", + TimeUnitSECOND: "SECOND", + TimeUnitMILLISECOND: "MILLISECOND", + TimeUnitMICROSECOND: "MICROSECOND", + TimeUnitNANOSECOND: "NANOSECOND", } +var EnumValuesTimeUnit = map[string]TimeUnit{ + "SECOND": TimeUnitSECOND, + "MILLISECOND": TimeUnitMILLISECOND, + "MICROSECOND": TimeUnitMICROSECOND, + "NANOSECOND": TimeUnitNANOSECOND, +} + +func (v TimeUnit) String() string { + if s, ok := EnumNamesTimeUnit[v]; ok { + return s + } + return "TimeUnit(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Timestamp.go b/go/arrow/internal/flatbuf/Timestamp.go index dd98c8226ec..44f944000b8 100644 --- a/go/arrow/internal/flatbuf/Timestamp.go +++ b/go/arrow/internal/flatbuf/Timestamp.go @@ -51,13 +51,13 @@ func (rcv *Timestamp) Table() flatbuffers.Table { func (rcv *Timestamp) Unit() TimeUnit { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return TimeUnit(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *Timestamp) MutateUnit(n TimeUnit) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } /// The time zone is a string indicating the name of a time zone, one of: @@ -111,8 +111,8 @@ func (rcv *Timestamp) Timezone() []byte { func TimestampStart(builder *flatbuffers.Builder) { builder.StartObject(2) } -func TimestampAddUnit(builder *flatbuffers.Builder, unit int16) { - builder.PrependInt16Slot(0, unit, 0) +func TimestampAddUnit(builder *flatbuffers.Builder, unit TimeUnit) { + builder.PrependInt16Slot(0, int16(unit), 0) } func TimestampAddTimezone(builder *flatbuffers.Builder, timezone flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(timezone), 0) diff --git a/go/arrow/internal/flatbuf/Type.go b/go/arrow/internal/flatbuf/Type.go index e3fbe2bb110..319c6c6a4a5 100644 --- a/go/arrow/internal/flatbuf/Type.go +++ b/go/arrow/internal/flatbuf/Type.go @@ -18,57 +18,91 @@ package flatbuf +import "strconv" + /// ---------------------------------------------------------------------- /// Top-level Type value, enabling extensible type-specific metadata. We can /// add new logical types to Type without breaking backwards compatibility -type Type = byte +type Type byte + const ( - TypeNONE Type = 0 - TypeNull Type = 1 - TypeInt Type = 2 - TypeFloatingPoint Type = 3 - TypeBinary Type = 4 - TypeUtf8 Type = 5 - TypeBool Type = 6 - TypeDecimal Type = 7 - TypeDate Type = 8 - TypeTime Type = 9 - TypeTimestamp Type = 10 - TypeInterval Type = 11 - TypeList Type = 12 - TypeStruct_ Type = 13 - TypeUnion Type = 14 + TypeNONE Type = 0 + TypeNull Type = 1 + TypeInt Type = 2 + TypeFloatingPoint Type = 3 + TypeBinary Type = 4 + TypeUtf8 Type = 5 + TypeBool Type = 6 + TypeDecimal Type = 7 + TypeDate Type = 8 + TypeTime Type = 9 + TypeTimestamp Type = 10 + TypeInterval Type = 11 + TypeList Type = 12 + TypeStruct_ Type = 13 + TypeUnion Type = 14 TypeFixedSizeBinary Type = 15 - TypeFixedSizeList Type = 16 - TypeMap Type = 17 - TypeDuration Type = 18 - TypeLargeBinary Type = 19 - TypeLargeUtf8 Type = 20 - TypeLargeList Type = 21 + TypeFixedSizeList Type = 16 + TypeMap Type = 17 + TypeDuration Type = 18 + TypeLargeBinary Type = 19 + TypeLargeUtf8 Type = 20 + TypeLargeList Type = 21 ) var EnumNamesType = map[Type]string{ - TypeNONE:"NONE", - TypeNull:"Null", - TypeInt:"Int", - TypeFloatingPoint:"FloatingPoint", - TypeBinary:"Binary", - TypeUtf8:"Utf8", - TypeBool:"Bool", - TypeDecimal:"Decimal", - TypeDate:"Date", - TypeTime:"Time", - TypeTimestamp:"Timestamp", - TypeInterval:"Interval", - TypeList:"List", - TypeStruct_:"Struct_", - TypeUnion:"Union", - TypeFixedSizeBinary:"FixedSizeBinary", - TypeFixedSizeList:"FixedSizeList", - TypeMap:"Map", - TypeDuration:"Duration", - TypeLargeBinary:"LargeBinary", - TypeLargeUtf8:"LargeUtf8", - TypeLargeList:"LargeList", + TypeNONE: "NONE", + TypeNull: "Null", + TypeInt: "Int", + TypeFloatingPoint: "FloatingPoint", + TypeBinary: "Binary", + TypeUtf8: "Utf8", + TypeBool: "Bool", + TypeDecimal: "Decimal", + TypeDate: "Date", + TypeTime: "Time", + TypeTimestamp: "Timestamp", + TypeInterval: "Interval", + TypeList: "List", + TypeStruct_: "Struct_", + TypeUnion: "Union", + TypeFixedSizeBinary: "FixedSizeBinary", + TypeFixedSizeList: "FixedSizeList", + TypeMap: "Map", + TypeDuration: "Duration", + TypeLargeBinary: "LargeBinary", + TypeLargeUtf8: "LargeUtf8", + TypeLargeList: "LargeList", } +var EnumValuesType = map[string]Type{ + "NONE": TypeNONE, + "Null": TypeNull, + "Int": TypeInt, + "FloatingPoint": TypeFloatingPoint, + "Binary": TypeBinary, + "Utf8": TypeUtf8, + "Bool": TypeBool, + "Decimal": TypeDecimal, + "Date": TypeDate, + "Time": TypeTime, + "Timestamp": TypeTimestamp, + "Interval": TypeInterval, + "List": TypeList, + "Struct_": TypeStruct_, + "Union": TypeUnion, + "FixedSizeBinary": TypeFixedSizeBinary, + "FixedSizeList": TypeFixedSizeList, + "Map": TypeMap, + "Duration": TypeDuration, + "LargeBinary": TypeLargeBinary, + "LargeUtf8": TypeLargeUtf8, + "LargeList": TypeLargeList, +} + +func (v Type) String() string { + if s, ok := EnumNamesType[v]; ok { + return s + } + return "Type(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/internal/flatbuf/Union.go b/go/arrow/internal/flatbuf/Union.go index 1eae176e630..e34121d4757 100644 --- a/go/arrow/internal/flatbuf/Union.go +++ b/go/arrow/internal/flatbuf/Union.go @@ -25,7 +25,7 @@ import ( /// A union is a complex type with children in Field /// By default ids in the type vector refer to the offsets in the children /// optionally typeIds provides an indirection between the child offset and the type id -/// for each child typeIds[offset] is the id used in the type vector +/// for each child `typeIds[offset]` is the id used in the type vector type Union struct { _tab flatbuffers.Table } @@ -49,13 +49,13 @@ func (rcv *Union) Table() flatbuffers.Table { func (rcv *Union) Mode() UnionMode { o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) + return UnionMode(rcv._tab.GetInt16(o + rcv._tab.Pos)) } return 0 } func (rcv *Union) MutateMode(n UnionMode) bool { - return rcv._tab.MutateInt16Slot(4, n) + return rcv._tab.MutateInt16Slot(4, int16(n)) } func (rcv *Union) TypeIds(j int) int32 { @@ -87,8 +87,8 @@ func (rcv *Union) MutateTypeIds(j int, n int32) bool { func UnionStart(builder *flatbuffers.Builder) { builder.StartObject(2) } -func UnionAddMode(builder *flatbuffers.Builder, mode int16) { - builder.PrependInt16Slot(0, mode, 0) +func UnionAddMode(builder *flatbuffers.Builder, mode UnionMode) { + builder.PrependInt16Slot(0, int16(mode), 0) } func UnionAddTypeIds(builder *flatbuffers.Builder, typeIds flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(typeIds), 0) diff --git a/go/arrow/internal/flatbuf/UnionMode.go b/go/arrow/internal/flatbuf/UnionMode.go index 4357682ad4d..357c1f3cb5f 100644 --- a/go/arrow/internal/flatbuf/UnionMode.go +++ b/go/arrow/internal/flatbuf/UnionMode.go @@ -18,14 +18,28 @@ package flatbuf -type UnionMode = int16 +import "strconv" + +type UnionMode int16 + const ( UnionModeSparse UnionMode = 0 - UnionModeDense UnionMode = 1 + UnionModeDense UnionMode = 1 ) var EnumNamesUnionMode = map[UnionMode]string{ - UnionModeSparse:"Sparse", - UnionModeDense:"Dense", + UnionModeSparse: "Sparse", + UnionModeDense: "Dense", } +var EnumValuesUnionMode = map[string]UnionMode{ + "Sparse": UnionModeSparse, + "Dense": UnionModeDense, +} + +func (v UnionMode) String() string { + if s, ok := EnumNamesUnionMode[v]; ok { + return s + } + return "UnionMode(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/go/arrow/ipc/file_writer.go b/go/arrow/ipc/file_writer.go index a2570c362cc..112427020f4 100644 --- a/go/arrow/ipc/file_writer.go +++ b/go/arrow/ipc/file_writer.go @@ -82,7 +82,7 @@ func (w *pwriter) WritePayload(p Payload) error { return xerrors.Errorf("arrow/ipc: could not update position while in write-payload: %w", err) } - switch byte(p.msg) { + switch flatbuf.MessageHeader(p.msg) { case flatbuf.MessageHeaderDictionaryBatch: w.dicts = append(w.dicts, blk) case flatbuf.MessageHeaderRecordBatch: diff --git a/go/arrow/ipc/message.go b/go/arrow/ipc/message.go index 468003c4f90..76f81e4fa4a 100644 --- a/go/arrow/ipc/message.go +++ b/go/arrow/ipc/message.go @@ -39,7 +39,7 @@ const ( ) func (m MetadataVersion) String() string { - if v, ok := flatbuf.EnumNamesMetadataVersion[int16(m)]; ok { + if v, ok := flatbuf.EnumNamesMetadataVersion[flatbuf.MetadataVersion(m)]; ok { return v } return fmt.Sprintf("MetadataVersion(%d)", int16(m)) @@ -58,7 +58,7 @@ const ( ) func (m MessageType) String() string { - if v, ok := flatbuf.EnumNamesMessageHeader[byte(m)]; ok { + if v, ok := flatbuf.EnumNamesMessageHeader[flatbuf.MessageHeader(m)]; ok { return v } return fmt.Sprintf("MessageType(%d)", int(m)) diff --git a/go/arrow/ipc/metadata.go b/go/arrow/ipc/metadata.go index 687cbe0a0ec..ef9a9bbe457 100644 --- a/go/arrow/ipc/metadata.go +++ b/go/arrow/ipc/metadata.go @@ -927,7 +927,7 @@ func writeFBBuilder(b *flatbuffers.Builder, mem memory.Allocator) *memory.Buffer func writeMessageFB(b *flatbuffers.Builder, mem memory.Allocator, hdrType flatbuf.MessageHeader, hdr flatbuffers.UOffsetT, bodyLen int64) *memory.Buffer { flatbuf.MessageStart(b) - flatbuf.MessageAddVersion(b, int16(currentMetadataVersion)) + flatbuf.MessageAddVersion(b, flatbuf.MetadataVersion(currentMetadataVersion)) flatbuf.MessageAddHeaderType(b, hdrType) flatbuf.MessageAddHeader(b, hdr) flatbuf.MessageAddBodyLength(b, bodyLen) @@ -954,7 +954,7 @@ func writeFileFooter(schema *arrow.Schema, dicts, recs []fileBlock, w io.Writer) recsFB := fileBlocksToFB(b, recs, flatbuf.FooterStartRecordBatchesVector) flatbuf.FooterStart(b) - flatbuf.FooterAddVersion(b, int16(currentMetadataVersion)) + flatbuf.FooterAddVersion(b, flatbuf.MetadataVersion(currentMetadataVersion)) flatbuf.FooterAddSchema(b, schemaFB) flatbuf.FooterAddDictionaries(b, dictsFB) flatbuf.FooterAddRecordBatches(b, recsFB)