You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/04/30 00:45:45 UTC
[arrow] branch main updated: GH-34858: [Swift] Initial reader impl (#34842)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 0ea1a103df GH-34858: [Swift] Initial reader impl (#34842)
0ea1a103df is described below
commit 0ea1a103dfc2fc4ab5a5d839369a805e2ae657a2
Author: abandy <ab...@live.com>
AuthorDate: Sat Apr 29 20:45:32 2023 -0400
GH-34858: [Swift] Initial reader impl (#34842)
- Initial check in for the swift arrow reader impl
- bug fixes found during reader testing
- class/method access modifier changes (mostly from internal to public)
* Closes: #34858
Authored-by: Alva Bandy <ab...@live.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
.../ubuntu-swift.dockerfile} | 14 +-
ci/scripts/swift_test.sh | 8 +-
dev/release/rat_exclude_files.txt | 1 +
docker-compose.yml | 5 +-
swift/Arrow/Package.swift | 11 +-
swift/Arrow/README.md | 7 +
swift/Arrow/Sources/Arrow/ArrowBuffer.swift | 9 +
swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift | 8 +-
swift/Arrow/Sources/Arrow/ArrowData.swift | 14 +-
swift/Arrow/Sources/Arrow/ArrowReader.swift | 163 +++
swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift | 144 ++
swift/Arrow/Sources/Arrow/ArrowSchema.swift | 14 +-
swift/Arrow/Sources/Arrow/ArrowTable.swift | 50 +-
swift/Arrow/Sources/Arrow/ArrowType.swift | 7 +-
swift/Arrow/Sources/Arrow/BitUtility.swift | 8 +-
swift/Arrow/Sources/Arrow/ChunkedArray.swift | 45 +-
swift/Arrow/Sources/Arrow/File_generated.swift | 160 +++
swift/Arrow/Sources/Arrow/Message_generated.swift | 421 ++++++
swift/Arrow/Sources/Arrow/Schema_generated.swift | 1479 ++++++++++++++++++++
.../Sources/Arrow/SparseTensor_generated.swift | 535 +++++++
swift/Arrow/Sources/Arrow/Tensor_generated.swift | 193 +++
swift/Arrow/Tests/ArrowTests/IPCTests.swift | 80 ++
swift/data-generator/swift-datagen/go.mod | 40 +
swift/data-generator/swift-datagen/go.sum | 47 +
swift/data-generator/swift-datagen/main.go | 91 ++
swift/gen-flatbuffers.sh | 51 +
26 files changed, 3537 insertions(+), 68 deletions(-)
diff --git a/ci/scripts/swift_test.sh b/ci/docker/ubuntu-swift.dockerfile
old mode 100755
new mode 100644
similarity index 83%
copy from ci/scripts/swift_test.sh
copy to ci/docker/ubuntu-swift.dockerfile
index 0ed22b16c2..5ef6bc433d
--- a/ci/scripts/swift_test.sh
+++ b/ci/docker/ubuntu-swift.dockerfile
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-#
# 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
@@ -17,10 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-set -ex
-
-source_dir=${1}/swift/Arrow
+FROM swift:5.7.3
-pushd ${source_dir}
-swift test
-popd
+# Install golang
+RUN apt-get update -y -q && \
+ apt-get install -y -q --no-install-recommends \
+ golang-go && \
+ apt-get clean
\ No newline at end of file
diff --git a/ci/scripts/swift_test.sh b/ci/scripts/swift_test.sh
index 0ed22b16c2..eac13c5d68 100755
--- a/ci/scripts/swift_test.sh
+++ b/ci/scripts/swift_test.sh
@@ -19,8 +19,14 @@
set -ex
-source_dir=${1}/swift/Arrow
+data_gen_dir=${1}/swift/data-generator/swift-datagen
+pushd ${data_gen_dir}
+go get -d ./...
+go run main.go
+cp *.arrow ../../Arrow
+popd
+source_dir=${1}/swift/Arrow
pushd ${source_dir}
swift test
popd
diff --git a/dev/release/rat_exclude_files.txt b/dev/release/rat_exclude_files.txt
index d37790912b..f61c217760 100644
--- a/dev/release/rat_exclude_files.txt
+++ b/dev/release/rat_exclude_files.txt
@@ -149,3 +149,4 @@ r/tools/nixlibs-allowlist.txt
.gitattributes
ruby/red-arrow/.yardopts
.github/pull_request_template.md
+swift/data-generator/swift-datagen/go.sum
diff --git a/docker-compose.yml b/docker-compose.yml
index a7f5f99278..267b6df4d1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -921,7 +921,10 @@ services:
# docker-compose build ubuntu-swift
# docker-compose run --rm ubuntu-swift
# Parameters:
- image: swift:5.7.3
+ image: ubuntu-swift
+ build:
+ context: .
+ dockerfile: ci/docker/ubuntu-swift.dockerfile
shm_size: *shm-size
volumes: *ubuntu-volumes
command: >
diff --git a/swift/Arrow/Package.swift b/swift/Arrow/Package.swift
index d89ef51965..065afe6264 100644
--- a/swift/Arrow/Package.swift
+++ b/swift/Arrow/Package.swift
@@ -22,17 +22,26 @@ import PackageDescription
let package = Package(
name: "Arrow",
+ platforms: [
+ .macOS(.v10_14)
+ ],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Arrow",
targets: ["Arrow"]),
],
+ dependencies: [
+ .package(url: "https://github.com/google/flatbuffers.git", from: "23.3.3")
+ ],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
- name: "Arrow"),
+ name: "Arrow",
+ dependencies: [
+ .product(name: "FlatBuffers", package: "flatbuffers")
+ ]),
.testTarget(
name: "ArrowTests",
dependencies: ["Arrow"]),
diff --git a/swift/Arrow/README.md b/swift/Arrow/README.md
index 4ddfba1382..3acded89e1 100644
--- a/swift/Arrow/README.md
+++ b/swift/Arrow/README.md
@@ -47,3 +47,10 @@ An implementation of Arrow targeting Swift.
- Data Types
- Fields
- Schema
+
+## Test data generation
+
+Test data files for the reader tests are generated by an executable built in go whose source is included in the data-generator directory.
+```sh
+$ go build -o swift-datagen
+```
diff --git a/swift/Arrow/Sources/Arrow/ArrowBuffer.swift b/swift/Arrow/Sources/Arrow/ArrowBuffer.swift
index f2c984e23b..6aa8f7b359 100644
--- a/swift/Arrow/Sources/Arrow/ArrowBuffer.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowBuffer.swift
@@ -34,6 +34,15 @@ public class ArrowBuffer {
self.rawPointer.deallocate()
}
+ static func createBuffer(_ data: [UInt8], length: UInt) -> ArrowBuffer {
+ let byteCount = UInt(data.count)
+ let capacity = alignTo64(byteCount)
+ let memory = MemoryAllocator(64)
+ let rawPointer = memory.allocateArray(Int(capacity))
+ rawPointer.copyMemory(from: data, byteCount: data.count)
+ return ArrowBuffer(length: length, capacity: capacity, rawPointer: rawPointer)
+ }
+
static func createBuffer(_ length: UInt, size: UInt, doAlign: Bool = true) -> ArrowBuffer {
let actualLen = max(length, ArrowBuffer.min_length)
let byteCount = size * actualLen
diff --git a/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift b/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
index 14ca8750a5..65ac44e174 100644
--- a/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift
@@ -77,10 +77,11 @@ public class FixedBufferBuilder<T>: BaseBufferBuilder<T>, ArrowBufferBuilder {
}
if let val = newValue {
+ BitUtility.setBit(index + self.offset, buffer: self.nulls)
self.values.rawPointer.advanced(by: byteIndex).storeBytes(of: val, as: T.self)
} else {
self.nullCount += 1
- BitUtility.setBit(index + self.offset, buffer: self.nulls)
+ BitUtility.clearBit(index + self.offset, buffer: self.nulls)
self.values.rawPointer.advanced(by: byteIndex).storeBytes(of: defaultVal, as: T.self)
}
}
@@ -150,6 +151,7 @@ public class BoolBufferBuilder: BaseBufferBuilder<Bool>, ArrowBufferBuilder {
}
if newValue != nil {
+ BitUtility.setBit(index + self.offset, buffer: self.nulls)
if newValue == true {
BitUtility.setBit(index + self.offset, buffer: self.values)
} else {
@@ -158,7 +160,7 @@ public class BoolBufferBuilder: BaseBufferBuilder<Bool>, ArrowBufferBuilder {
} else {
self.nullCount += 1
- BitUtility.setBit(index + self.offset, buffer: self.nulls)
+ BitUtility.clearBit(index + self.offset, buffer: self.nulls)
BitUtility.clearBit(index + self.offset, buffer: self.values)
}
}
@@ -225,6 +227,8 @@ public class VariableBufferBuilder<T>: BaseBufferBuilder<T>, ArrowBufferBuilder
if isNull {
self.nullCount += 1
+ BitUtility.clearBit(index + self.offset, buffer: self.nulls)
+ } else {
BitUtility.setBit(index + self.offset, buffer: self.nulls)
}
diff --git a/swift/Arrow/Sources/Arrow/ArrowData.swift b/swift/Arrow/Sources/Arrow/ArrowData.swift
index cdfe6fdc9b..f70e5b551e 100644
--- a/swift/Arrow/Sources/Arrow/ArrowData.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowData.swift
@@ -18,11 +18,11 @@
import Foundation
public class ArrowData {
- let type: ArrowType.Info
- let buffers: [ArrowBuffer]
- let nullCount: UInt
- let length: UInt
- let stride: Int
+ public let type: ArrowType.Info
+ public let buffers: [ArrowBuffer]
+ public let nullCount: UInt
+ public let length: UInt
+ public let stride: Int
init(_ type: ArrowType.Info, buffers: [ArrowBuffer], nullCount: UInt, stride: Int) throws {
switch(type) {
@@ -43,8 +43,8 @@ public class ArrowData {
self.stride = stride
}
- func isNull(_ at: UInt) -> Bool {
+ public func isNull(_ at: UInt) -> Bool {
let nullBuffer = buffers[0];
- return nullBuffer.length == 0 || BitUtility.isSet(at, buffer: nullBuffer)
+ return nullBuffer.length > 0 && !BitUtility.isSet(at, buffer: nullBuffer)
}
}
diff --git a/swift/Arrow/Sources/Arrow/ArrowReader.swift b/swift/Arrow/Sources/Arrow/ArrowReader.swift
new file mode 100644
index 0000000000..88ef4e1c60
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/ArrowReader.swift
@@ -0,0 +1,163 @@
+// 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.
+
+import FlatBuffers
+import Foundation
+
+public enum ArrowError: Error {
+ case runtimeError(String)
+}
+
+let FILEMARKER = "ARROW1"
+let CONTINUATIONMARKER = -1
+
+public class ArrowReader {
+ private struct DataLoadInfo {
+ let recordBatch: org_apache_arrow_flatbuf_RecordBatch
+ let field: org_apache_arrow_flatbuf_Field
+ let nodeIndex: Int32
+ let bufferIndex: Int32
+ let fileData: Data
+ let messageOffset: Int64
+ }
+
+ private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
+ let builder = ArrowSchema.Builder()
+ for index in 0 ..< schema.fieldsCount {
+ let field = schema.fields(at: index)!
+ let arrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
+ builder.addField(arrowField)
+ if field.typeType == .struct_ {
+ throw ValidationError.unknownType
+ }
+ }
+
+ return builder.finish()
+ }
+
+ private func loadPrimitiveData(_ loadInfo: DataLoadInfo) throws -> ChunkedArrayHolder {
+ let node = loadInfo.recordBatch.nodes(at: loadInfo.nodeIndex)!
+ try validateBufferIndex(loadInfo.recordBatch, index: loadInfo.bufferIndex)
+ let nullBuffer = loadInfo.recordBatch.buffers(at: loadInfo.bufferIndex)!
+ let arrowNullBuffer = makeBuffer(nullBuffer, fileData: loadInfo.fileData,
+ length: UInt(node.nullCount), messageOffset: loadInfo.messageOffset)
+ try validateBufferIndex(loadInfo.recordBatch, index: loadInfo.bufferIndex + 1)
+ let valueBuffer = loadInfo.recordBatch.buffers(at: loadInfo.bufferIndex + 1)!
+ let arrowValueBuffer = makeBuffer(valueBuffer, fileData: loadInfo.fileData,
+ length: UInt(node.length), messageOffset: loadInfo.messageOffset)
+ return try makeArrayHolder(loadInfo.field, buffers: [arrowNullBuffer, arrowValueBuffer])
+ }
+
+ private func loadVariableData(_ loadInfo: DataLoadInfo) throws -> ChunkedArrayHolder {
+ let node = loadInfo.recordBatch.nodes(at: loadInfo.nodeIndex)!
+ try validateBufferIndex(loadInfo.recordBatch, index: loadInfo.bufferIndex)
+ let nullBuffer = loadInfo.recordBatch.buffers(at: loadInfo.bufferIndex)!
+ let arrowNullBuffer = makeBuffer(nullBuffer, fileData: loadInfo.fileData,
+ length: UInt(node.nullCount), messageOffset: loadInfo.messageOffset)
+ try validateBufferIndex(loadInfo.recordBatch, index: loadInfo.bufferIndex + 1)
+ let offsetBuffer = loadInfo.recordBatch.buffers(at: loadInfo.bufferIndex + 1)!
+ let arrowOffsetBuffer = makeBuffer(offsetBuffer, fileData: loadInfo.fileData,
+ length: UInt(node.length), messageOffset: loadInfo.messageOffset)
+ try validateBufferIndex(loadInfo.recordBatch, index: loadInfo.bufferIndex + 2)
+ let valueBuffer = loadInfo.recordBatch.buffers(at: loadInfo.bufferIndex + 2)!
+ let arrowValueBuffer = makeBuffer(valueBuffer, fileData: loadInfo.fileData,
+ length: UInt(node.length), messageOffset: loadInfo.messageOffset)
+ return try makeArrayHolder(loadInfo.field, buffers: [arrowNullBuffer, arrowOffsetBuffer, arrowValueBuffer])
+ }
+
+ private func loadRecordBatch(_ message: org_apache_arrow_flatbuf_Message, schema: org_apache_arrow_flatbuf_Schema,
+ data: Data, messageEndOffset: Int64) throws -> RecordBatch {
+ let recordBatch = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)
+ let nodesCount = recordBatch?.nodesCount ?? 0
+ var bufferIndex: Int32 = 0
+ var columns: [ChunkedArrayHolder] = []
+ let arrowSchema = try loadSchema(schema)
+ for nodeIndex in 0 ..< nodesCount {
+ let field = schema.fields(at: nodeIndex)!
+ let loadInfo = DataLoadInfo(recordBatch: recordBatch!, field: field,
+ nodeIndex: nodeIndex, bufferIndex: bufferIndex,
+ fileData: data, messageOffset: messageEndOffset)
+ if isFixedPrimitive(field.typeType) {
+ let holder = try loadPrimitiveData(loadInfo)
+ columns.append(holder)
+ bufferIndex += 2
+ } else {
+ let holder = try loadVariableData(loadInfo)
+ columns.append(holder)
+ bufferIndex += 3
+ }
+ }
+
+ return RecordBatch(arrowSchema, columns: columns)
+ }
+
+ public func fromStream(_ fileData: Data) throws -> [RecordBatch] {
+ let footerLength = fileData.withUnsafeBytes { rawBuffer in
+ rawBuffer.loadUnaligned(fromByteOffset: fileData.count - 4, as: Int32.self)
+ }
+
+ var recordBatchs: [RecordBatch] = []
+ let footerStartOffset = fileData.count - Int(footerLength + 4)
+ let footerData = fileData[footerStartOffset...]
+ let footerBuffer = ByteBuffer(data: footerData)
+ let footer = org_apache_arrow_flatbuf_Footer.getRootAsFooter(bb: footerBuffer)
+ for index in 0 ..< footer.recordBatchesCount {
+ let recordBatch = footer.recordBatches(at: index)!
+ var messageLength = fileData.withUnsafeBytes { rawBuffer in
+ rawBuffer.loadUnaligned(fromByteOffset: Int(recordBatch.offset), as: Int32.self)
+ }
+
+ var messageOffset: Int64 = 1
+ if messageLength == CONTINUATIONMARKER {
+ messageOffset += 1
+ messageLength = fileData.withUnsafeBytes { rawBuffer in
+ rawBuffer.loadUnaligned(
+ fromByteOffset: Int(recordBatch.offset + Int64(MemoryLayout<Int32>.size)),
+ as: Int32.self)
+ }
+ }
+
+ let messageStartOffset = recordBatch.offset + (Int64(MemoryLayout<Int32>.size) * messageOffset)
+ let messageEndOffset = messageStartOffset + Int64(messageLength)
+ let recordBatchData = fileData[messageStartOffset ... messageEndOffset]
+ let mbb = ByteBuffer(data: recordBatchData)
+ let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: mbb)
+ switch message.headerType {
+ case .recordbatch:
+ let recordBatch = try loadRecordBatch(message, schema: footer.schema!,
+ data: fileData, messageEndOffset: messageEndOffset)
+ recordBatchs.append(recordBatch)
+ default:
+ print("Unhandled header type: \(message.headerType)")
+ }
+ }
+
+ return recordBatchs
+ }
+
+ public func fromFile(_ fileURL: URL) throws -> [RecordBatch] {
+ let fileData = try Data(contentsOf: fileURL)
+ if !validateFileData(fileData) {
+ throw ArrowError.runtimeError("Not a valid arrow file.")
+ }
+
+ let markerLength = FILEMARKER.utf8.count
+ let footerLengthEnd = Int(fileData.count - markerLength)
+ let data = fileData[..<(footerLengthEnd)]
+ return try fromStream(data)
+ }
+}
diff --git a/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift b/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift
new file mode 100644
index 0000000000..6f306f761f
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift
@@ -0,0 +1,144 @@
+// 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.
+
+import FlatBuffers
+import Foundation
+
+fileprivate func makeFixedHolder<T>(_: T.Type, buffers: [ArrowBuffer]) throws -> ChunkedArrayHolder {
+ let nullCount = buffers[0].length
+ let arrowData = try ArrowData(ArrowType.ArrowInt32, buffers: buffers,
+ nullCount: nullCount, stride: MemoryLayout<T>.stride)
+ let chuckedArray = try ChunkedArray<T>([FixedArray<T>(arrowData)])
+ return ChunkedArrayHolder(chuckedArray)
+}
+
+func makeArrayHolder(_ field: org_apache_arrow_flatbuf_Field, buffers: [ArrowBuffer]) throws -> ChunkedArrayHolder {
+ let type = field.typeType
+ switch type {
+ case .int:
+ let intType = field.type(type: org_apache_arrow_flatbuf_Int.self)!
+ let bitWidth = intType.bitWidth
+ if bitWidth == 8 {
+ if intType.isSigned {
+ return try makeFixedHolder(Int8.self, buffers: buffers)
+ } else {
+ return try makeFixedHolder(UInt8.self, buffers: buffers)
+ }
+ } else if bitWidth == 16 {
+ if intType.isSigned {
+ return try makeFixedHolder(Int16.self, buffers: buffers)
+ } else {
+ return try makeFixedHolder(UInt16.self, buffers: buffers)
+ }
+ } else if bitWidth == 32 {
+ if intType.isSigned {
+ return try makeFixedHolder(Int32.self, buffers: buffers)
+ } else {
+ return try makeFixedHolder(UInt32.self, buffers: buffers)
+ }
+ } else if bitWidth == 64 {
+ if intType.isSigned {
+ return try makeFixedHolder(Int64.self, buffers: buffers)
+ } else {
+ return try makeFixedHolder(UInt64.self, buffers: buffers)
+ }
+ }
+ throw ValidationError.unknownType
+ case .bool:
+ let arrowData = try ArrowData(ArrowType.ArrowInt32, buffers: buffers,
+ nullCount: buffers[0].length, stride: MemoryLayout<UInt8>.stride)
+ let chuckedArray = try ChunkedArray<Bool>([BoolArray(arrowData)])
+ return ChunkedArrayHolder(chuckedArray)
+ case .floatingpoint:
+ let floatType = field.type(type: org_apache_arrow_flatbuf_FloatingPoint.self)!
+ switch floatType.precision {
+ case .single:
+ return try makeFixedHolder(Float.self, buffers: buffers)
+ case .double:
+ return try makeFixedHolder(Double.self, buffers: buffers)
+ default:
+ throw ValidationError.unknownType
+ }
+ case .utf8:
+ let arrowData = try ArrowData(ArrowType.ArrowString, buffers: buffers,
+ nullCount: buffers[0].length, stride: MemoryLayout<Int8>.stride)
+ let chuckedArray = try ChunkedArray<String>([StringArray(arrowData)])
+ return ChunkedArrayHolder(chuckedArray)
+ default:
+ throw ValidationError.unknownType
+ }
+}
+
+func makeBuffer(_ buffer: org_apache_arrow_flatbuf_Buffer, fileData: Data,
+ length: UInt, messageOffset: Int64) -> ArrowBuffer {
+ let startOffset = messageOffset + buffer.offset
+ let endOffset = startOffset + buffer.length
+ let bufferData = [UInt8](fileData[startOffset ..< endOffset])
+ return ArrowBuffer.createBuffer(bufferData, length: length)
+}
+
+func isFixedPrimitive(_ type: org_apache_arrow_flatbuf_Type_) -> Bool {
+ switch type {
+ case .int, .bool, .floatingpoint, .date:
+ return true
+ default:
+ return false
+ }
+}
+
+func findArrowType(_ field: org_apache_arrow_flatbuf_Field) -> ArrowType.Info {
+ let type = field.typeType
+ switch type {
+ case .int:
+ let intType = field.type(type: org_apache_arrow_flatbuf_Int.self)!
+ let bitWidth = intType.bitWidth
+ if bitWidth == 8 { return intType.isSigned ? ArrowType.ArrowInt8 : ArrowType.ArrowUInt8 }
+ if bitWidth == 16 { return intType.isSigned ? ArrowType.ArrowInt16 : ArrowType.ArrowUInt16 }
+ if bitWidth == 32 { return intType.isSigned ? ArrowType.ArrowInt32 : ArrowType.ArrowUInt32 }
+ if bitWidth == 64 { return intType.isSigned ? ArrowType.ArrowInt64 : ArrowType.ArrowUInt64 }
+ return ArrowType.ArrowUnknown
+ case .bool:
+ return ArrowType.ArrowBool
+ case .floatingpoint:
+ let floatType = field.type(type: org_apache_arrow_flatbuf_FloatingPoint.self)!
+ switch floatType.precision {
+ case .single:
+ return ArrowType.ArrowFloat
+ case .double:
+ return ArrowType.ArrowDouble
+ default:
+ return ArrowType.ArrowUnknown
+ }
+ case .utf8:
+ return ArrowType.ArrowString
+ default:
+ return ArrowType.ArrowUnknown
+ }
+}
+
+func validateBufferIndex(_ recordBatch: org_apache_arrow_flatbuf_RecordBatch, index: Int32) throws {
+ if index >= recordBatch.buffersCount {
+ throw ArrowError.runtimeError("Buffer index is out of bounds: \(index)")
+ }
+}
+
+func validateFileData(_ data: Data) -> Bool {
+ let markerLength = FILEMARKER.utf8.count
+ let startString = String(decoding: data[..<markerLength], as: UTF8.self)
+ let endString = String(decoding: data[(data.count - markerLength)...], as: UTF8.self)
+ return startString == FILEMARKER && endString == FILEMARKER
+}
diff --git a/swift/Arrow/Sources/Arrow/ArrowSchema.swift b/swift/Arrow/Sources/Arrow/ArrowSchema.swift
index af9564aaea..4214403824 100644
--- a/swift/Arrow/Sources/Arrow/ArrowSchema.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowSchema.swift
@@ -29,8 +29,8 @@ public class ArrowField {
}
public class ArrowSchema {
- let fields: [ArrowField]
- let fieldLookup: [String: Int]
+ public let fields: [ArrowField]
+ public let fieldLookup: [String: Int]
init(_ fields: [ArrowField]) {
var fieldLookup = [String: Int]()
for (index, field) in fields.enumerated() {
@@ -41,28 +41,28 @@ public class ArrowSchema {
self.fieldLookup = fieldLookup
}
- func field(_ index: Int) -> ArrowField {
+ public func field(_ index: Int) -> ArrowField {
return self.fields[index]
}
- func fieldIndex(_ name: String) -> Int? {
+ public func fieldIndex(_ name: String) -> Int? {
return self.fieldLookup[name]
}
public class Builder {
private var fields: [ArrowField] = []
- func addField(_ field: ArrowField) -> Builder {
+ public func addField(_ field: ArrowField) -> Builder {
fields.append(field)
return self
}
- func addField(_ name: String, type: ArrowType.Info, isNullable: Bool) -> Builder {
+ public func addField(_ name: String, type: ArrowType.Info, isNullable: Bool) -> Builder {
fields.append(ArrowField(name, type: type, isNullable: isNullable))
return self
}
- func finish() -> ArrowSchema {
+ public func finish() -> ArrowSchema {
return ArrowSchema(fields)
}
}
diff --git a/swift/Arrow/Sources/Arrow/ArrowTable.swift b/swift/Arrow/Sources/Arrow/ArrowTable.swift
index 25677ba013..e5eb0d775c 100644
--- a/swift/Arrow/Sources/Arrow/ArrowTable.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowTable.swift
@@ -18,12 +18,12 @@
import Foundation
public class ChunkedArrayHolder {
- let type: ArrowType.Info
- let length: UInt
- let nullCount: UInt
- let holder: Any
+ public let type: ArrowType.Info
+ public let length: UInt
+ public let nullCount: UInt
+ public let holder: Any
- init<T>(_ chunked: ChunkedArray<T>) {
+ public init<T>(_ chunked: ChunkedArray<T>) {
self.holder = chunked
self.length = chunked.length
self.type = chunked.type
@@ -32,28 +32,28 @@ public class ChunkedArrayHolder {
}
public class ArrowColumn {
- let field: ArrowField
+ public let field: ArrowField
private let dataHolder: ChunkedArrayHolder
- var type: ArrowType.Info {get{return self.dataHolder.type}}
- var length: UInt {get{return self.dataHolder.length}}
- var nullCount: UInt {get{return self.dataHolder.nullCount}}
+ public var type: ArrowType.Info {get{return self.dataHolder.type}}
+ public var length: UInt {get{return self.dataHolder.length}}
+ public var nullCount: UInt {get{return self.dataHolder.nullCount}}
- func data<T>() -> ChunkedArray<T> {
+ public func data<T>() -> ChunkedArray<T> {
return (self.dataHolder.holder as! ChunkedArray<T>)
}
- var name: String {get{return field.name}}
- init<T>(_ field: ArrowField, chunked: ChunkedArray<T>) {
+ public var name: String {get{return field.name}}
+ public init<T>(_ field: ArrowField, chunked: ChunkedArray<T>) {
self.field = field
self.dataHolder = ChunkedArrayHolder(chunked)
}
}
public class ArrowTable {
- let schema: ArrowSchema
- var columnCount: UInt {get{return UInt(self.columns.count)}}
- let rowCount: UInt
- let columns: [ArrowColumn]
+ public let schema: ArrowSchema
+ public var columnCount: UInt {get{return UInt(self.columns.count)}}
+ public let rowCount: UInt
+ public let columns: [ArrowColumn]
init(_ schema: ArrowSchema, columns: [ArrowColumn]) {
self.schema = schema
self.columns = columns
@@ -64,35 +64,35 @@ public class ArrowTable {
let schemaBuilder = ArrowSchema.Builder()
var columns = [ArrowColumn]()
- func addColumn<T>(_ fieldName: String, arrowArray: ArrowArray<T>) throws -> Builder {
+ public func addColumn<T>(_ fieldName: String, arrowArray: ArrowArray<T>) throws -> Builder {
return self.addColumn(fieldName, chunked: try ChunkedArray([arrowArray]))
}
- func addColumn<T>(_ fieldName: String, chunked: ChunkedArray<T>) -> Builder {
+ public func addColumn<T>(_ fieldName: String, chunked: ChunkedArray<T>) -> Builder {
let field = ArrowField(fieldName, type: chunked.type, isNullable: chunked.nullCount != 0)
self.schemaBuilder.addField(field)
self.columns.append(ArrowColumn(field, chunked: chunked))
return self
}
- func addColumn<T>(_ field: ArrowField, arrowArray: ArrowArray<T>) throws -> Builder {
+ public func addColumn<T>(_ field: ArrowField, arrowArray: ArrowArray<T>) throws -> Builder {
self.schemaBuilder.addField(field)
self.columns.append(ArrowColumn(field, chunked: try ChunkedArray([arrowArray])))
return self
}
- func addColumn<T>(_ field: ArrowField, chunked: ChunkedArray<T>) -> Builder {
+ public func addColumn<T>(_ field: ArrowField, chunked: ChunkedArray<T>) -> Builder {
self.schemaBuilder.addField(field)
self.columns.append(ArrowColumn(field, chunked: chunked))
return self
}
- func addColumn(_ column: ArrowColumn) -> Builder {
+ public func addColumn(_ column: ArrowColumn) -> Builder {
self.columns.append(column)
return self
}
- func finish() -> ArrowTable {
+ public func finish() -> ArrowTable {
return ArrowTable(self.schemaBuilder.finish(), columns: self.columns)
}
}
@@ -103,17 +103,17 @@ public class RecordBatch {
var columnCount: UInt {get{return UInt(self.columns.count)}}
let columns: [ChunkedArrayHolder]
let length: UInt
- init(_ schema: ArrowSchema, columns: [ChunkedArrayHolder]) {
+ public init(_ schema: ArrowSchema, columns: [ChunkedArrayHolder]) {
self.schema = schema
self.columns = columns
self.length = columns[0].length
}
- func column(_ index: Int) -> ChunkedArrayHolder {
+ public func column(_ index: Int) -> ChunkedArrayHolder {
return self.columns[index]
}
- func column(_ name: String) -> ChunkedArrayHolder? {
+ public func column(_ name: String) -> ChunkedArrayHolder? {
if let index = self.schema.fieldIndex(name) {
return self.columns[index]
}
diff --git a/swift/Arrow/Sources/Arrow/ArrowType.swift b/swift/Arrow/Sources/Arrow/ArrowType.swift
index e136fada40..0dc998287e 100644
--- a/swift/Arrow/Sources/Arrow/ArrowType.swift
+++ b/swift/Arrow/Sources/Arrow/ArrowType.swift
@@ -17,7 +17,10 @@
import Foundation
-enum ValidationError: Error {
+func FlatBuffersVersion_23_1_4() {
+}
+
+public enum ValidationError: Error {
case unknownType
case outOfBounds(index: UInt)
case arrayHasNoElements
@@ -65,10 +68,10 @@ public class ArrowType {
public static let ArrowInt16 = Info.PrimitiveInfo(ArrowTypeId.Int16)
public static let ArrowInt32 = Info.PrimitiveInfo(ArrowTypeId.Int32)
public static let ArrowInt64 = Info.PrimitiveInfo(ArrowTypeId.Int64)
+ public static let ArrowUInt8 = Info.PrimitiveInfo(ArrowTypeId.UInt8)
public static let ArrowUInt16 = Info.PrimitiveInfo(ArrowTypeId.UInt16)
public static let ArrowUInt32 = Info.PrimitiveInfo(ArrowTypeId.UInt32)
public static let ArrowUInt64 = Info.PrimitiveInfo(ArrowTypeId.UInt64)
- public static let ArrowUInt8 = Info.PrimitiveInfo(ArrowTypeId.UInt8)
public static let ArrowFloat = Info.PrimitiveInfo(ArrowTypeId.Float)
public static let ArrowDouble = Info.PrimitiveInfo(ArrowTypeId.Double)
public static let ArrowUnknown = Info.PrimitiveInfo(ArrowTypeId.Unknown)
diff --git a/swift/Arrow/Sources/Arrow/BitUtility.swift b/swift/Arrow/Sources/Arrow/BitUtility.swift
index a4abb5941f..4c5da29803 100644
--- a/swift/Arrow/Sources/Arrow/BitUtility.swift
+++ b/swift/Arrow/Sources/Arrow/BitUtility.swift
@@ -18,25 +18,23 @@
import Foundation
class BitUtility {
- static let twoPow: [UInt8] = [1, 2, 4, 8, 16, 32, 64, 128]
static func isSet(_ bit: UInt, buffer: ArrowBuffer) -> Bool {
let byteIndex = UInt(bit / 8)
let theByte = buffer.rawPointer.load(fromByteOffset: Int(byteIndex), as: UInt8.self)
- let bitToGet = 7 - Int(bit % 8);
- return theByte & twoPow[bitToGet] > 0
+ return theByte & UInt8(1 << (bit % 8)) > 0
}
static func setBit(_ bit: UInt, buffer: ArrowBuffer) {
let byteIndex = UInt(bit / 8)
var theByte = buffer.rawPointer.load(fromByteOffset: Int(byteIndex), as: UInt8.self)
- theByte |= twoPow[7 - Int(bit % 8)]
+ theByte |= UInt8(1 << (bit % 8))
buffer.rawPointer.storeBytes(of: theByte, toByteOffset: Int(byteIndex), as: UInt8.self)
}
static func clearBit(_ bit: UInt, buffer: ArrowBuffer) {
let byteIndex = UInt(bit / 8)
var theByte = buffer.rawPointer.load(fromByteOffset: Int(byteIndex), as: UInt8.self)
- theByte &= ~twoPow[7 - Int(bit % 8)]
+ theByte &= ~(UInt8(1 << (bit % 8)))
buffer.rawPointer.storeBytes(of: theByte, toByteOffset: Int(byteIndex), as: UInt8.self)
}
}
diff --git a/swift/Arrow/Sources/Arrow/ChunkedArray.swift b/swift/Arrow/Sources/Arrow/ChunkedArray.swift
index a6cd29aece..2e060b3b66 100644
--- a/swift/Arrow/Sources/Arrow/ChunkedArray.swift
+++ b/swift/Arrow/Sources/Arrow/ChunkedArray.swift
@@ -17,14 +17,17 @@
import Foundation
-public class ChunkedArray<T> {
- let arrays: [ArrowArray<T>]
- let type: ArrowType.Info
- let nullCount: UInt
- let length: UInt
- var arrayCount: UInt {get{return UInt(self.arrays.count)}}
+public protocol AsString {
+ func asString(_ index: UInt) -> String
+}
+public class ChunkedArray<T> : AsString {
+ public let arrays: [ArrowArray<T>]
+ public let type: ArrowType.Info
+ public let nullCount: UInt
+ public let length: UInt
+ public var arrayCount: UInt {get{return UInt(self.arrays.count)}}
- init(_ arrays: [ArrowArray<T>]) throws {
+ public init(_ arrays: [ArrowArray<T>]) throws {
if arrays.count == 0 {
throw ValidationError.arrayHasNoElements
}
@@ -42,8 +45,32 @@ public class ChunkedArray<T> {
self.nullCount = nullCount
}
- subscript(_ index: UInt) -> ArrowArray<T> {
- return arrays[Int(index)]
+ public subscript(_ index: UInt) -> T? {
+ if arrays.count == 0 {
+ return nil
+ }
+
+ var localIndex = index
+ var arrayIndex = 0;
+ var len: UInt = arrays[arrayIndex].length
+ while localIndex > len {
+ arrayIndex += 1
+ if arrayIndex > arrays.count {
+ return nil
+ }
+
+ localIndex -= len
+ len = arrays[arrayIndex].length
+ }
+
+ return arrays[arrayIndex][localIndex]
}
+ public func asString(_ index: UInt) -> String {
+ if self[index] == nil {
+ return ""
+ }
+
+ return "\(self[index]!)"
+ }
}
diff --git a/swift/Arrow/Sources/Arrow/File_generated.swift b/swift/Arrow/Sources/Arrow/File_generated.swift
new file mode 100644
index 0000000000..6817c8364d
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/File_generated.swift
@@ -0,0 +1,160 @@
+// 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.
+
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+public struct org_apache_arrow_flatbuf_Block: NativeStruct, Verifiable, FlatbuffersInitializable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+
+ /// Index to the start of the RecordBlock (note this is past the Message header)
+ private var _offset: Int64
+ /// Length of the metadata
+ private var _metaDataLength: Int32
+ private let padding0__: UInt32 = 0
+ /// Length of the data (this is aligned so there can be a gap between this and
+ /// the metadata).
+ private var _bodyLength: Int64
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _offset = _accessor.readBuffer(of: Int64.self, at: 0)
+ _metaDataLength = _accessor.readBuffer(of: Int32.self, at: 8)
+ _bodyLength = _accessor.readBuffer(of: Int64.self, at: 16)
+ }
+
+ public init(offset: Int64, metaDataLength: Int32, bodyLength: Int64) {
+ _offset = offset
+ _metaDataLength = metaDataLength
+ _bodyLength = bodyLength
+ }
+
+ public init() {
+ _offset = 0
+ _metaDataLength = 0
+ _bodyLength = 0
+ }
+
+ /// Index to the start of the RecordBlock (note this is past the Message header)
+ public var offset: Int64 { _offset }
+ /// Length of the metadata
+ public var metaDataLength: Int32 { _metaDataLength }
+ /// Length of the data (this is aligned so there can be a gap between this and
+ /// the metadata).
+ public var bodyLength: Int64 { _bodyLength }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: org_apache_arrow_flatbuf_Block.self)
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Block_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var offset: Int64 { return _accessor.readBuffer(of: Int64.self, at: 0) }
+ public var metaDataLength: Int32 { return _accessor.readBuffer(of: Int32.self, at: 8) }
+ public var bodyLength: Int64 { return _accessor.readBuffer(of: Int64.self, at: 16) }
+}
+
+/// ----------------------------------------------------------------------
+/// Arrow File metadata
+///
+public struct org_apache_arrow_flatbuf_Footer: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsFooter(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Footer { return org_apache_arrow_flatbuf_Footer(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case version = 4
+ case schema = 6
+ case dictionaries = 8
+ case recordBatches = 10
+ case customMetadata = 12
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var version: org_apache_arrow_flatbuf_MetadataVersion { let o = _accessor.offset(VTOFFSET.version.v); return o == 0 ? .v1 : org_apache_arrow_flatbuf_MetadataVersion(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .v1 }
+ public var schema: org_apache_arrow_flatbuf_Schema? { let o = _accessor.offset(VTOFFSET.schema.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Schema(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public var hasDictionaries: Bool { let o = _accessor.offset(VTOFFSET.dictionaries.v); return o == 0 ? false : true }
+ public var dictionariesCount: Int32 { let o = _accessor.offset(VTOFFSET.dictionaries.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func dictionaries(at index: Int32) -> org_apache_arrow_flatbuf_Block? { let o = _accessor.offset(VTOFFSET.dictionaries.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_Block.self, offset: _accessor.vector(at: o) + index * 24) }
+ public func mutableDictionaries(at index: Int32) -> org_apache_arrow_flatbuf_Block_Mutable? { let o = _accessor.offset(VTOFFSET.dictionaries.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Block_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 24) }
+ public var hasRecordBatches: Bool { let o = _accessor.offset(VTOFFSET.recordBatches.v); return o == 0 ? false : true }
+ public var recordBatchesCount: Int32 { let o = _accessor.offset(VTOFFSET.recordBatches.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func recordBatches(at index: Int32) -> org_apache_arrow_flatbuf_Block? { let o = _accessor.offset(VTOFFSET.recordBatches.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_Block.self, offset: _accessor.vector(at: o) + index * 24) }
+ public func mutableRecordBatches(at index: Int32) -> org_apache_arrow_flatbuf_Block_Mutable? { let o = _accessor.offset(VTOFFSET.recordBatches.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Block_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 24) }
+ /// User-defined metadata
+ public var hasCustomMetadata: Bool { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? false : true }
+ public var customMetadataCount: Int32 { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func customMetadata(at index: Int32) -> org_apache_arrow_flatbuf_KeyValue? { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? nil : org_apache_arrow_flatbuf_KeyValue(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ public static func startFooter(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
+ public static func add(version: org_apache_arrow_flatbuf_MetadataVersion, _ fbb: inout FlatBufferBuilder) { fbb.add(element: version.rawValue, def: 0, at: VTOFFSET.version.p) }
+ public static func add(schema: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: schema, at: VTOFFSET.schema.p) }
+ public static func addVectorOf(dictionaries: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: dictionaries, at: VTOFFSET.dictionaries.p) }
+ public static func startVectorOfDictionaries(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Block>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Block>.alignment)
+ }
+ public static func addVectorOf(recordBatches: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: recordBatches, at: VTOFFSET.recordBatches.p) }
+ public static func startVectorOfRecordBatches(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Block>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Block>.alignment)
+ }
+ public static func addVectorOf(customMetadata: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: customMetadata, at: VTOFFSET.customMetadata.p) }
+ public static func endFooter(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createFooter(
+ _ fbb: inout FlatBufferBuilder,
+ version: org_apache_arrow_flatbuf_MetadataVersion = .v1,
+ schemaOffset schema: Offset = Offset(),
+ dictionariesVectorOffset dictionaries: Offset = Offset(),
+ recordBatchesVectorOffset recordBatches: Offset = Offset(),
+ customMetadataVectorOffset customMetadata: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Footer.startFooter(&fbb)
+ org_apache_arrow_flatbuf_Footer.add(version: version, &fbb)
+ org_apache_arrow_flatbuf_Footer.add(schema: schema, &fbb)
+ org_apache_arrow_flatbuf_Footer.addVectorOf(dictionaries: dictionaries, &fbb)
+ org_apache_arrow_flatbuf_Footer.addVectorOf(recordBatches: recordBatches, &fbb)
+ org_apache_arrow_flatbuf_Footer.addVectorOf(customMetadata: customMetadata, &fbb)
+ return org_apache_arrow_flatbuf_Footer.endFooter(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.version.p, fieldName: "version", required: false, type: org_apache_arrow_flatbuf_MetadataVersion.self)
+ try _v.visit(field: VTOFFSET.schema.p, fieldName: "schema", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_Schema>.self)
+ try _v.visit(field: VTOFFSET.dictionaries.p, fieldName: "dictionaries", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Block, org_apache_arrow_flatbuf_Block>>.self)
+ try _v.visit(field: VTOFFSET.recordBatches.p, fieldName: "recordBatches", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Block, org_apache_arrow_flatbuf_Block>>.self)
+ try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_KeyValue>, org_apache_arrow_flatbuf_KeyValue>>.self)
+ _v.finish()
+ }
+}
+
diff --git a/swift/Arrow/Sources/Arrow/Message_generated.swift b/swift/Arrow/Sources/Arrow/Message_generated.swift
new file mode 100644
index 0000000000..99a3d1ab45
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/Message_generated.swift
@@ -0,0 +1,421 @@
+// 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.
+
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+public enum org_apache_arrow_flatbuf_CompressionType: Int8, Enum, Verifiable {
+ public typealias T = Int8
+ public static var byteSize: Int { return MemoryLayout<Int8>.size }
+ public var value: Int8 { return self.rawValue }
+ case lz4Frame = 0
+ case zstd = 1
+
+ public static var max: org_apache_arrow_flatbuf_CompressionType { return .zstd }
+ public static var min: org_apache_arrow_flatbuf_CompressionType { return .lz4Frame }
+}
+
+
+/// 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
+public enum org_apache_arrow_flatbuf_BodyCompressionMethod: Int8, Enum, Verifiable {
+ public typealias T = Int8
+ public static var byteSize: Int { return MemoryLayout<Int8>.size }
+ public var value: Int8 { return self.rawValue }
+ /// 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.
+ case buffer = 0
+
+ public static var max: org_apache_arrow_flatbuf_BodyCompressionMethod { return .buffer }
+ public static var min: org_apache_arrow_flatbuf_BodyCompressionMethod { return .buffer }
+}
+
+
+/// ----------------------------------------------------------------------
+/// The root Message type
+/// This union enables us to easily send different message types without
+/// redundant storage, and in the future we can easily add new message types.
+///
+/// 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
+public enum org_apache_arrow_flatbuf_MessageHeader: UInt8, UnionEnum {
+ public typealias T = UInt8
+
+ public init?(value: T) {
+ self.init(rawValue: value)
+ }
+
+ public static var byteSize: Int { return MemoryLayout<UInt8>.size }
+ public var value: UInt8 { return self.rawValue }
+ case none_ = 0
+ case schema = 1
+ case dictionarybatch = 2
+ case recordbatch = 3
+ case tensor = 4
+ case sparsetensor = 5
+
+ public static var max: org_apache_arrow_flatbuf_MessageHeader { return .sparsetensor }
+ public static var min: org_apache_arrow_flatbuf_MessageHeader { return .none_ }
+}
+
+
+/// ----------------------------------------------------------------------
+/// Data structures for describing a table row batch (a collection of
+/// equal-length Arrow arrays)
+/// Metadata about a field at some level of a nested type tree (but not
+/// its children).
+///
+/// For example, a List<Int16> 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
+public struct org_apache_arrow_flatbuf_FieldNode: NativeStruct, Verifiable, FlatbuffersInitializable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+
+ /// The number of value slots in the Arrow array at this level of a nested
+ /// tree
+ private var _length: Int64
+ /// The number of observed nulls. Fields with null_count == 0 may choose not
+ /// to write their physical validity bitmap out as a materialized buffer,
+ /// instead setting the length of the bitmap buffer to 0.
+ private var _nullCount: Int64
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _length = _accessor.readBuffer(of: Int64.self, at: 0)
+ _nullCount = _accessor.readBuffer(of: Int64.self, at: 8)
+ }
+
+ public init(length: Int64, nullCount: Int64) {
+ _length = length
+ _nullCount = nullCount
+ }
+
+ public init() {
+ _length = 0
+ _nullCount = 0
+ }
+
+ /// The number of value slots in the Arrow array at this level of a nested
+ /// tree
+ public var length: Int64 { _length }
+ /// The number of observed nulls. Fields with null_count == 0 may choose not
+ /// to write their physical validity bitmap out as a materialized buffer,
+ /// instead setting the length of the bitmap buffer to 0.
+ public var nullCount: Int64 { _nullCount }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: org_apache_arrow_flatbuf_FieldNode.self)
+ }
+}
+
+/// ----------------------------------------------------------------------
+/// Data structures for describing a table row batch (a collection of
+/// equal-length Arrow arrays)
+/// Metadata about a field at some level of a nested type tree (but not
+/// its children).
+///
+/// For example, a List<Int16> 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
+public struct org_apache_arrow_flatbuf_FieldNode_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var length: Int64 { return _accessor.readBuffer(of: Int64.self, at: 0) }
+ public var nullCount: Int64 { return _accessor.readBuffer(of: Int64.self, at: 8) }
+}
+
+/// Optional compression for the memory buffers constituting IPC message
+/// bodies. Intended for use with RecordBatch but could be used for other
+/// message types
+public struct org_apache_arrow_flatbuf_BodyCompression: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsBodyCompression(bb: ByteBuffer) -> org_apache_arrow_flatbuf_BodyCompression { return org_apache_arrow_flatbuf_BodyCompression(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case codec = 4
+ case method = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Compressor library.
+ /// For LZ4_FRAME, each compressed buffer must consist of a single frame.
+ public var codec: org_apache_arrow_flatbuf_CompressionType { let o = _accessor.offset(VTOFFSET.codec.v); return o == 0 ? .lz4Frame : org_apache_arrow_flatbuf_CompressionType(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .lz4Frame }
+ /// Indicates the way the record batch body was compressed
+ public var method: org_apache_arrow_flatbuf_BodyCompressionMethod { let o = _accessor.offset(VTOFFSET.method.v); return o == 0 ? .buffer : org_apache_arrow_flatbuf_BodyCompressionMethod(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .buffer }
+ public static func startBodyCompression(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(codec: org_apache_arrow_flatbuf_CompressionType, _ fbb: inout FlatBufferBuilder) { fbb.add(element: codec.rawValue, def: 0, at: VTOFFSET.codec.p) }
+ public static func add(method: org_apache_arrow_flatbuf_BodyCompressionMethod, _ fbb: inout FlatBufferBuilder) { fbb.add(element: method.rawValue, def: 0, at: VTOFFSET.method.p) }
+ public static func endBodyCompression(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createBodyCompression(
+ _ fbb: inout FlatBufferBuilder,
+ codec: org_apache_arrow_flatbuf_CompressionType = .lz4Frame,
+ method: org_apache_arrow_flatbuf_BodyCompressionMethod = .buffer
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_BodyCompression.startBodyCompression(&fbb)
+ org_apache_arrow_flatbuf_BodyCompression.add(codec: codec, &fbb)
+ org_apache_arrow_flatbuf_BodyCompression.add(method: method, &fbb)
+ return org_apache_arrow_flatbuf_BodyCompression.endBodyCompression(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.codec.p, fieldName: "codec", required: false, type: org_apache_arrow_flatbuf_CompressionType.self)
+ try _v.visit(field: VTOFFSET.method.p, fieldName: "method", required: false, type: org_apache_arrow_flatbuf_BodyCompressionMethod.self)
+ _v.finish()
+ }
+}
+
+/// A data header describing the shared memory layout of a "record" or "row"
+/// batch. Some systems call this a "row batch" internally and others a "record
+/// batch".
+public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsRecordBatch(bb: ByteBuffer) -> org_apache_arrow_flatbuf_RecordBatch { return org_apache_arrow_flatbuf_RecordBatch(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case length = 4
+ case nodes = 6
+ case buffers = 8
+ case compression = 10
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// number of records / rows. The arrays in the batch should all have this
+ /// length
+ public var length: Int64 { let o = _accessor.offset(VTOFFSET.length.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ /// Nodes correspond to the pre-ordered flattened logical schema
+ public var hasNodes: Bool { let o = _accessor.offset(VTOFFSET.nodes.v); return o == 0 ? false : true }
+ public var nodesCount: Int32 { let o = _accessor.offset(VTOFFSET.nodes.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func nodes(at index: Int32) -> org_apache_arrow_flatbuf_FieldNode? { let o = _accessor.offset(VTOFFSET.nodes.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_FieldNode.self, offset: _accessor.vector(at: o) + index * 16) }
+ public func mutableNodes(at index: Int32) -> org_apache_arrow_flatbuf_FieldNode_Mutable? { let o = _accessor.offset(VTOFFSET.nodes.v); return o == 0 ? nil : org_apache_arrow_flatbuf_FieldNode_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 16) }
+ /// Buffers correspond to the pre-ordered flattened buffer tree
+ ///
+ /// The number of buffers appended to this list depends on the schema. For
+ /// 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
+ public var hasBuffers: Bool { let o = _accessor.offset(VTOFFSET.buffers.v); return o == 0 ? false : true }
+ public var buffersCount: Int32 { let o = _accessor.offset(VTOFFSET.buffers.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func buffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer? { let o = _accessor.offset(VTOFFSET.buffers.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_Buffer.self, offset: _accessor.vector(at: o) + index * 16) }
+ public func mutableBuffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer_Mutable? { let o = _accessor.offset(VTOFFSET.buffers.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 16) }
+ /// Optional compression of the message body
+ public var compression: org_apache_arrow_flatbuf_BodyCompression? { let o = _accessor.offset(VTOFFSET.compression.v); return o == 0 ? nil : org_apache_arrow_flatbuf_BodyCompression(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ public static func startRecordBatch(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
+ public static func add(length: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: length, def: 0, at: VTOFFSET.length.p) }
+ public static func addVectorOf(nodes: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: nodes, at: VTOFFSET.nodes.p) }
+ public static func startVectorOfNodes(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_FieldNode>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_FieldNode>.alignment)
+ }
+ public static func addVectorOf(buffers: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: buffers, at: VTOFFSET.buffers.p) }
+ public static func startVectorOfBuffers(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Buffer>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Buffer>.alignment)
+ }
+ public static func add(compression: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: compression, at: VTOFFSET.compression.p) }
+ public static func endRecordBatch(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createRecordBatch(
+ _ fbb: inout FlatBufferBuilder,
+ length: Int64 = 0,
+ nodesVectorOffset nodes: Offset = Offset(),
+ buffersVectorOffset buffers: Offset = Offset(),
+ compressionOffset compression: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_RecordBatch.startRecordBatch(&fbb)
+ org_apache_arrow_flatbuf_RecordBatch.add(length: length, &fbb)
+ org_apache_arrow_flatbuf_RecordBatch.addVectorOf(nodes: nodes, &fbb)
+ org_apache_arrow_flatbuf_RecordBatch.addVectorOf(buffers: buffers, &fbb)
+ org_apache_arrow_flatbuf_RecordBatch.add(compression: compression, &fbb)
+ return org_apache_arrow_flatbuf_RecordBatch.endRecordBatch(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.length.p, fieldName: "length", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.nodes.p, fieldName: "nodes", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_FieldNode, org_apache_arrow_flatbuf_FieldNode>>.self)
+ try _v.visit(field: VTOFFSET.buffers.p, fieldName: "buffers", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer>>.self)
+ try _v.visit(field: VTOFFSET.compression.p, fieldName: "compression", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_BodyCompression>.self)
+ _v.finish()
+ }
+}
+
+/// For sending dictionary encoding information. Any Field can be
+/// dictionary-encoded, but in this case none of its children may be
+/// dictionary-encoded.
+/// There is one vector / column per dictionary, but that vector / column
+/// may be spread across multiple dictionary batches by using the isDelta
+/// flag
+public struct org_apache_arrow_flatbuf_DictionaryBatch: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsDictionaryBatch(bb: ByteBuffer) -> org_apache_arrow_flatbuf_DictionaryBatch { return org_apache_arrow_flatbuf_DictionaryBatch(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case id = 4
+ case data = 6
+ case isDelta = 8
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ public var data: org_apache_arrow_flatbuf_RecordBatch? { let o = _accessor.offset(VTOFFSET.data.v); return o == 0 ? nil : org_apache_arrow_flatbuf_RecordBatch(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// If isDelta is true the values in the dictionary are to be appended to a
+ /// dictionary with the indicated id. If isDelta is false this dictionary
+ /// should replace the existing dictionary.
+ public var isDelta: Bool { let o = _accessor.offset(VTOFFSET.isDelta.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public static func startDictionaryBatch(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
+ public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VTOFFSET.id.p) }
+ public static func add(data: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: data, at: VTOFFSET.data.p) }
+ public static func add(isDelta: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: isDelta, def: false,
+ at: VTOFFSET.isDelta.p) }
+ public static func endDictionaryBatch(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createDictionaryBatch(
+ _ fbb: inout FlatBufferBuilder,
+ id: Int64 = 0,
+ dataOffset data: Offset = Offset(),
+ isDelta: Bool = false
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_DictionaryBatch.startDictionaryBatch(&fbb)
+ org_apache_arrow_flatbuf_DictionaryBatch.add(id: id, &fbb)
+ org_apache_arrow_flatbuf_DictionaryBatch.add(data: data, &fbb)
+ org_apache_arrow_flatbuf_DictionaryBatch.add(isDelta: isDelta, &fbb)
+ return org_apache_arrow_flatbuf_DictionaryBatch.endDictionaryBatch(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.id.p, fieldName: "id", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.data.p, fieldName: "data", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_RecordBatch>.self)
+ try _v.visit(field: VTOFFSET.isDelta.p, fieldName: "isDelta", required: false, type: Bool.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Message: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsMessage(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Message { return org_apache_arrow_flatbuf_Message(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case version = 4
+ case headerType = 6
+ case header = 8
+ case bodyLength = 10
+ case customMetadata = 12
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var version: org_apache_arrow_flatbuf_MetadataVersion { let o = _accessor.offset(VTOFFSET.version.v); return o == 0 ? .v1 : org_apache_arrow_flatbuf_MetadataVersion(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .v1 }
+ public var headerType: org_apache_arrow_flatbuf_MessageHeader { let o = _accessor.offset(VTOFFSET.headerType.v); return o == 0 ? .none_ : org_apache_arrow_flatbuf_MessageHeader(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
+ public func header<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.header.v); return o == 0 ? nil : _accessor.union(o) }
+ public var bodyLength: Int64 { let o = _accessor.offset(VTOFFSET.bodyLength.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ public var hasCustomMetadata: Bool { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? false : true }
+ public var customMetadataCount: Int32 { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func customMetadata(at index: Int32) -> org_apache_arrow_flatbuf_KeyValue? { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? nil : org_apache_arrow_flatbuf_KeyValue(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ public static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
+ public static func add(version: org_apache_arrow_flatbuf_MetadataVersion, _ fbb: inout FlatBufferBuilder) { fbb.add(element: version.rawValue, def: 0, at: VTOFFSET.version.p) }
+ public static func add(headerType: org_apache_arrow_flatbuf_MessageHeader, _ fbb: inout FlatBufferBuilder) { fbb.add(element: headerType.rawValue, def: 0, at: VTOFFSET.headerType.p) }
+ public static func add(header: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: header, at: VTOFFSET.header.p) }
+ public static func add(bodyLength: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: bodyLength, def: 0, at: VTOFFSET.bodyLength.p) }
+ public static func addVectorOf(customMetadata: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: customMetadata, at: VTOFFSET.customMetadata.p) }
+ public static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createMessage(
+ _ fbb: inout FlatBufferBuilder,
+ version: org_apache_arrow_flatbuf_MetadataVersion = .v1,
+ headerType: org_apache_arrow_flatbuf_MessageHeader = .none_,
+ headerOffset header: Offset = Offset(),
+ bodyLength: Int64 = 0,
+ customMetadataVectorOffset customMetadata: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Message.startMessage(&fbb)
+ org_apache_arrow_flatbuf_Message.add(version: version, &fbb)
+ org_apache_arrow_flatbuf_Message.add(headerType: headerType, &fbb)
+ org_apache_arrow_flatbuf_Message.add(header: header, &fbb)
+ org_apache_arrow_flatbuf_Message.add(bodyLength: bodyLength, &fbb)
+ org_apache_arrow_flatbuf_Message.addVectorOf(customMetadata: customMetadata, &fbb)
+ return org_apache_arrow_flatbuf_Message.endMessage(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.version.p, fieldName: "version", required: false, type: org_apache_arrow_flatbuf_MetadataVersion.self)
+ try _v.visit(unionKey: VTOFFSET.headerType.p, unionField: VTOFFSET.header.p, unionKeyName: "headerType", fieldName: "header", required: false, completion: { (verifier, key: org_apache_arrow_flatbuf_MessageHeader, pos) in
+ switch key {
+ case .none_:
+ break // NOTE - SWIFT doesnt support none
+ case .schema:
+ try ForwardOffset<org_apache_arrow_flatbuf_Schema>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Schema.self)
+ case .dictionarybatch:
+ try ForwardOffset<org_apache_arrow_flatbuf_DictionaryBatch>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_DictionaryBatch.self)
+ case .recordbatch:
+ try ForwardOffset<org_apache_arrow_flatbuf_RecordBatch>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RecordBatch.self)
+ case .tensor:
+ try ForwardOffset<org_apache_arrow_flatbuf_Tensor>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Tensor.self)
+ case .sparsetensor:
+ try ForwardOffset<org_apache_arrow_flatbuf_SparseTensor>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseTensor.self)
+ }
+ })
+ try _v.visit(field: VTOFFSET.bodyLength.p, fieldName: "bodyLength", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_KeyValue>, org_apache_arrow_flatbuf_KeyValue>>.self)
+ _v.finish()
+ }
+}
+
diff --git a/swift/Arrow/Sources/Arrow/Schema_generated.swift b/swift/Arrow/Sources/Arrow/Schema_generated.swift
new file mode 100644
index 0000000000..990d9c3df1
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/Schema_generated.swift
@@ -0,0 +1,1479 @@
+// 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.
+
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+public enum org_apache_arrow_flatbuf_MetadataVersion: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ /// 0.1.0 (October 2016).
+ case v1 = 0
+ /// 0.2.0 (February 2017). Non-backwards compatible with V1.
+ case v2 = 1
+ /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.
+ case v3 = 2
+ /// >= 0.8.0 (December 2017). Non-backwards compatible with V3.
+ case v4 = 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.
+ case v5 = 4
+
+ public static var max: org_apache_arrow_flatbuf_MetadataVersion { return .v5 }
+ public static var min: org_apache_arrow_flatbuf_MetadataVersion { return .v1 }
+}
+
+
+/// 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.
+public enum org_apache_arrow_flatbuf_Feature: Int64, Enum, Verifiable {
+ public typealias T = Int64
+ public static var byteSize: Int { return MemoryLayout<Int64>.size }
+ public var value: Int64 { return self.rawValue }
+ /// Needed to make flatbuffers happy.
+ case unused = 0
+ /// The stream makes use of multiple full dictionaries with the
+ /// same ID and assumes clients implement dictionary replacement
+ /// correctly.
+ case dictionaryReplacement = 1
+ /// The stream makes use of compressed bodies as described
+ /// in Message.fbs.
+ case compressedBody = 2
+
+ public static var max: org_apache_arrow_flatbuf_Feature { return .compressedBody }
+ public static var min: org_apache_arrow_flatbuf_Feature { return .unused }
+}
+
+
+public enum org_apache_arrow_flatbuf_UnionMode: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case sparse = 0
+ case dense = 1
+
+ public static var max: org_apache_arrow_flatbuf_UnionMode { return .dense }
+ public static var min: org_apache_arrow_flatbuf_UnionMode { return .sparse }
+}
+
+
+public enum org_apache_arrow_flatbuf_Precision: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case half = 0
+ case single = 1
+ case double = 2
+
+ public static var max: org_apache_arrow_flatbuf_Precision { return .double }
+ public static var min: org_apache_arrow_flatbuf_Precision { return .half }
+}
+
+
+public enum org_apache_arrow_flatbuf_DateUnit: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case day = 0
+ case millisecond = 1
+
+ public static var max: org_apache_arrow_flatbuf_DateUnit { return .millisecond }
+ public static var min: org_apache_arrow_flatbuf_DateUnit { return .day }
+}
+
+
+public enum org_apache_arrow_flatbuf_TimeUnit: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case second = 0
+ case millisecond = 1
+ case microsecond = 2
+ case nanosecond = 3
+
+ public static var max: org_apache_arrow_flatbuf_TimeUnit { return .nanosecond }
+ public static var min: org_apache_arrow_flatbuf_TimeUnit { return .second }
+}
+
+
+public enum org_apache_arrow_flatbuf_IntervalUnit: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case yearMonth = 0
+ case dayTime = 1
+ case monthDayNano = 2
+
+ public static var max: org_apache_arrow_flatbuf_IntervalUnit { return .monthDayNano }
+ public static var min: org_apache_arrow_flatbuf_IntervalUnit { return .yearMonth }
+}
+
+
+/// ----------------------------------------------------------------------
+/// Top-level Type value, enabling extensible type-specific metadata. We can
+/// add new logical types to Type without breaking backwards compatibility
+public enum org_apache_arrow_flatbuf_Type_: UInt8, UnionEnum {
+ public typealias T = UInt8
+
+ public init?(value: T) {
+ self.init(rawValue: value)
+ }
+
+ public static var byteSize: Int { return MemoryLayout<UInt8>.size }
+ public var value: UInt8 { return self.rawValue }
+ case none_ = 0
+ case null = 1
+ case int = 2
+ case floatingpoint = 3
+ case binary = 4
+ case utf8 = 5
+ case bool = 6
+ case decimal = 7
+ case date = 8
+ case time = 9
+ case timestamp = 10
+ case interval = 11
+ case list = 12
+ case struct_ = 13
+ case union = 14
+ case fixedsizebinary = 15
+ case fixedsizelist = 16
+ case map = 17
+ case duration = 18
+ case largebinary = 19
+ case largeutf8 = 20
+ case largelist = 21
+ case runendencoded = 22
+
+ public static var max: org_apache_arrow_flatbuf_Type_ { return .runendencoded }
+ public static var min: org_apache_arrow_flatbuf_Type_ { return .none_ }
+}
+
+
+/// ----------------------------------------------------------------------
+/// 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
+public enum org_apache_arrow_flatbuf_DictionaryKind: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case densearray = 0
+
+ public static var max: org_apache_arrow_flatbuf_DictionaryKind { return .densearray }
+ public static var min: org_apache_arrow_flatbuf_DictionaryKind { return .densearray }
+}
+
+
+/// ----------------------------------------------------------------------
+/// Endianness of the platform producing the data
+public enum org_apache_arrow_flatbuf_Endianness: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case little = 0
+ case big = 1
+
+ public static var max: org_apache_arrow_flatbuf_Endianness { return .big }
+ public static var min: org_apache_arrow_flatbuf_Endianness { return .little }
+}
+
+
+/// ----------------------------------------------------------------------
+/// A Buffer represents a single contiguous memory segment
+public struct org_apache_arrow_flatbuf_Buffer: NativeStruct, Verifiable, FlatbuffersInitializable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+
+ /// The relative offset into the shared memory page where the bytes for this
+ /// buffer starts
+ private var _offset: Int64
+ /// The absolute length (in bytes) of the memory buffer. The memory is found
+ /// from offset (inclusive) to offset + length (non-inclusive). When building
+ /// messages using the encapsulated IPC message, padding bytes may be written
+ /// after a buffer, but such padding bytes do not need to be accounted for in
+ /// the size here.
+ private var _length: Int64
+
+ public init(_ bb: ByteBuffer, o: Int32) {
+ let _accessor = Struct(bb: bb, position: o)
+ _offset = _accessor.readBuffer(of: Int64.self, at: 0)
+ _length = _accessor.readBuffer(of: Int64.self, at: 8)
+ }
+
+ public init(offset: Int64, length: Int64) {
+ _offset = offset
+ _length = length
+ }
+
+ public init() {
+ _offset = 0
+ _length = 0
+ }
+
+ /// The relative offset into the shared memory page where the bytes for this
+ /// buffer starts
+ public var offset: Int64 { _offset }
+ /// The absolute length (in bytes) of the memory buffer. The memory is found
+ /// from offset (inclusive) to offset + length (non-inclusive). When building
+ /// messages using the encapsulated IPC message, padding bytes may be written
+ /// after a buffer, but such padding bytes do not need to be accounted for in
+ /// the size here.
+ public var length: Int64 { _length }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ try verifier.inBuffer(position: position, of: org_apache_arrow_flatbuf_Buffer.self)
+ }
+}
+
+/// ----------------------------------------------------------------------
+/// A Buffer represents a single contiguous memory segment
+public struct org_apache_arrow_flatbuf_Buffer_Mutable: FlatBufferObject {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Struct
+
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
+
+ public var offset: Int64 { return _accessor.readBuffer(of: Int64.self, at: 0) }
+ public var length: Int64 { return _accessor.readBuffer(of: Int64.self, at: 8) }
+}
+
+/// These are stored in the flatbuffer in the Type union below
+public struct org_apache_arrow_flatbuf_Null: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsNull(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Null { return org_apache_arrow_flatbuf_Null(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startNull(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endNull(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// A Struct_ in the flatbuffer metadata is the same as an Arrow Struct
+/// (according to the physical memory layout). We used Struct_ here as
+/// Struct is a reserved word in Flatbuffers
+public struct org_apache_arrow_flatbuf_Struct_: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsStruct_(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Struct_ { return org_apache_arrow_flatbuf_Struct_(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startStruct_(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endStruct_(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_List: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsList(bb: ByteBuffer) -> org_apache_arrow_flatbuf_List { return org_apache_arrow_flatbuf_List(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startList(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endList(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// Same as List, but with 64-bit offsets, allowing to represent
+/// extremely large data values.
+public struct org_apache_arrow_flatbuf_LargeList: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsLargeList(bb: ByteBuffer) -> org_apache_arrow_flatbuf_LargeList { return org_apache_arrow_flatbuf_LargeList(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startLargeList(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endLargeList(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_FixedSizeList: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsFixedSizeList(bb: ByteBuffer) -> org_apache_arrow_flatbuf_FixedSizeList { return org_apache_arrow_flatbuf_FixedSizeList(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case listSize = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Number of list items per value
+ public var listSize: Int32 { let o = _accessor.offset(VTOFFSET.listSize.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
+ public static func startFixedSizeList(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(listSize: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: listSize, def: 0, at: VTOFFSET.listSize.p) }
+ public static func endFixedSizeList(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createFixedSizeList(
+ _ fbb: inout FlatBufferBuilder,
+ listSize: Int32 = 0
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_FixedSizeList.startFixedSizeList(&fbb)
+ org_apache_arrow_flatbuf_FixedSizeList.add(listSize: listSize, &fbb)
+ return org_apache_arrow_flatbuf_FixedSizeList.endFixedSizeList(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.listSize.p, fieldName: "listSize", required: false, type: Int32.self)
+ _v.finish()
+ }
+}
+
+/// A Map is a logical nested type that is represented as
+///
+/// List<entries: Struct<key: K, value: V>>
+///
+/// In this layout, the keys and values are each respectively contiguous. We do
+/// not constrain the key and value types, so the application is responsible
+/// for ensuring that the keys are hashable and unique. Whether the keys are sorted
+/// may be set in the metadata for this field.
+///
+/// In a field with Map type, the field has a child Struct field, which then
+/// has two children: key type and the second the value type. The names of the
+/// child fields may be respectively "entries", "key", and "value", but this is
+/// 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
+/// for Map can make Map an alias for List. The "layout" attribute for the Map
+/// field must have the same contents as a List.
+public struct org_apache_arrow_flatbuf_Map: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsMap(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Map { return org_apache_arrow_flatbuf_Map(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case keysSorted = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Set to true if the keys within each value are sorted
+ public var keysSorted: Bool { let o = _accessor.offset(VTOFFSET.keysSorted.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public static func startMap(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(keysSorted: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: keysSorted, def: false,
+ at: VTOFFSET.keysSorted.p) }
+ public static func endMap(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createMap(
+ _ fbb: inout FlatBufferBuilder,
+ keysSorted: Bool = false
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Map.startMap(&fbb)
+ org_apache_arrow_flatbuf_Map.add(keysSorted: keysSorted, &fbb)
+ return org_apache_arrow_flatbuf_Map.endMap(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.keysSorted.p, fieldName: "keysSorted", required: false, type: Bool.self)
+ _v.finish()
+ }
+}
+
+/// 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
+public struct org_apache_arrow_flatbuf_Union: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsUnion(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Union { return org_apache_arrow_flatbuf_Union(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case mode = 4
+ case typeIds = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var mode: org_apache_arrow_flatbuf_UnionMode { let o = _accessor.offset(VTOFFSET.mode.v); return o == 0 ? .sparse : org_apache_arrow_flatbuf_UnionMode(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .sparse }
+ public var hasTypeIds: Bool { let o = _accessor.offset(VTOFFSET.typeIds.v); return o == 0 ? false : true }
+ public var typeIdsCount: Int32 { let o = _accessor.offset(VTOFFSET.typeIds.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func typeIds(at index: Int32) -> Int32 { let o = _accessor.offset(VTOFFSET.typeIds.v); return o == 0 ? 0 : _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4) }
+ public var typeIds: [Int32] { return _accessor.getVector(at: VTOFFSET.typeIds.v) ?? [] }
+ public static func startUnion(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(mode: org_apache_arrow_flatbuf_UnionMode, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mode.rawValue, def: 0, at: VTOFFSET.mode.p) }
+ public static func addVectorOf(typeIds: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: typeIds, at: VTOFFSET.typeIds.p) }
+ public static func endUnion(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createUnion(
+ _ fbb: inout FlatBufferBuilder,
+ mode: org_apache_arrow_flatbuf_UnionMode = .sparse,
+ typeIdsVectorOffset typeIds: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Union.startUnion(&fbb)
+ org_apache_arrow_flatbuf_Union.add(mode: mode, &fbb)
+ org_apache_arrow_flatbuf_Union.addVectorOf(typeIds: typeIds, &fbb)
+ return org_apache_arrow_flatbuf_Union.endUnion(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.mode.p, fieldName: "mode", required: false, type: org_apache_arrow_flatbuf_UnionMode.self)
+ try _v.visit(field: VTOFFSET.typeIds.p, fieldName: "typeIds", required: false, type: ForwardOffset<Vector<Int32, Int32>>.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Int: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsInt(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Int { return org_apache_arrow_flatbuf_Int(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case bitWidth = 4
+ case isSigned = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var bitWidth: Int32 { let o = _accessor.offset(VTOFFSET.bitWidth.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
+ public var isSigned: Bool { let o = _accessor.offset(VTOFFSET.isSigned.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public static func startInt(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(bitWidth: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: bitWidth, def: 0, at: VTOFFSET.bitWidth.p) }
+ public static func add(isSigned: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: isSigned, def: false,
+ at: VTOFFSET.isSigned.p) }
+ public static func endInt(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createInt(
+ _ fbb: inout FlatBufferBuilder,
+ bitWidth: Int32 = 0,
+ isSigned: Bool = false
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Int.startInt(&fbb)
+ org_apache_arrow_flatbuf_Int.add(bitWidth: bitWidth, &fbb)
+ org_apache_arrow_flatbuf_Int.add(isSigned: isSigned, &fbb)
+ return org_apache_arrow_flatbuf_Int.endInt(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.bitWidth.p, fieldName: "bitWidth", required: false, type: Int32.self)
+ try _v.visit(field: VTOFFSET.isSigned.p, fieldName: "isSigned", required: false, type: Bool.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_FloatingPoint: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsFloatingPoint(bb: ByteBuffer) -> org_apache_arrow_flatbuf_FloatingPoint { return org_apache_arrow_flatbuf_FloatingPoint(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case precision = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var precision: org_apache_arrow_flatbuf_Precision { let o = _accessor.offset(VTOFFSET.precision.v); return o == 0 ? .half : org_apache_arrow_flatbuf_Precision(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .half }
+ public static func startFloatingPoint(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(precision: org_apache_arrow_flatbuf_Precision, _ fbb: inout FlatBufferBuilder) { fbb.add(element: precision.rawValue, def: 0, at: VTOFFSET.precision.p) }
+ public static func endFloatingPoint(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createFloatingPoint(
+ _ fbb: inout FlatBufferBuilder,
+ precision: org_apache_arrow_flatbuf_Precision = .half
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_FloatingPoint.startFloatingPoint(&fbb)
+ org_apache_arrow_flatbuf_FloatingPoint.add(precision: precision, &fbb)
+ return org_apache_arrow_flatbuf_FloatingPoint.endFloatingPoint(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.precision.p, fieldName: "precision", required: false, type: org_apache_arrow_flatbuf_Precision.self)
+ _v.finish()
+ }
+}
+
+/// Unicode with UTF-8 encoding
+public struct org_apache_arrow_flatbuf_Utf8: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsUtf8(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Utf8 { return org_apache_arrow_flatbuf_Utf8(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startUtf8(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endUtf8(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// Opaque binary data
+public struct org_apache_arrow_flatbuf_Binary: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsBinary(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Binary { return org_apache_arrow_flatbuf_Binary(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startBinary(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endBinary(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// Same as Utf8, but with 64-bit offsets, allowing to represent
+/// extremely large data values.
+public struct org_apache_arrow_flatbuf_LargeUtf8: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsLargeUtf8(bb: ByteBuffer) -> org_apache_arrow_flatbuf_LargeUtf8 { return org_apache_arrow_flatbuf_LargeUtf8(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startLargeUtf8(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endLargeUtf8(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// Same as Binary, but with 64-bit offsets, allowing to represent
+/// extremely large data values.
+public struct org_apache_arrow_flatbuf_LargeBinary: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsLargeBinary(bb: ByteBuffer) -> org_apache_arrow_flatbuf_LargeBinary { return org_apache_arrow_flatbuf_LargeBinary(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startLargeBinary(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endLargeBinary(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_FixedSizeBinary: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsFixedSizeBinary(bb: ByteBuffer) -> org_apache_arrow_flatbuf_FixedSizeBinary { return org_apache_arrow_flatbuf_FixedSizeBinary(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case byteWidth = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Number of bytes per value
+ public var byteWidth: Int32 { let o = _accessor.offset(VTOFFSET.byteWidth.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
+ public static func startFixedSizeBinary(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(byteWidth: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: byteWidth, def: 0, at: VTOFFSET.byteWidth.p) }
+ public static func endFixedSizeBinary(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createFixedSizeBinary(
+ _ fbb: inout FlatBufferBuilder,
+ byteWidth: Int32 = 0
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_FixedSizeBinary.startFixedSizeBinary(&fbb)
+ org_apache_arrow_flatbuf_FixedSizeBinary.add(byteWidth: byteWidth, &fbb)
+ return org_apache_arrow_flatbuf_FixedSizeBinary.endFixedSizeBinary(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.byteWidth.p, fieldName: "byteWidth", required: false, type: Int32.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Bool: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsBool(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Bool { return org_apache_arrow_flatbuf_Bool(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startBool(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endBool(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// Contains two child arrays, run_ends and values.
+/// The run_ends child array must be a 16/32/64-bit integer array
+/// which encodes the indices at which the run with the value in
+/// each corresponding index in the values child array ends.
+/// Like list/struct types, the value array can be of any type.
+public struct org_apache_arrow_flatbuf_RunEndEncoded: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsRunEndEncoded(bb: ByteBuffer) -> org_apache_arrow_flatbuf_RunEndEncoded { return org_apache_arrow_flatbuf_RunEndEncoded(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ public static func startRunEndEncoded(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
+ public static func endRunEndEncoded(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ _v.finish()
+ }
+}
+
+/// 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.
+public struct org_apache_arrow_flatbuf_Decimal: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsDecimal(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Decimal { return org_apache_arrow_flatbuf_Decimal(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case precision = 4
+ case scale = 6
+ case bitWidth = 8
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Total number of decimal digits
+ public var precision: Int32 { let o = _accessor.offset(VTOFFSET.precision.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
+ /// Number of digits after the decimal point "."
+ public var scale: Int32 { let o = _accessor.offset(VTOFFSET.scale.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
+ /// Number of bits per value. The only accepted widths are 128 and 256.
+ /// We use bitWidth for consistency with Int::bitWidth.
+ public var bitWidth: Int32 { let o = _accessor.offset(VTOFFSET.bitWidth.v); return o == 0 ? 128 : _accessor.readBuffer(of: Int32.self, at: o) }
+ public static func startDecimal(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
+ public static func add(precision: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: precision, def: 0, at: VTOFFSET.precision.p) }
+ public static func add(scale: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: scale, def: 0, at: VTOFFSET.scale.p) }
+ public static func add(bitWidth: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: bitWidth, def: 128, at: VTOFFSET.bitWidth.p) }
+ public static func endDecimal(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createDecimal(
+ _ fbb: inout FlatBufferBuilder,
+ precision: Int32 = 0,
+ scale: Int32 = 0,
+ bitWidth: Int32 = 128
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Decimal.startDecimal(&fbb)
+ org_apache_arrow_flatbuf_Decimal.add(precision: precision, &fbb)
+ org_apache_arrow_flatbuf_Decimal.add(scale: scale, &fbb)
+ org_apache_arrow_flatbuf_Decimal.add(bitWidth: bitWidth, &fbb)
+ return org_apache_arrow_flatbuf_Decimal.endDecimal(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.precision.p, fieldName: "precision", required: false, type: Int32.self)
+ try _v.visit(field: VTOFFSET.scale.p, fieldName: "scale", required: false, type: Int32.self)
+ try _v.visit(field: VTOFFSET.bitWidth.p, fieldName: "bitWidth", required: false, type: Int32.self)
+ _v.finish()
+ }
+}
+
+/// Date is either a 32-bit or 64-bit signed integer type representing an
+/// elapsed time since UNIX epoch (1970-01-01), stored in either of two units:
+///
+/// * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no
+/// leap seconds), where the values are evenly divisible by 86400000
+/// * Days (32 bits) since the UNIX epoch
+public struct org_apache_arrow_flatbuf_Date: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsDate(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Date { return org_apache_arrow_flatbuf_Date(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case unit = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var unit: org_apache_arrow_flatbuf_DateUnit { let o = _accessor.offset(VTOFFSET.unit.v); return o == 0 ? .millisecond : org_apache_arrow_flatbuf_DateUnit(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .millisecond }
+ public static func startDate(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(unit: org_apache_arrow_flatbuf_DateUnit, _ fbb: inout FlatBufferBuilder) { fbb.add(element: unit.rawValue, def: 1, at: VTOFFSET.unit.p) }
+ public static func endDate(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createDate(
+ _ fbb: inout FlatBufferBuilder,
+ unit: org_apache_arrow_flatbuf_DateUnit = .millisecond
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Date.startDate(&fbb)
+ org_apache_arrow_flatbuf_Date.add(unit: unit, &fbb)
+ return org_apache_arrow_flatbuf_Date.endDate(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.unit.p, fieldName: "unit", required: false, type: org_apache_arrow_flatbuf_DateUnit.self)
+ _v.finish()
+ }
+}
+
+/// Time is either a 32-bit or 64-bit signed integer type representing an
+/// elapsed time since midnight, stored in either of four units: seconds,
+/// milliseconds, microseconds or nanoseconds.
+///
+/// The integer `bitWidth` depends on the `unit` and must be one of the following:
+/// * SECOND and MILLISECOND: 32 bits
+/// * MICROSECOND and NANOSECOND: 64 bits
+///
+/// The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds
+/// (exclusive), adjusted for the time unit (for example, up to 86400000
+/// exclusive for the MILLISECOND unit).
+/// This definition doesn't allow for leap seconds. Time values from
+/// measurements with leap seconds will need to be corrected when ingesting
+/// into Arrow (for example by replacing the value 86400 with 86399).
+public struct org_apache_arrow_flatbuf_Time: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsTime(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Time { return org_apache_arrow_flatbuf_Time(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case unit = 4
+ case bitWidth = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var unit: org_apache_arrow_flatbuf_TimeUnit { let o = _accessor.offset(VTOFFSET.unit.v); return o == 0 ? .millisecond : org_apache_arrow_flatbuf_TimeUnit(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .millisecond }
+ public var bitWidth: Int32 { let o = _accessor.offset(VTOFFSET.bitWidth.v); return o == 0 ? 32 : _accessor.readBuffer(of: Int32.self, at: o) }
+ public static func startTime(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(unit: org_apache_arrow_flatbuf_TimeUnit, _ fbb: inout FlatBufferBuilder) { fbb.add(element: unit.rawValue, def: 1, at: VTOFFSET.unit.p) }
+ public static func add(bitWidth: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: bitWidth, def: 32, at: VTOFFSET.bitWidth.p) }
+ public static func endTime(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createTime(
+ _ fbb: inout FlatBufferBuilder,
+ unit: org_apache_arrow_flatbuf_TimeUnit = .millisecond,
+ bitWidth: Int32 = 32
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Time.startTime(&fbb)
+ org_apache_arrow_flatbuf_Time.add(unit: unit, &fbb)
+ org_apache_arrow_flatbuf_Time.add(bitWidth: bitWidth, &fbb)
+ return org_apache_arrow_flatbuf_Time.endTime(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.unit.p, fieldName: "unit", required: false, type: org_apache_arrow_flatbuf_TimeUnit.self)
+ try _v.visit(field: VTOFFSET.bitWidth.p, fieldName: "bitWidth", required: false, type: Int32.self)
+ _v.finish()
+ }
+}
+
+/// Timestamp is a 64-bit signed integer representing an elapsed time since a
+/// fixed epoch, stored in either of four units: seconds, milliseconds,
+/// microseconds or nanoseconds, and is optionally annotated with a timezone.
+///
+/// Timestamp values do not include any leap seconds (in other words, all
+/// days are considered 86400 seconds long).
+///
+/// Timestamps with a non-empty timezone
+/// ------------------------------------
+///
+/// If a Timestamp column has a non-empty timezone value, its epoch is
+/// 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone
+/// (the Unix epoch), regardless of the Timestamp's own timezone.
+///
+/// Therefore, timestamp values with a non-empty timezone correspond to
+/// physical points in time together with some additional information about
+/// how the data was obtained and/or how to display it (the timezone).
+///
+/// For example, the timestamp value 0 with the timezone string "Europe/Paris"
+/// corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the
+/// application may prefer to display it as "January 1st 1970, 01h00" in
+/// the Europe/Paris timezone (which is the same physical point in time).
+///
+/// One consequence is that timestamp values with a non-empty timezone
+/// can be compared and ordered directly, since they all share the same
+/// well-known point of reference (the Unix epoch).
+///
+/// Timestamps with an unset / empty timezone
+/// -----------------------------------------
+///
+/// If a Timestamp column has no timezone value, its epoch is
+/// 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone.
+///
+/// Therefore, timestamp values without a timezone cannot be meaningfully
+/// interpreted as physical points in time, but only as calendar / clock
+/// indications ("wall clock time") in an unspecified timezone.
+///
+/// For example, the timestamp value 0 with an empty timezone string
+/// corresponds to "January 1st 1970, 00h00" in an unknown timezone: there
+/// is not enough information to interpret it as a well-defined physical
+/// point in time.
+///
+/// One consequence is that timestamp values without a timezone cannot
+/// be reliably compared or ordered, since they may have different points of
+/// reference. In particular, it is *not* possible to interpret an unset
+/// or empty timezone as the same as "UTC".
+///
+/// Conversion between timezones
+/// ----------------------------
+///
+/// If a Timestamp column has a non-empty timezone, changing the timezone
+/// to a different non-empty value is a metadata-only operation:
+/// the timestamp values need not change as their point of reference remains
+/// the same (the Unix epoch).
+///
+/// However, if a Timestamp column has no timezone value, changing it to a
+/// non-empty value requires to think about the desired semantics.
+/// One possibility is to assume that the original timestamp values are
+/// relative to the epoch of the timezone being set; timestamp values should
+/// then adjusted to the Unix epoch (for example, changing the timezone from
+/// empty to "Europe/Paris" would require converting the timestamp values
+/// from "Europe/Paris" to "UTC", which seems counter-intuitive but is
+/// nevertheless correct).
+///
+/// Guidelines for encoding data from external libraries
+/// ----------------------------------------------------
+///
+/// Date & time libraries often have multiple different data types for temporal
+/// data. In order to ease interoperability between different implementations the
+/// Arrow project has some recommendations for encoding these types into a Timestamp
+/// column.
+///
+/// An "instant" represents a physical point in time that has no relevant timezone
+/// (for example, astronomical data). To encode an instant, use a Timestamp with
+/// the timezone string set to "UTC", and make sure the Timestamp values
+/// are relative to the UTC epoch (January 1st 1970, midnight).
+///
+/// A "zoned date-time" represents a physical point in time annotated with an
+/// informative timezone (for example, the timezone in which the data was
+/// recorded). To encode a zoned date-time, use a Timestamp with the timezone
+/// string set to the name of the timezone, and make sure the Timestamp values
+/// are relative to the UTC epoch (January 1st 1970, midnight).
+///
+/// (There is some ambiguity between an instant and a zoned date-time with the
+/// UTC timezone. Both of these are stored the same in Arrow. Typically,
+/// this distinction does not matter. If it does, then an application should
+/// use custom metadata or an extension type to distinguish between the two cases.)
+///
+/// An "offset date-time" represents a physical point in time combined with an
+/// explicit offset from UTC. To encode an offset date-time, use a Timestamp
+/// with the timezone string set to the numeric timezone offset string
+/// (e.g. "+03:00"), and make sure the Timestamp values are relative to
+/// the UTC epoch (January 1st 1970, midnight).
+///
+/// A "naive date-time" (also called "local date-time" in some libraries)
+/// represents a wall clock time combined with a calendar date, but with
+/// no indication of how to map this information to a physical point in time.
+/// Naive date-times must be handled with care because of this missing
+/// information, and also because daylight saving time (DST) may make
+/// some values ambiguous or non-existent. A naive date-time may be
+/// stored as a struct with Date and Time fields. However, it may also be
+/// encoded into a Timestamp column with an empty timezone. The timestamp
+/// values should be computed "as if" the timezone of the date-time values
+/// was UTC; for example, the naive date-time "January 1st 1970, 00h00" would
+/// be encoded as timestamp value 0.
+public struct org_apache_arrow_flatbuf_Timestamp: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsTimestamp(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Timestamp { return org_apache_arrow_flatbuf_Timestamp(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case unit = 4
+ case timezone = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var unit: org_apache_arrow_flatbuf_TimeUnit { let o = _accessor.offset(VTOFFSET.unit.v); return o == 0 ? .second : org_apache_arrow_flatbuf_TimeUnit(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .second }
+ /// The timezone is an optional string indicating the name of a timezone,
+ /// one of:
+ ///
+ /// * As used in the Olson timezone database (the "tz database" or
+ /// "tzdata"), such as "America/New_York".
+ /// * An absolute timezone offset of the form "+XX:XX" or "-XX:XX",
+ /// such as "+07:30".
+ ///
+ /// Whether a timezone string is present indicates different semantics about
+ /// the data (see above).
+ public var timezone: String? { let o = _accessor.offset(VTOFFSET.timezone.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var timezoneSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.timezone.v) }
+ public static func startTimestamp(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(unit: org_apache_arrow_flatbuf_TimeUnit, _ fbb: inout FlatBufferBuilder) { fbb.add(element: unit.rawValue, def: 0, at: VTOFFSET.unit.p) }
+ public static func add(timezone: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: timezone, at: VTOFFSET.timezone.p) }
+ public static func endTimestamp(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createTimestamp(
+ _ fbb: inout FlatBufferBuilder,
+ unit: org_apache_arrow_flatbuf_TimeUnit = .second,
+ timezoneOffset timezone: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Timestamp.startTimestamp(&fbb)
+ org_apache_arrow_flatbuf_Timestamp.add(unit: unit, &fbb)
+ org_apache_arrow_flatbuf_Timestamp.add(timezone: timezone, &fbb)
+ return org_apache_arrow_flatbuf_Timestamp.endTimestamp(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.unit.p, fieldName: "unit", required: false, type: org_apache_arrow_flatbuf_TimeUnit.self)
+ try _v.visit(field: VTOFFSET.timezone.p, fieldName: "timezone", required: false, type: ForwardOffset<String>.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Interval: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsInterval(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Interval { return org_apache_arrow_flatbuf_Interval(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case unit = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var unit: org_apache_arrow_flatbuf_IntervalUnit { let o = _accessor.offset(VTOFFSET.unit.v); return o == 0 ? .yearMonth : org_apache_arrow_flatbuf_IntervalUnit(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .yearMonth }
+ public static func startInterval(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(unit: org_apache_arrow_flatbuf_IntervalUnit, _ fbb: inout FlatBufferBuilder) { fbb.add(element: unit.rawValue, def: 0, at: VTOFFSET.unit.p) }
+ public static func endInterval(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createInterval(
+ _ fbb: inout FlatBufferBuilder,
+ unit: org_apache_arrow_flatbuf_IntervalUnit = .yearMonth
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Interval.startInterval(&fbb)
+ org_apache_arrow_flatbuf_Interval.add(unit: unit, &fbb)
+ return org_apache_arrow_flatbuf_Interval.endInterval(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.unit.p, fieldName: "unit", required: false, type: org_apache_arrow_flatbuf_IntervalUnit.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Duration: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsDuration(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Duration { return org_apache_arrow_flatbuf_Duration(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case unit = 4
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var unit: org_apache_arrow_flatbuf_TimeUnit { let o = _accessor.offset(VTOFFSET.unit.v); return o == 0 ? .millisecond : org_apache_arrow_flatbuf_TimeUnit(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .millisecond }
+ public static func startDuration(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
+ public static func add(unit: org_apache_arrow_flatbuf_TimeUnit, _ fbb: inout FlatBufferBuilder) { fbb.add(element: unit.rawValue, def: 1, at: VTOFFSET.unit.p) }
+ public static func endDuration(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createDuration(
+ _ fbb: inout FlatBufferBuilder,
+ unit: org_apache_arrow_flatbuf_TimeUnit = .millisecond
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Duration.startDuration(&fbb)
+ org_apache_arrow_flatbuf_Duration.add(unit: unit, &fbb)
+ return org_apache_arrow_flatbuf_Duration.endDuration(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.unit.p, fieldName: "unit", required: false, type: org_apache_arrow_flatbuf_TimeUnit.self)
+ _v.finish()
+ }
+}
+
+/// ----------------------------------------------------------------------
+/// user defined key value pairs to add custom metadata to arrow
+/// key namespacing is the responsibility of the user
+public struct org_apache_arrow_flatbuf_KeyValue: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsKeyValue(bb: ByteBuffer) -> org_apache_arrow_flatbuf_KeyValue { return org_apache_arrow_flatbuf_KeyValue(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case key = 4
+ case value = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var key: String? { let o = _accessor.offset(VTOFFSET.key.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var keySegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.key.v) }
+ public var value: String? { let o = _accessor.offset(VTOFFSET.value.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var valueSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.value.v) }
+ public static func startKeyValue(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(key: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: key, at: VTOFFSET.key.p) }
+ public static func add(value: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: value, at: VTOFFSET.value.p) }
+ public static func endKeyValue(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createKeyValue(
+ _ fbb: inout FlatBufferBuilder,
+ keyOffset key: Offset = Offset(),
+ valueOffset value: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_KeyValue.startKeyValue(&fbb)
+ org_apache_arrow_flatbuf_KeyValue.add(key: key, &fbb)
+ org_apache_arrow_flatbuf_KeyValue.add(value: value, &fbb)
+ return org_apache_arrow_flatbuf_KeyValue.endKeyValue(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.key.p, fieldName: "key", required: false, type: ForwardOffset<String>.self)
+ try _v.visit(field: VTOFFSET.value.p, fieldName: "value", required: false, type: ForwardOffset<String>.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_DictionaryEncoding: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsDictionaryEncoding(bb: ByteBuffer) -> org_apache_arrow_flatbuf_DictionaryEncoding { return org_apache_arrow_flatbuf_DictionaryEncoding(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case id = 4
+ case indexType = 6
+ case isOrdered = 8
+ case dictionaryKind = 10
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// The known dictionary id in the application where this data is used. In
+ /// the file or streaming formats, the dictionary ids are found in the
+ /// DictionaryBatch messages
+ public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ /// 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.
+ public var indexType: org_apache_arrow_flatbuf_Int? { let o = _accessor.offset(VTOFFSET.indexType.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// 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
+ /// preserve that metadata here
+ public var isOrdered: Bool { let o = _accessor.offset(VTOFFSET.isOrdered.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public var dictionaryKind: org_apache_arrow_flatbuf_DictionaryKind { let o = _accessor.offset(VTOFFSET.dictionaryKind.v); return o == 0 ? .densearray : org_apache_arrow_flatbuf_DictionaryKind(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .densearray }
+ public static func startDictionaryEncoding(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
+ public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VTOFFSET.id.p) }
+ public static func add(indexType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indexType, at: VTOFFSET.indexType.p) }
+ public static func add(isOrdered: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: isOrdered, def: false,
+ at: VTOFFSET.isOrdered.p) }
+ public static func add(dictionaryKind: org_apache_arrow_flatbuf_DictionaryKind, _ fbb: inout FlatBufferBuilder) { fbb.add(element: dictionaryKind.rawValue, def: 0, at: VTOFFSET.dictionaryKind.p) }
+ public static func endDictionaryEncoding(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createDictionaryEncoding(
+ _ fbb: inout FlatBufferBuilder,
+ id: Int64 = 0,
+ indexTypeOffset indexType: Offset = Offset(),
+ isOrdered: Bool = false,
+ dictionaryKind: org_apache_arrow_flatbuf_DictionaryKind = .densearray
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_DictionaryEncoding.startDictionaryEncoding(&fbb)
+ org_apache_arrow_flatbuf_DictionaryEncoding.add(id: id, &fbb)
+ org_apache_arrow_flatbuf_DictionaryEncoding.add(indexType: indexType, &fbb)
+ org_apache_arrow_flatbuf_DictionaryEncoding.add(isOrdered: isOrdered, &fbb)
+ org_apache_arrow_flatbuf_DictionaryEncoding.add(dictionaryKind: dictionaryKind, &fbb)
+ return org_apache_arrow_flatbuf_DictionaryEncoding.endDictionaryEncoding(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.id.p, fieldName: "id", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.indexType.p, fieldName: "indexType", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.isOrdered.p, fieldName: "isOrdered", required: false, type: Bool.self)
+ try _v.visit(field: VTOFFSET.dictionaryKind.p, fieldName: "dictionaryKind", required: false, type: org_apache_arrow_flatbuf_DictionaryKind.self)
+ _v.finish()
+ }
+}
+
+/// ----------------------------------------------------------------------
+/// A field represents a named column in a record / row batch or child of a
+/// nested type.
+public struct org_apache_arrow_flatbuf_Field: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsField(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Field { return org_apache_arrow_flatbuf_Field(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case name = 4
+ case nullable = 6
+ case typeType = 8
+ case type = 10
+ case dictionary = 12
+ case children = 14
+ case customMetadata = 16
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Name is not required, in i.e. a List
+ public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
+ /// Whether or not this field can contain nulls. Should be true in general.
+ public var nullable: Bool { let o = _accessor.offset(VTOFFSET.nullable.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public var typeType: org_apache_arrow_flatbuf_Type_ { let o = _accessor.offset(VTOFFSET.typeType.v); return o == 0 ? .none_ : org_apache_arrow_flatbuf_Type_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
+ /// This is the type of the decoded value if the field is dictionary encoded.
+ public func type<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.type.v); return o == 0 ? nil : _accessor.union(o) }
+ /// Present only if the field is dictionary encoded.
+ public var dictionary: org_apache_arrow_flatbuf_DictionaryEncoding? { let o = _accessor.offset(VTOFFSET.dictionary.v); return o == 0 ? nil : org_apache_arrow_flatbuf_DictionaryEncoding(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// children apply only to nested data types like Struct, List and Union. For
+ /// primitive types children will have length 0.
+ public var hasChildren: Bool { let o = _accessor.offset(VTOFFSET.children.v); return o == 0 ? false : true }
+ public var childrenCount: Int32 { let o = _accessor.offset(VTOFFSET.children.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func children(at index: Int32) -> org_apache_arrow_flatbuf_Field? { let o = _accessor.offset(VTOFFSET.children.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Field(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ /// User-defined metadata
+ public var hasCustomMetadata: Bool { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? false : true }
+ public var customMetadataCount: Int32 { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func customMetadata(at index: Int32) -> org_apache_arrow_flatbuf_KeyValue? { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? nil : org_apache_arrow_flatbuf_KeyValue(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ public static func startField(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 7) }
+ public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
+ public static func add(nullable: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: nullable, def: false,
+ at: VTOFFSET.nullable.p) }
+ public static func add(typeType: org_apache_arrow_flatbuf_Type_, _ fbb: inout FlatBufferBuilder) { fbb.add(element: typeType.rawValue, def: 0, at: VTOFFSET.typeType.p) }
+ public static func add(type: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: type, at: VTOFFSET.type.p) }
+ public static func add(dictionary: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: dictionary, at: VTOFFSET.dictionary.p) }
+ public static func addVectorOf(children: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: children, at: VTOFFSET.children.p) }
+ public static func addVectorOf(customMetadata: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: customMetadata, at: VTOFFSET.customMetadata.p) }
+ public static func endField(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createField(
+ _ fbb: inout FlatBufferBuilder,
+ nameOffset name: Offset = Offset(),
+ nullable: Bool = false,
+ typeType: org_apache_arrow_flatbuf_Type_ = .none_,
+ typeOffset type: Offset = Offset(),
+ dictionaryOffset dictionary: Offset = Offset(),
+ childrenVectorOffset children: Offset = Offset(),
+ customMetadataVectorOffset customMetadata: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Field.startField(&fbb)
+ org_apache_arrow_flatbuf_Field.add(name: name, &fbb)
+ org_apache_arrow_flatbuf_Field.add(nullable: nullable, &fbb)
+ org_apache_arrow_flatbuf_Field.add(typeType: typeType, &fbb)
+ org_apache_arrow_flatbuf_Field.add(type: type, &fbb)
+ org_apache_arrow_flatbuf_Field.add(dictionary: dictionary, &fbb)
+ org_apache_arrow_flatbuf_Field.addVectorOf(children: children, &fbb)
+ org_apache_arrow_flatbuf_Field.addVectorOf(customMetadata: customMetadata, &fbb)
+ return org_apache_arrow_flatbuf_Field.endField(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
+ try _v.visit(field: VTOFFSET.nullable.p, fieldName: "nullable", required: false, type: Bool.self)
+ try _v.visit(unionKey: VTOFFSET.typeType.p, unionField: VTOFFSET.type.p, unionKeyName: "typeType", fieldName: "type", required: false, completion: { (verifier, key: org_apache_arrow_flatbuf_Type_, pos) in
+ switch key {
+ case .none_:
+ break // NOTE - SWIFT doesnt support none
+ case .null:
+ try ForwardOffset<org_apache_arrow_flatbuf_Null>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self)
+ case .int:
+ try ForwardOffset<org_apache_arrow_flatbuf_Int>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self)
+ case .floatingpoint:
+ try ForwardOffset<org_apache_arrow_flatbuf_FloatingPoint>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self)
+ case .binary:
+ try ForwardOffset<org_apache_arrow_flatbuf_Binary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self)
+ case .utf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_Utf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self)
+ case .bool:
+ try ForwardOffset<org_apache_arrow_flatbuf_Bool>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self)
+ case .decimal:
+ try ForwardOffset<org_apache_arrow_flatbuf_Decimal>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self)
+ case .date:
+ try ForwardOffset<org_apache_arrow_flatbuf_Date>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self)
+ case .time:
+ try ForwardOffset<org_apache_arrow_flatbuf_Time>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self)
+ case .timestamp:
+ try ForwardOffset<org_apache_arrow_flatbuf_Timestamp>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self)
+ case .interval:
+ try ForwardOffset<org_apache_arrow_flatbuf_Interval>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self)
+ case .list:
+ try ForwardOffset<org_apache_arrow_flatbuf_List>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self)
+ case .struct_:
+ try ForwardOffset<org_apache_arrow_flatbuf_Struct_>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self)
+ case .union:
+ try ForwardOffset<org_apache_arrow_flatbuf_Union>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self)
+ case .fixedsizebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self)
+ case .fixedsizelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self)
+ case .map:
+ try ForwardOffset<org_apache_arrow_flatbuf_Map>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self)
+ case .duration:
+ try ForwardOffset<org_apache_arrow_flatbuf_Duration>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self)
+ case .largebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self)
+ case .largeutf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeUtf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self)
+ case .largelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self)
+ case .runendencoded:
+ try ForwardOffset<org_apache_arrow_flatbuf_RunEndEncoded>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self)
+ }
+ })
+ try _v.visit(field: VTOFFSET.dictionary.p, fieldName: "dictionary", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_DictionaryEncoding>.self)
+ try _v.visit(field: VTOFFSET.children.p, fieldName: "children", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_Field>, org_apache_arrow_flatbuf_Field>>.self)
+ try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_KeyValue>, org_apache_arrow_flatbuf_KeyValue>>.self)
+ _v.finish()
+ }
+}
+
+/// ----------------------------------------------------------------------
+/// A Schema describes the columns in a row batch
+public struct org_apache_arrow_flatbuf_Schema: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsSchema(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Schema { return org_apache_arrow_flatbuf_Schema(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case endianness = 4
+ case fields = 6
+ case customMetadata = 8
+ case features = 10
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// endianness of the buffer
+ /// it is Little Endian by default
+ /// if endianness doesn't match the underlying system then the vectors need to be converted
+ public var endianness: org_apache_arrow_flatbuf_Endianness { let o = _accessor.offset(VTOFFSET.endianness.v); return o == 0 ? .little : org_apache_arrow_flatbuf_Endianness(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .little }
+ public var hasFields: Bool { let o = _accessor.offset(VTOFFSET.fields.v); return o == 0 ? false : true }
+ public var fieldsCount: Int32 { let o = _accessor.offset(VTOFFSET.fields.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func fields(at index: Int32) -> org_apache_arrow_flatbuf_Field? { let o = _accessor.offset(VTOFFSET.fields.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Field(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ public var hasCustomMetadata: Bool { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? false : true }
+ public var customMetadataCount: Int32 { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func customMetadata(at index: Int32) -> org_apache_arrow_flatbuf_KeyValue? { let o = _accessor.offset(VTOFFSET.customMetadata.v); return o == 0 ? nil : org_apache_arrow_flatbuf_KeyValue(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ /// Features used in the stream/file.
+ public var hasFeatures: Bool { let o = _accessor.offset(VTOFFSET.features.v); return o == 0 ? false : true }
+ public var featuresCount: Int32 { let o = _accessor.offset(VTOFFSET.features.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func features(at index: Int32) -> org_apache_arrow_flatbuf_Feature? { let o = _accessor.offset(VTOFFSET.features.v); return o == 0 ? org_apache_arrow_flatbuf_Feature.unused : org_apache_arrow_flatbuf_Feature(rawValue: _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8)) }
+ public static func startSchema(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
+ public static func add(endianness: org_apache_arrow_flatbuf_Endianness, _ fbb: inout FlatBufferBuilder) { fbb.add(element: endianness.rawValue, def: 0, at: VTOFFSET.endianness.p) }
+ public static func addVectorOf(fields: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: fields, at: VTOFFSET.fields.p) }
+ public static func addVectorOf(customMetadata: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: customMetadata, at: VTOFFSET.customMetadata.p) }
+ public static func addVectorOf(features: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: features, at: VTOFFSET.features.p) }
+ public static func endSchema(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createSchema(
+ _ fbb: inout FlatBufferBuilder,
+ endianness: org_apache_arrow_flatbuf_Endianness = .little,
+ fieldsVectorOffset fields: Offset = Offset(),
+ customMetadataVectorOffset customMetadata: Offset = Offset(),
+ featuresVectorOffset features: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Schema.startSchema(&fbb)
+ org_apache_arrow_flatbuf_Schema.add(endianness: endianness, &fbb)
+ org_apache_arrow_flatbuf_Schema.addVectorOf(fields: fields, &fbb)
+ org_apache_arrow_flatbuf_Schema.addVectorOf(customMetadata: customMetadata, &fbb)
+ org_apache_arrow_flatbuf_Schema.addVectorOf(features: features, &fbb)
+ return org_apache_arrow_flatbuf_Schema.endSchema(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.endianness.p, fieldName: "endianness", required: false, type: org_apache_arrow_flatbuf_Endianness.self)
+ try _v.visit(field: VTOFFSET.fields.p, fieldName: "fields", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_Field>, org_apache_arrow_flatbuf_Field>>.self)
+ try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_KeyValue>, org_apache_arrow_flatbuf_KeyValue>>.self)
+ try _v.visit(field: VTOFFSET.features.p, fieldName: "features", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Feature, org_apache_arrow_flatbuf_Feature>>.self)
+ _v.finish()
+ }
+}
+
diff --git a/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift b/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift
new file mode 100644
index 0000000000..e412a61dc2
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift
@@ -0,0 +1,535 @@
+// 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.
+
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+public enum org_apache_arrow_flatbuf_SparseMatrixCompressedAxis: Int16, Enum, Verifiable {
+ public typealias T = Int16
+ public static var byteSize: Int { return MemoryLayout<Int16>.size }
+ public var value: Int16 { return self.rawValue }
+ case row = 0
+ case column = 1
+
+ public static var max: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis { return .column }
+ public static var min: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis { return .row }
+}
+
+
+public enum org_apache_arrow_flatbuf_SparseTensorIndex: UInt8, UnionEnum {
+ public typealias T = UInt8
+
+ public init?(value: T) {
+ self.init(rawValue: value)
+ }
+
+ public static var byteSize: Int { return MemoryLayout<UInt8>.size }
+ public var value: UInt8 { return self.rawValue }
+ case none_ = 0
+ case sparsetensorindexcoo = 1
+ case sparsematrixindexcsx = 2
+ case sparsetensorindexcsf = 3
+
+ public static var max: org_apache_arrow_flatbuf_SparseTensorIndex { return .sparsetensorindexcsf }
+ public static var min: org_apache_arrow_flatbuf_SparseTensorIndex { return .none_ }
+}
+
+
+/// ----------------------------------------------------------------------
+/// EXPERIMENTAL: Data structures for sparse tensors
+/// 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,
+/// and M is the number of dimensions of a sparse tensor.
+///
+/// indicesBuffer stores the location and size of the data of this indices
+/// matrix. The value type and the stride of the indices matrix is
+/// specified in indicesType and indicesStrides fields.
+///
+/// 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]]
+/// ```
+/// 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.
+public struct org_apache_arrow_flatbuf_SparseTensorIndexCOO: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsSparseTensorIndexCOO(bb: ByteBuffer) -> org_apache_arrow_flatbuf_SparseTensorIndexCOO { return org_apache_arrow_flatbuf_SparseTensorIndexCOO(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case indicesType = 4
+ case indicesStrides = 6
+ case indicesBuffer = 8
+ case isCanonical = 10
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// The type of values in indicesBuffer
+ public var indicesType: org_apache_arrow_flatbuf_Int! { let o = _accessor.offset(VTOFFSET.indicesType.v); return org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// Non-negative byte offsets to advance one value cell along each dimension
+ /// If omitted, default to row-major order (C-like).
+ public var hasIndicesStrides: Bool { let o = _accessor.offset(VTOFFSET.indicesStrides.v); return o == 0 ? false : true }
+ public var indicesStridesCount: Int32 { let o = _accessor.offset(VTOFFSET.indicesStrides.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func indicesStrides(at index: Int32) -> Int64 { let o = _accessor.offset(VTOFFSET.indicesStrides.v); return o == 0 ? 0 : _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8) }
+ public var indicesStrides: [Int64] { return _accessor.getVector(at: VTOFFSET.indicesStrides.v) ?? [] }
+ /// The location and size of the indices matrix's data
+ public var indicesBuffer: org_apache_arrow_flatbuf_Buffer! { let o = _accessor.offset(VTOFFSET.indicesBuffer.v); return _accessor.readBuffer(of: org_apache_arrow_flatbuf_Buffer.self, at: o) }
+ public var mutableIndicesBuffer: org_apache_arrow_flatbuf_Buffer_Mutable! { let o = _accessor.offset(VTOFFSET.indicesBuffer.v); return org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ /// 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).
+ public var isCanonical: Bool { let o = _accessor.offset(VTOFFSET.isCanonical.v); return o == 0 ? false : 0 != _accessor.readBuffer(of: Byte.self, at: o) }
+ public static func startSparseTensorIndexCOO(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
+ public static func add(indicesType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indicesType, at: VTOFFSET.indicesType.p) }
+ public static func addVectorOf(indicesStrides: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indicesStrides, at: VTOFFSET.indicesStrides.p) }
+ public static func add(indicesBuffer: org_apache_arrow_flatbuf_Buffer?, _ fbb: inout FlatBufferBuilder) { guard let indicesBuffer = indicesBuffer else { return }; fbb.create(struct: indicesBuffer, position: VTOFFSET.indicesBuffer.p) }
+ public static func add(isCanonical: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: isCanonical, def: false,
+ at: VTOFFSET.isCanonical.p) }
+ public static func endSparseTensorIndexCOO(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [4, 8]); return end }
+ public static func createSparseTensorIndexCOO(
+ _ fbb: inout FlatBufferBuilder,
+ indicesTypeOffset indicesType: Offset,
+ indicesStridesVectorOffset indicesStrides: Offset = Offset(),
+ indicesBuffer: org_apache_arrow_flatbuf_Buffer,
+ isCanonical: Bool = false
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_SparseTensorIndexCOO.startSparseTensorIndexCOO(&fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCOO.add(indicesType: indicesType, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCOO.addVectorOf(indicesStrides: indicesStrides, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCOO.add(indicesBuffer: indicesBuffer, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCOO.add(isCanonical: isCanonical, &fbb)
+ return org_apache_arrow_flatbuf_SparseTensorIndexCOO.endSparseTensorIndexCOO(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.indicesType.p, fieldName: "indicesType", required: true, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.indicesStrides.p, fieldName: "indicesStrides", required: false, type: ForwardOffset<Vector<Int64, Int64>>.self)
+ try _v.visit(field: VTOFFSET.indicesBuffer.p, fieldName: "indicesBuffer", required: true, type: org_apache_arrow_flatbuf_Buffer.self)
+ try _v.visit(field: VTOFFSET.isCanonical.p, fieldName: "isCanonical", required: false, type: Bool.self)
+ _v.finish()
+ }
+}
+
+/// Compressed Sparse format, that is matrix-specific.
+public struct org_apache_arrow_flatbuf_SparseMatrixIndexCSX: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsSparseMatrixIndexCSX(bb: ByteBuffer) -> org_apache_arrow_flatbuf_SparseMatrixIndexCSX { return org_apache_arrow_flatbuf_SparseMatrixIndexCSX(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case compressedAxis = 4
+ case indptrType = 6
+ case indptrBuffer = 8
+ case indicesType = 10
+ case indicesBuffer = 12
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Which axis, row or column, is compressed
+ public var compressedAxis: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis { let o = _accessor.offset(VTOFFSET.compressedAxis.v); return o == 0 ? .row : org_apache_arrow_flatbuf_SparseMatrixCompressedAxis(rawValue: _accessor.readBuffer(of: Int16.self, at: o)) ?? .row }
+ /// The type of values in indptrBuffer
+ public var indptrType: org_apache_arrow_flatbuf_Int! { let o = _accessor.offset(VTOFFSET.indptrType.v); return org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// 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].
+ /// ```
+ public var indptrBuffer: org_apache_arrow_flatbuf_Buffer! { let o = _accessor.offset(VTOFFSET.indptrBuffer.v); return _accessor.readBuffer(of: org_apache_arrow_flatbuf_Buffer.self, at: o) }
+ public var mutableIndptrBuffer: org_apache_arrow_flatbuf_Buffer_Mutable! { let o = _accessor.offset(VTOFFSET.indptrBuffer.v); return org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ /// The type of values in indicesBuffer
+ public var indicesType: org_apache_arrow_flatbuf_Int! { let o = _accessor.offset(VTOFFSET.indicesType.v); return org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// 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.
+ public var indicesBuffer: org_apache_arrow_flatbuf_Buffer! { let o = _accessor.offset(VTOFFSET.indicesBuffer.v); return _accessor.readBuffer(of: org_apache_arrow_flatbuf_Buffer.self, at: o) }
+ public var mutableIndicesBuffer: org_apache_arrow_flatbuf_Buffer_Mutable! { let o = _accessor.offset(VTOFFSET.indicesBuffer.v); return org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ public static func startSparseMatrixIndexCSX(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
+ public static func add(compressedAxis: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis, _ fbb: inout FlatBufferBuilder) { fbb.add(element: compressedAxis.rawValue, def: 0, at: VTOFFSET.compressedAxis.p) }
+ public static func add(indptrType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indptrType, at: VTOFFSET.indptrType.p) }
+ public static func add(indptrBuffer: org_apache_arrow_flatbuf_Buffer?, _ fbb: inout FlatBufferBuilder) { guard let indptrBuffer = indptrBuffer else { return }; fbb.create(struct: indptrBuffer, position: VTOFFSET.indptrBuffer.p) }
+ public static func add(indicesType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indicesType, at: VTOFFSET.indicesType.p) }
+ public static func add(indicesBuffer: org_apache_arrow_flatbuf_Buffer?, _ fbb: inout FlatBufferBuilder) { guard let indicesBuffer = indicesBuffer else { return }; fbb.create(struct: indicesBuffer, position: VTOFFSET.indicesBuffer.p) }
+ public static func endSparseMatrixIndexCSX(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8, 10, 12]); return end }
+ public static func createSparseMatrixIndexCSX(
+ _ fbb: inout FlatBufferBuilder,
+ compressedAxis: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis = .row,
+ indptrTypeOffset indptrType: Offset,
+ indptrBuffer: org_apache_arrow_flatbuf_Buffer,
+ indicesTypeOffset indicesType: Offset,
+ indicesBuffer: org_apache_arrow_flatbuf_Buffer
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_SparseMatrixIndexCSX.startSparseMatrixIndexCSX(&fbb)
+ org_apache_arrow_flatbuf_SparseMatrixIndexCSX.add(compressedAxis: compressedAxis, &fbb)
+ org_apache_arrow_flatbuf_SparseMatrixIndexCSX.add(indptrType: indptrType, &fbb)
+ org_apache_arrow_flatbuf_SparseMatrixIndexCSX.add(indptrBuffer: indptrBuffer, &fbb)
+ org_apache_arrow_flatbuf_SparseMatrixIndexCSX.add(indicesType: indicesType, &fbb)
+ org_apache_arrow_flatbuf_SparseMatrixIndexCSX.add(indicesBuffer: indicesBuffer, &fbb)
+ return org_apache_arrow_flatbuf_SparseMatrixIndexCSX.endSparseMatrixIndexCSX(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.compressedAxis.p, fieldName: "compressedAxis", required: false, type: org_apache_arrow_flatbuf_SparseMatrixCompressedAxis.self)
+ try _v.visit(field: VTOFFSET.indptrType.p, fieldName: "indptrType", required: true, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.indptrBuffer.p, fieldName: "indptrBuffer", required: true, type: org_apache_arrow_flatbuf_Buffer.self)
+ try _v.visit(field: VTOFFSET.indicesType.p, fieldName: "indicesType", required: true, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.indicesBuffer.p, fieldName: "indicesBuffer", required: true, type: org_apache_arrow_flatbuf_Buffer.self)
+ _v.finish()
+ }
+}
+
+/// Compressed Sparse Fiber (CSF) sparse tensor index.
+public struct org_apache_arrow_flatbuf_SparseTensorIndexCSF: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsSparseTensorIndexCSF(bb: ByteBuffer) -> org_apache_arrow_flatbuf_SparseTensorIndexCSF { return org_apache_arrow_flatbuf_SparseTensorIndexCSF(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case indptrType = 4
+ case indptrBuffers = 6
+ case indicesType = 8
+ case indicesBuffers = 10
+ case axisOrder = 12
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// 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
+ public var indptrType: org_apache_arrow_flatbuf_Int! { let o = _accessor.offset(VTOFFSET.indptrType.v); return org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// 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]
+ /// ].
+ /// ```
+ public var hasIndptrBuffers: Bool { let o = _accessor.offset(VTOFFSET.indptrBuffers.v); return o == 0 ? false : true }
+ public var indptrBuffersCount: Int32 { let o = _accessor.offset(VTOFFSET.indptrBuffers.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func indptrBuffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer? { let o = _accessor.offset(VTOFFSET.indptrBuffers.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_Buffer.self, offset: _accessor.vector(at: o) + index * 16) }
+ public func mutableIndptrBuffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer_Mutable? { let o = _accessor.offset(VTOFFSET.indptrBuffers.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 16) }
+ /// The type of values in indicesBuffers
+ public var indicesType: org_apache_arrow_flatbuf_Int! { let o = _accessor.offset(VTOFFSET.indicesType.v); return org_apache_arrow_flatbuf_Int(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
+ /// 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]
+ /// ].
+ /// ```
+ public var hasIndicesBuffers: Bool { let o = _accessor.offset(VTOFFSET.indicesBuffers.v); return o == 0 ? false : true }
+ public var indicesBuffersCount: Int32 { let o = _accessor.offset(VTOFFSET.indicesBuffers.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func indicesBuffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer? { let o = _accessor.offset(VTOFFSET.indicesBuffers.v); return o == 0 ? nil : _accessor.directRead(of: org_apache_arrow_flatbuf_Buffer.self, offset: _accessor.vector(at: o) + index * 16) }
+ public func mutableIndicesBuffers(at index: Int32) -> org_apache_arrow_flatbuf_Buffer_Mutable? { let o = _accessor.offset(VTOFFSET.indicesBuffers.v); return o == 0 ? nil : org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 16) }
+ /// 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].
+ /// ```
+ public var hasAxisOrder: Bool { let o = _accessor.offset(VTOFFSET.axisOrder.v); return o == 0 ? false : true }
+ public var axisOrderCount: Int32 { let o = _accessor.offset(VTOFFSET.axisOrder.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func axisOrder(at index: Int32) -> Int32 { let o = _accessor.offset(VTOFFSET.axisOrder.v); return o == 0 ? 0 : _accessor.directRead(of: Int32.self, offset: _accessor.vector(at: o) + index * 4) }
+ public var axisOrder: [Int32] { return _accessor.getVector(at: VTOFFSET.axisOrder.v) ?? [] }
+ public static func startSparseTensorIndexCSF(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
+ public static func add(indptrType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indptrType, at: VTOFFSET.indptrType.p) }
+ public static func addVectorOf(indptrBuffers: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indptrBuffers, at: VTOFFSET.indptrBuffers.p) }
+ public static func startVectorOfIndptrBuffers(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Buffer>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Buffer>.alignment)
+ }
+ public static func add(indicesType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indicesType, at: VTOFFSET.indicesType.p) }
+ public static func addVectorOf(indicesBuffers: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: indicesBuffers, at: VTOFFSET.indicesBuffers.p) }
+ public static func startVectorOfIndicesBuffers(_ size: Int, in builder: inout FlatBufferBuilder) {
+ builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Buffer>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Buffer>.alignment)
+ }
+ public static func addVectorOf(axisOrder: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: axisOrder, at: VTOFFSET.axisOrder.p) }
+ public static func endSparseTensorIndexCSF(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [4, 6, 8, 10, 12]); return end }
+ public static func createSparseTensorIndexCSF(
+ _ fbb: inout FlatBufferBuilder,
+ indptrTypeOffset indptrType: Offset,
+ indptrBuffersVectorOffset indptrBuffers: Offset,
+ indicesTypeOffset indicesType: Offset,
+ indicesBuffersVectorOffset indicesBuffers: Offset,
+ axisOrderVectorOffset axisOrder: Offset
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_SparseTensorIndexCSF.startSparseTensorIndexCSF(&fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCSF.add(indptrType: indptrType, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCSF.addVectorOf(indptrBuffers: indptrBuffers, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCSF.add(indicesType: indicesType, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCSF.addVectorOf(indicesBuffers: indicesBuffers, &fbb)
+ org_apache_arrow_flatbuf_SparseTensorIndexCSF.addVectorOf(axisOrder: axisOrder, &fbb)
+ return org_apache_arrow_flatbuf_SparseTensorIndexCSF.endSparseTensorIndexCSF(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.indptrType.p, fieldName: "indptrType", required: true, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.indptrBuffers.p, fieldName: "indptrBuffers", required: true, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer>>.self)
+ try _v.visit(field: VTOFFSET.indicesType.p, fieldName: "indicesType", required: true, type: ForwardOffset<org_apache_arrow_flatbuf_Int>.self)
+ try _v.visit(field: VTOFFSET.indicesBuffers.p, fieldName: "indicesBuffers", required: true, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer>>.self)
+ try _v.visit(field: VTOFFSET.axisOrder.p, fieldName: "axisOrder", required: true, type: ForwardOffset<Vector<Int32, Int32>>.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_SparseTensor: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsSparseTensor(bb: ByteBuffer) -> org_apache_arrow_flatbuf_SparseTensor { return org_apache_arrow_flatbuf_SparseTensor(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case typeType = 4
+ case type = 6
+ case shape = 8
+ case nonZeroLength = 10
+ case sparseIndexType = 12
+ case sparseIndex = 14
+ case data = 16
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var typeType: org_apache_arrow_flatbuf_Type_ { let o = _accessor.offset(VTOFFSET.typeType.v); return o == 0 ? .none_ : org_apache_arrow_flatbuf_Type_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
+ /// The type of data contained in a value cell.
+ /// Currently only fixed-width value types are supported,
+ /// no strings or nested types.
+ public func type<T: FlatbuffersInitializable>(type: T.Type) -> T! { let o = _accessor.offset(VTOFFSET.type.v); return _accessor.union(o) }
+ /// The dimensions of the tensor, optionally named.
+ public var hasShape: Bool { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? false : true }
+ public var shapeCount: Int32 { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func shape(at index: Int32) -> org_apache_arrow_flatbuf_TensorDim? { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? nil : org_apache_arrow_flatbuf_TensorDim(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ /// The number of non-zero values in a sparse tensor.
+ public var nonZeroLength: Int64 { let o = _accessor.offset(VTOFFSET.nonZeroLength.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ public var sparseIndexType: org_apache_arrow_flatbuf_SparseTensorIndex { let o = _accessor.offset(VTOFFSET.sparseIndexType.v); return o == 0 ? .none_ : org_apache_arrow_flatbuf_SparseTensorIndex(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
+ /// Sparse tensor index
+ public func sparseIndex<T: FlatbuffersInitializable>(type: T.Type) -> T! { let o = _accessor.offset(VTOFFSET.sparseIndex.v); return _accessor.union(o) }
+ /// The location and size of the tensor's data
+ public var data: org_apache_arrow_flatbuf_Buffer! { let o = _accessor.offset(VTOFFSET.data.v); return _accessor.readBuffer(of: org_apache_arrow_flatbuf_Buffer.self, at: o) }
+ public var mutableData: org_apache_arrow_flatbuf_Buffer_Mutable! { let o = _accessor.offset(VTOFFSET.data.v); return org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ public static func startSparseTensor(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 7) }
+ public static func add(typeType: org_apache_arrow_flatbuf_Type_, _ fbb: inout FlatBufferBuilder) { fbb.add(element: typeType.rawValue, def: 0, at: VTOFFSET.typeType.p) }
+ public static func add(type: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: type, at: VTOFFSET.type.p) }
+ public static func addVectorOf(shape: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: shape, at: VTOFFSET.shape.p) }
+ public static func add(nonZeroLength: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: nonZeroLength, def: 0, at: VTOFFSET.nonZeroLength.p) }
+ public static func add(sparseIndexType: org_apache_arrow_flatbuf_SparseTensorIndex, _ fbb: inout FlatBufferBuilder) { fbb.add(element: sparseIndexType.rawValue, def: 0, at: VTOFFSET.sparseIndexType.p) }
+ public static func add(sparseIndex: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: sparseIndex, at: VTOFFSET.sparseIndex.p) }
+ public static func add(data: org_apache_arrow_flatbuf_Buffer?, _ fbb: inout FlatBufferBuilder) { guard let data = data else { return }; fbb.create(struct: data, position: VTOFFSET.data.p) }
+ public static func endSparseTensor(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8, 14, 16]); return end }
+ public static func createSparseTensor(
+ _ fbb: inout FlatBufferBuilder,
+ typeType: org_apache_arrow_flatbuf_Type_ = .none_,
+ typeOffset type: Offset,
+ shapeVectorOffset shape: Offset,
+ nonZeroLength: Int64 = 0,
+ sparseIndexType: org_apache_arrow_flatbuf_SparseTensorIndex = .none_,
+ sparseIndexOffset sparseIndex: Offset,
+ data: org_apache_arrow_flatbuf_Buffer
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_SparseTensor.startSparseTensor(&fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(typeType: typeType, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(type: type, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.addVectorOf(shape: shape, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(nonZeroLength: nonZeroLength, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(sparseIndexType: sparseIndexType, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(sparseIndex: sparseIndex, &fbb)
+ org_apache_arrow_flatbuf_SparseTensor.add(data: data, &fbb)
+ return org_apache_arrow_flatbuf_SparseTensor.endSparseTensor(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(unionKey: VTOFFSET.typeType.p, unionField: VTOFFSET.type.p, unionKeyName: "typeType", fieldName: "type", required: true, completion: { (verifier, key: org_apache_arrow_flatbuf_Type_, pos) in
+ switch key {
+ case .none_:
+ break // NOTE - SWIFT doesnt support none
+ case .null:
+ try ForwardOffset<org_apache_arrow_flatbuf_Null>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self)
+ case .int:
+ try ForwardOffset<org_apache_arrow_flatbuf_Int>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self)
+ case .floatingpoint:
+ try ForwardOffset<org_apache_arrow_flatbuf_FloatingPoint>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self)
+ case .binary:
+ try ForwardOffset<org_apache_arrow_flatbuf_Binary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self)
+ case .utf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_Utf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self)
+ case .bool:
+ try ForwardOffset<org_apache_arrow_flatbuf_Bool>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self)
+ case .decimal:
+ try ForwardOffset<org_apache_arrow_flatbuf_Decimal>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self)
+ case .date:
+ try ForwardOffset<org_apache_arrow_flatbuf_Date>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self)
+ case .time:
+ try ForwardOffset<org_apache_arrow_flatbuf_Time>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self)
+ case .timestamp:
+ try ForwardOffset<org_apache_arrow_flatbuf_Timestamp>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self)
+ case .interval:
+ try ForwardOffset<org_apache_arrow_flatbuf_Interval>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self)
+ case .list:
+ try ForwardOffset<org_apache_arrow_flatbuf_List>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self)
+ case .struct_:
+ try ForwardOffset<org_apache_arrow_flatbuf_Struct_>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self)
+ case .union:
+ try ForwardOffset<org_apache_arrow_flatbuf_Union>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self)
+ case .fixedsizebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self)
+ case .fixedsizelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self)
+ case .map:
+ try ForwardOffset<org_apache_arrow_flatbuf_Map>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self)
+ case .duration:
+ try ForwardOffset<org_apache_arrow_flatbuf_Duration>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self)
+ case .largebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self)
+ case .largeutf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeUtf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self)
+ case .largelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self)
+ case .runendencoded:
+ try ForwardOffset<org_apache_arrow_flatbuf_RunEndEncoded>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self)
+ }
+ })
+ try _v.visit(field: VTOFFSET.shape.p, fieldName: "shape", required: true, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_TensorDim>, org_apache_arrow_flatbuf_TensorDim>>.self)
+ try _v.visit(field: VTOFFSET.nonZeroLength.p, fieldName: "nonZeroLength", required: false, type: Int64.self)
+ try _v.visit(unionKey: VTOFFSET.sparseIndexType.p, unionField: VTOFFSET.sparseIndex.p, unionKeyName: "sparseIndexType", fieldName: "sparseIndex", required: true, completion: { (verifier, key: org_apache_arrow_flatbuf_SparseTensorIndex, pos) in
+ switch key {
+ case .none_:
+ break // NOTE - SWIFT doesnt support none
+ case .sparsetensorindexcoo:
+ try ForwardOffset<org_apache_arrow_flatbuf_SparseTensorIndexCOO>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseTensorIndexCOO.self)
+ case .sparsematrixindexcsx:
+ try ForwardOffset<org_apache_arrow_flatbuf_SparseMatrixIndexCSX>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseMatrixIndexCSX.self)
+ case .sparsetensorindexcsf:
+ try ForwardOffset<org_apache_arrow_flatbuf_SparseTensorIndexCSF>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseTensorIndexCSF.self)
+ }
+ })
+ try _v.visit(field: VTOFFSET.data.p, fieldName: "data", required: true, type: org_apache_arrow_flatbuf_Buffer.self)
+ _v.finish()
+ }
+}
+
diff --git a/swift/Arrow/Sources/Arrow/Tensor_generated.swift b/swift/Arrow/Sources/Arrow/Tensor_generated.swift
new file mode 100644
index 0000000000..cd8fd14bb1
--- /dev/null
+++ b/swift/Arrow/Sources/Arrow/Tensor_generated.swift
@@ -0,0 +1,193 @@
+// 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.
+
+// automatically generated by the FlatBuffers compiler, do not modify
+// swiftlint:disable all
+// swiftformat:disable all
+
+import FlatBuffers
+
+/// ----------------------------------------------------------------------
+/// Data structures for dense tensors
+/// Shape data for a single axis in a tensor
+public struct org_apache_arrow_flatbuf_TensorDim: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsTensorDim(bb: ByteBuffer) -> org_apache_arrow_flatbuf_TensorDim { return org_apache_arrow_flatbuf_TensorDim(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case size = 4
+ case name = 6
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ /// Length of dimension
+ public var size: Int64 { let o = _accessor.offset(VTOFFSET.size.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
+ /// Name of the dimension, optional
+ public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
+ public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
+ public static func startTensorDim(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
+ public static func add(size: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: size, def: 0, at: VTOFFSET.size.p) }
+ public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
+ public static func endTensorDim(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
+ public static func createTensorDim(
+ _ fbb: inout FlatBufferBuilder,
+ size: Int64 = 0,
+ nameOffset name: Offset = Offset()
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_TensorDim.startTensorDim(&fbb)
+ org_apache_arrow_flatbuf_TensorDim.add(size: size, &fbb)
+ org_apache_arrow_flatbuf_TensorDim.add(name: name, &fbb)
+ return org_apache_arrow_flatbuf_TensorDim.endTensorDim(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(field: VTOFFSET.size.p, fieldName: "size", required: false, type: Int64.self)
+ try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
+ _v.finish()
+ }
+}
+
+public struct org_apache_arrow_flatbuf_Tensor: FlatBufferObject, Verifiable {
+
+ static func validateVersion() { FlatBuffersVersion_23_1_4() }
+ public var __buffer: ByteBuffer! { return _accessor.bb }
+ private var _accessor: Table
+
+ public static func getRootAsTensor(bb: ByteBuffer) -> org_apache_arrow_flatbuf_Tensor { return org_apache_arrow_flatbuf_Tensor(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
+
+ private init(_ t: Table) { _accessor = t }
+ public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
+
+ private enum VTOFFSET: VOffset {
+ case typeType = 4
+ case type = 6
+ case shape = 8
+ case strides = 10
+ case data = 12
+ var v: Int32 { Int32(self.rawValue) }
+ var p: VOffset { self.rawValue }
+ }
+
+ public var typeType: org_apache_arrow_flatbuf_Type_ { let o = _accessor.offset(VTOFFSET.typeType.v); return o == 0 ? .none_ : org_apache_arrow_flatbuf_Type_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
+ /// The type of data contained in a value cell. Currently only fixed-width
+ /// value types are supported, no strings or nested types
+ public func type<T: FlatbuffersInitializable>(type: T.Type) -> T! { let o = _accessor.offset(VTOFFSET.type.v); return _accessor.union(o) }
+ /// The dimensions of the tensor, optionally named
+ public var hasShape: Bool { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? false : true }
+ public var shapeCount: Int32 { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func shape(at index: Int32) -> org_apache_arrow_flatbuf_TensorDim? { let o = _accessor.offset(VTOFFSET.shape.v); return o == 0 ? nil : org_apache_arrow_flatbuf_TensorDim(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
+ /// Non-negative byte offsets to advance one value cell along each dimension
+ /// If omitted, default to row-major order (C-like).
+ public var hasStrides: Bool { let o = _accessor.offset(VTOFFSET.strides.v); return o == 0 ? false : true }
+ public var stridesCount: Int32 { let o = _accessor.offset(VTOFFSET.strides.v); return o == 0 ? 0 : _accessor.vector(count: o) }
+ public func strides(at index: Int32) -> Int64 { let o = _accessor.offset(VTOFFSET.strides.v); return o == 0 ? 0 : _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8) }
+ public var strides: [Int64] { return _accessor.getVector(at: VTOFFSET.strides.v) ?? [] }
+ /// The location and size of the tensor's data
+ public var data: org_apache_arrow_flatbuf_Buffer! { let o = _accessor.offset(VTOFFSET.data.v); return _accessor.readBuffer(of: org_apache_arrow_flatbuf_Buffer.self, at: o) }
+ public var mutableData: org_apache_arrow_flatbuf_Buffer_Mutable! { let o = _accessor.offset(VTOFFSET.data.v); return org_apache_arrow_flatbuf_Buffer_Mutable(_accessor.bb, o: o + _accessor.postion) }
+ public static func startTensor(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
+ public static func add(typeType: org_apache_arrow_flatbuf_Type_, _ fbb: inout FlatBufferBuilder) { fbb.add(element: typeType.rawValue, def: 0, at: VTOFFSET.typeType.p) }
+ public static func add(type: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: type, at: VTOFFSET.type.p) }
+ public static func addVectorOf(shape: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: shape, at: VTOFFSET.shape.p) }
+ public static func addVectorOf(strides: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: strides, at: VTOFFSET.strides.p) }
+ public static func add(data: org_apache_arrow_flatbuf_Buffer?, _ fbb: inout FlatBufferBuilder) { guard let data = data else { return }; fbb.create(struct: data, position: VTOFFSET.data.p) }
+ public static func endTensor(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8, 12]); return end }
+ public static func createTensor(
+ _ fbb: inout FlatBufferBuilder,
+ typeType: org_apache_arrow_flatbuf_Type_ = .none_,
+ typeOffset type: Offset,
+ shapeVectorOffset shape: Offset,
+ stridesVectorOffset strides: Offset = Offset(),
+ data: org_apache_arrow_flatbuf_Buffer
+ ) -> Offset {
+ let __start = org_apache_arrow_flatbuf_Tensor.startTensor(&fbb)
+ org_apache_arrow_flatbuf_Tensor.add(typeType: typeType, &fbb)
+ org_apache_arrow_flatbuf_Tensor.add(type: type, &fbb)
+ org_apache_arrow_flatbuf_Tensor.addVectorOf(shape: shape, &fbb)
+ org_apache_arrow_flatbuf_Tensor.addVectorOf(strides: strides, &fbb)
+ org_apache_arrow_flatbuf_Tensor.add(data: data, &fbb)
+ return org_apache_arrow_flatbuf_Tensor.endTensor(&fbb, start: __start)
+ }
+
+ public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
+ var _v = try verifier.visitTable(at: position)
+ try _v.visit(unionKey: VTOFFSET.typeType.p, unionField: VTOFFSET.type.p, unionKeyName: "typeType", fieldName: "type", required: true, completion: { (verifier, key: org_apache_arrow_flatbuf_Type_, pos) in
+ switch key {
+ case .none_:
+ break // NOTE - SWIFT doesnt support none
+ case .null:
+ try ForwardOffset<org_apache_arrow_flatbuf_Null>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self)
+ case .int:
+ try ForwardOffset<org_apache_arrow_flatbuf_Int>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self)
+ case .floatingpoint:
+ try ForwardOffset<org_apache_arrow_flatbuf_FloatingPoint>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self)
+ case .binary:
+ try ForwardOffset<org_apache_arrow_flatbuf_Binary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self)
+ case .utf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_Utf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self)
+ case .bool:
+ try ForwardOffset<org_apache_arrow_flatbuf_Bool>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self)
+ case .decimal:
+ try ForwardOffset<org_apache_arrow_flatbuf_Decimal>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self)
+ case .date:
+ try ForwardOffset<org_apache_arrow_flatbuf_Date>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self)
+ case .time:
+ try ForwardOffset<org_apache_arrow_flatbuf_Time>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self)
+ case .timestamp:
+ try ForwardOffset<org_apache_arrow_flatbuf_Timestamp>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self)
+ case .interval:
+ try ForwardOffset<org_apache_arrow_flatbuf_Interval>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self)
+ case .list:
+ try ForwardOffset<org_apache_arrow_flatbuf_List>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self)
+ case .struct_:
+ try ForwardOffset<org_apache_arrow_flatbuf_Struct_>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self)
+ case .union:
+ try ForwardOffset<org_apache_arrow_flatbuf_Union>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self)
+ case .fixedsizebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self)
+ case .fixedsizelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_FixedSizeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self)
+ case .map:
+ try ForwardOffset<org_apache_arrow_flatbuf_Map>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self)
+ case .duration:
+ try ForwardOffset<org_apache_arrow_flatbuf_Duration>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self)
+ case .largebinary:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeBinary>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self)
+ case .largeutf8:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeUtf8>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self)
+ case .largelist:
+ try ForwardOffset<org_apache_arrow_flatbuf_LargeList>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self)
+ case .runendencoded:
+ try ForwardOffset<org_apache_arrow_flatbuf_RunEndEncoded>.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self)
+ }
+ })
+ try _v.visit(field: VTOFFSET.shape.p, fieldName: "shape", required: true, type: ForwardOffset<Vector<ForwardOffset<org_apache_arrow_flatbuf_TensorDim>, org_apache_arrow_flatbuf_TensorDim>>.self)
+ try _v.visit(field: VTOFFSET.strides.p, fieldName: "strides", required: false, type: ForwardOffset<Vector<Int64, Int64>>.self)
+ try _v.visit(field: VTOFFSET.data.p, fieldName: "data", required: true, type: org_apache_arrow_flatbuf_Buffer.self)
+ _v.finish()
+ }
+}
+
diff --git a/swift/Arrow/Tests/ArrowTests/IPCTests.swift b/swift/Arrow/Tests/ArrowTests/IPCTests.swift
new file mode 100644
index 0000000000..9f876f80a5
--- /dev/null
+++ b/swift/Arrow/Tests/ArrowTests/IPCTests.swift
@@ -0,0 +1,80 @@
+// 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.
+
+import XCTest
+import FlatBuffers
+@testable import Arrow
+
+final class IPCTests: XCTestCase {
+ func currentDirectory(path: String = #file) -> URL {
+ return URL(fileURLWithPath: path).deletingLastPathComponent()
+ }
+
+ func testFileReader() throws {
+ let fileURL = currentDirectory().appendingPathComponent("../../testdata_double.arrow")
+ let arrowReader = ArrowReader()
+ let recordBatchs = try arrowReader.fromFile(fileURL)
+ XCTAssertEqual(recordBatchs.count, 1)
+ for recordBatch in recordBatchs {
+ XCTAssertEqual(recordBatch.length, 5)
+ XCTAssertEqual(recordBatch.columns.count, 2)
+ XCTAssertEqual(recordBatch.schema.fields.count, 2)
+ XCTAssertEqual(recordBatch.schema.fields[0].name, "one")
+ XCTAssertEqual(recordBatch.schema.fields[0].type, ArrowType.ArrowDouble)
+ XCTAssertEqual(recordBatch.schema.fields[1].name, "two")
+ XCTAssertEqual(recordBatch.schema.fields[1].type, ArrowType.ArrowString)
+ for index in 0..<recordBatch.length {
+ let column = recordBatch.columns[1]
+ let str = column.holder as! AsString
+ let val = "\(str.asString(index))"
+ if index != 1 {
+ XCTAssertNotEqual(val, "")
+ } else {
+ XCTAssertEqual(val, "")
+ }
+ }
+ }
+ }
+
+ func testFileReader_bool() throws {
+ let fileURL = currentDirectory().appendingPathComponent("../../testdata_bool.arrow")
+ let arrowReader = ArrowReader()
+ let recordBatchs = try arrowReader.fromFile(fileURL)
+ XCTAssertEqual(recordBatchs.count, 1)
+ for recordBatch in recordBatchs {
+ XCTAssertEqual(recordBatch.length, 5)
+ XCTAssertEqual(recordBatch.columns.count, 2)
+ XCTAssertEqual(recordBatch.schema.fields.count, 2)
+ XCTAssertEqual(recordBatch.schema.fields[0].name, "one")
+ XCTAssertEqual(recordBatch.schema.fields[0].type, ArrowType.ArrowBool)
+ XCTAssertEqual(recordBatch.schema.fields[1].name, "two")
+ XCTAssertEqual(recordBatch.schema.fields[1].type, ArrowType.ArrowString)
+ for index in 0..<recordBatch.length {
+ let column = recordBatch.columns[0]
+ let str = column.holder as! AsString
+ let val = "\(str.asString(index))"
+ if index == 0 || index == 4 {
+ XCTAssertEqual(val, "true")
+ } else if index == 2 {
+ XCTAssertEqual(val, "")
+ } else {
+ XCTAssertEqual(val, "false")
+ }
+ }
+ }
+ }
+}
diff --git a/swift/data-generator/swift-datagen/go.mod b/swift/data-generator/swift-datagen/go.mod
new file mode 100644
index 0000000000..83a0d26149
--- /dev/null
+++ b/swift/data-generator/swift-datagen/go.mod
@@ -0,0 +1,40 @@
+// 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.
+
+module swift-datagen/main
+
+go 1.20
+
+require github.com/apache/arrow/go/v12 v12.0.0-20230424155504-5de56928e0fe
+
+require (
+ github.com/andybalholm/brotli v1.0.4 // indirect
+ github.com/apache/thrift v0.16.0 // indirect
+ github.com/goccy/go-json v0.9.11 // indirect
+ github.com/golang/snappy v0.0.4 // indirect
+ github.com/google/flatbuffers v2.0.8+incompatible // indirect
+ github.com/klauspost/asmfmt v1.3.2 // indirect
+ github.com/klauspost/compress v1.15.9 // indirect
+ github.com/klauspost/cpuid/v2 v2.0.9 // indirect
+ github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
+ github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
+ github.com/pierrec/lz4/v4 v4.1.15 // indirect
+ github.com/zeebo/xxh3 v1.0.2 // indirect
+ golang.org/x/mod v0.8.0 // indirect
+ golang.org/x/sys v0.5.0 // indirect
+ golang.org/x/tools v0.6.0 // indirect
+ golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
+)
diff --git a/swift/data-generator/swift-datagen/go.sum b/swift/data-generator/swift-datagen/go.sum
new file mode 100644
index 0000000000..a38c27351d
--- /dev/null
+++ b/swift/data-generator/swift-datagen/go.sum
@@ -0,0 +1,47 @@
+github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
+github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
+github.com/apache/arrow/go/v12 v12.0.0-20230424155504-5de56928e0fe h1:1imeesaihTgA2ovJ1HlJp09yNlW1xp8pZt6geRIg67c=
+github.com/apache/arrow/go/v12 v12.0.0-20230424155504-5de56928e0fe/go.mod h1:d+tV/eHZZ7Dz7RPrFKtPK02tpr+c9/PEd/zm8mDS9Vg=
+github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY=
+github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
+github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
+github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
+github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM=
+github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
+github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4=
+github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE=
+github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
+github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
+github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs=
+github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
+github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI=
+github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
+github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
+github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
+github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0=
+golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
diff --git a/swift/data-generator/swift-datagen/main.go b/swift/data-generator/swift-datagen/main.go
new file mode 100644
index 0000000000..a60fb56293
--- /dev/null
+++ b/swift/data-generator/swift-datagen/main.go
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "log"
+ "os"
+
+ "github.com/apache/arrow/go/v12/arrow"
+ "github.com/apache/arrow/go/v12/arrow/array"
+ "github.com/apache/arrow/go/v12/arrow/memory"
+ "github.com/apache/arrow/go/v12/arrow/ipc"
+)
+
+func writeBytes(rec arrow.Record, file_name string) {
+ file, err := os.Create(file_name)
+ defer file.Close()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ rr, write_err := ipc.NewFileWriter(file, ipc.WithSchema(rec.Schema()))
+ if write_err != nil {
+ log.Fatal(write_err)
+ }
+
+ rr.Write(rec)
+ rr.Close()
+}
+
+
+func writeBoolData() {
+ alloc := memory.NewGoAllocator()
+ schema := arrow.NewSchema([]arrow.Field{
+ {Name: "one", Type: arrow.FixedWidthTypes.Boolean},
+ {Name: "two", Type: arrow.BinaryTypes.String},
+ }, nil)
+
+ b := array.NewRecordBuilder(alloc, schema)
+ defer b.Release()
+
+ b.Field(0).(*array.BooleanBuilder).AppendValues([]bool{true, false,}, nil)
+ b.Field(0).(*array.BooleanBuilder).AppendNull()
+ b.Field(0).(*array.BooleanBuilder).AppendValues([]bool{false, true,}, nil)
+ b.Field(1).(*array.StringBuilder).AppendValues([]string{"zero", "one", "two", "three", "four"}, nil)
+ rec := b.NewRecord()
+ defer rec.Release()
+
+
+ writeBytes(rec, "testdata_bool.arrow")
+}
+
+func writeDoubleData() {
+ alloc := memory.NewGoAllocator()
+ schema := arrow.NewSchema([]arrow.Field{
+ {Name: "one", Type: arrow.PrimitiveTypes.Float64},
+ {Name: "two", Type: arrow.BinaryTypes.String},
+ }, nil)
+
+ b := array.NewRecordBuilder(alloc, schema)
+ defer b.Release()
+
+ b.Field(0).(*array.Float64Builder).AppendValues([]float64{1.1, 2.2, 3.3, 4.4, 5.5}, nil)
+ b.Field(1).(*array.StringBuilder).AppendValues([]string{"zero"}, nil)
+ b.Field(1).(*array.StringBuilder).AppendNull()
+ b.Field(1).(*array.StringBuilder).AppendValues([]string{"two", "three", "four"}, nil)
+ rec := b.NewRecord()
+ defer rec.Release()
+
+
+ writeBytes(rec, "testdata_double.arrow")
+}
+
+func main() {
+ writeBoolData();
+ writeDoubleData();
+}
diff --git a/swift/gen-flatbuffers.sh b/swift/gen-flatbuffers.sh
new file mode 100755
index 0000000000..f55f4eb8ba
--- /dev/null
+++ b/swift/gen-flatbuffers.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+# 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.
+
+set -eu
+pushd Arrow/Sources/Arrow/
+flatc --swift ../../../../format/Message.fbs
+flatc --swift ../../../../format/Schema.fbs
+flatc --swift ../../../../format/SparseTensor.fbs
+flatc --swift ../../../../format/Tensor.fbs
+flatc --swift ../../../../format/File.fbs
+cat <<HEADER > header.swift
+// 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.
+HEADER
+for generated_swift in *_generated.swift; do
+ mv ${generated_swift} ${generated_swift}.orig
+ cat header.swift ${generated_swift}.orig > ${generated_swift}
+ rm ${generated_swift}.orig
+done
+rm header.swift
+popd
\ No newline at end of file