diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml deleted file mode 100644 index 2e1268f52d6..00000000000 --- a/.github/workflows/swift.yml +++ /dev/null @@ -1,89 +0,0 @@ -# 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. - -name: Swift - -on: - push: - branches: - - '**' - - '!dependabot/**' - tags: - - '**' - paths: - - '.dockerignore' - - '.github/workflows/swift.yml' - - 'ci/docker/*swift*' - - 'ci/scripts/swift_*' - - 'docker-compose.yml' - - 'swift/**' - pull_request: - paths: - - '.dockerignore' - - '.github/workflows/swift.yml' - - 'ci/docker/*swift*' - - 'ci/scripts/swift_*' - - 'docker-compose.yml' - - 'swift/**' - -concurrency: - group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -permissions: - contents: read - -env: - ARCHERY_DEBUG: 1 - DOCKER_VOLUME_PREFIX: ".docker/" - -jobs: - docker: - name: AMD 64 Ubuntu Swift 5.10 - runs-on: ubuntu-latest - if: ${{ !contains(github.event.pull_request.title, 'WIP') }} - timeout-minutes: 15 - steps: - - name: Checkout Arrow - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - submodules: recursive - - name: Setup Python on hosted runner - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - with: - python-version: 3 - - name: Setup Archery - run: pip install -e dev/archery[docker] - - name: Execute Docker Build - env: - ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }} - ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - run: | - source ci/scripts/util_enable_core_dumps.sh - archery docker run ubuntu-swift - - name: Docker Push - if: >- - success() && - github.event_name == 'push' && - github.repository == 'apache/arrow' && - github.ref_name == 'main' - env: - ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }} - ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - continue-on-error: true - run: archery docker push ubuntu-swift diff --git a/swift/.editorconfig b/swift/.editorconfig deleted file mode 100644 index ffaf7e24024..00000000000 --- a/swift/.editorconfig +++ /dev/null @@ -1,28 +0,0 @@ -# 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. - -# This is an EditorConfig file: https://editorconfig.org/ - -# See ../.editorconfig for inherited values - -[*.{c,cc,cpp,h,hh,hpp}] -indent_size = 4 -indent_style = space - -[*.swift] -indent_size = 4 -indent_style = space diff --git a/swift/.swiftlint.yml b/swift/.swiftlint.yml deleted file mode 100644 index 7e4da29f374..00000000000 --- a/swift/.swiftlint.yml +++ /dev/null @@ -1,38 +0,0 @@ -# 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. - -included: - - Arrow/Package.swift - - Arrow/Sources - - Arrow/Tests - - ArrowFlight/Package.swift - - ArrowFlight/Sources - - ArrowFlight/Tests - - CDataWGo/Package.swift - - CDataWGo/Sources/go-swift -excluded: - - Arrow/Sources/Arrow/File_generated.swift - - Arrow/Sources/Arrow/Message_generated.swift - - Arrow/Sources/Arrow/Schema_generated.swift - - Arrow/Sources/Arrow/SparseTensor_generated.swift - - Arrow/Sources/Arrow/Tensor_generated.swift - - ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift - - ArrowFlight/Sources/ArrowFlight/Flight.pb.swift - - ArrowFlight/Sources/ArrowFlight/FlightSql.pb.swift -identifier_name: - min_length: 2 # only warning -allow_zero_lintable_files: false diff --git a/swift/Arrow/.gitignore b/swift/Arrow/.gitignore deleted file mode 100644 index d561187385c..00000000000 --- a/swift/Arrow/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/ -.netrc -Package.resolved \ No newline at end of file diff --git a/swift/Arrow/Package.swift b/swift/Arrow/Package.swift deleted file mode 100644 index d9e328f8eea..00000000000 --- a/swift/Arrow/Package.swift +++ /dev/null @@ -1,67 +0,0 @@ -// swift-tools-version: 5.10 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -// 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 PackageDescription - -let package = Package( - name: "Arrow", - platforms: [ - .macOS(.v10_14) - ], - products: [ - .library( - name: "Arrow", - targets: ["Arrow"]) - ], - dependencies: [ - .package(url: "https://github.com/google/flatbuffers.git", branch: "v25.2.10"), - .package( - url: "https://github.com/apple/swift-atomics.git", - .upToNextMajor(from: "1.2.0") // or `.upToNextMinor - ) - ], - targets: [ - .target( - name: "ArrowC", - path: "Sources/ArrowC", - swiftSettings: [ - // build: .unsafeFlags(["-warnings-as-errors"]) - ] - - ), - .target( - name: "Arrow", - dependencies: ["ArrowC", - .product(name: "FlatBuffers", package: "flatbuffers"), - .product(name: "Atomics", package: "swift-atomics") - ], - swiftSettings: [ - // build: .unsafeFlags(["-warnings-as-errors"]) - ] - ), - .testTarget( - name: "ArrowTests", - dependencies: ["Arrow", "ArrowC"], - swiftSettings: [ - // build: .unsafeFlags(["-warnings-as-errors"]) - ] - ) - ] -) diff --git a/swift/Arrow/README.md b/swift/Arrow/README.md deleted file mode 100644 index 3acded89e1f..00000000000 --- a/swift/Arrow/README.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Apache Arrow Swift - -An implementation of Arrow targeting Swift. - -## Status - -## Memory Management - -- Allocations are 64-byte aligned and padded to 8-bytes. -- Allocations are automatically garbage collected - -## Arrays - -### Primitive Types - -- Int8, Int16, Int32, Int64 -- UInt8, UInt16, UInt32, UInt64 -- Float, Double -- String (utf-8) - -### Parametric Types - -- Date32 -- Date64 - -### Type Metadata - -- 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/ArrowArray.swift b/swift/Arrow/Sources/Arrow/ArrowArray.swift deleted file mode 100644 index 4fc1b8b9fc7..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowArray.swift +++ /dev/null @@ -1,327 +0,0 @@ -// 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 Foundation - -public protocol ArrowArrayHolder { - var type: ArrowType {get} - var length: UInt {get} - var nullCount: UInt {get} - var array: AnyArray {get} - var data: ArrowData {get} - var getBufferData: () -> [Data] {get} - var getBufferDataSizes: () -> [Int] {get} - var getArrowColumn: (ArrowField, [ArrowArrayHolder]) throws -> ArrowColumn {get} -} - -public class ArrowArrayHolderImpl: ArrowArrayHolder { - public let data: ArrowData - public let type: ArrowType - public let length: UInt - public let nullCount: UInt - public let array: AnyArray - public let getBufferData: () -> [Data] - public let getBufferDataSizes: () -> [Int] - public let getArrowColumn: (ArrowField, [ArrowArrayHolder]) throws -> ArrowColumn - public init(_ arrowArray: ArrowArray) { - self.array = arrowArray - self.data = arrowArray.arrowData - self.length = arrowArray.length - self.type = arrowArray.arrowData.type - self.nullCount = arrowArray.nullCount - self.getBufferData = {() -> [Data] in - var bufferData = [Data]() - for buffer in arrowArray.arrowData.buffers { - bufferData.append(Data()) - buffer.append(to: &bufferData[bufferData.count - 1]) - } - - return bufferData - } - - self.getBufferDataSizes = {() -> [Int] in - var bufferDataSizes = [Int]() - for buffer in arrowArray.arrowData.buffers { - bufferDataSizes.append(Int(buffer.capacity)) - } - - return bufferDataSizes - } - - self.getArrowColumn = {(field: ArrowField, arrayHolders: [ArrowArrayHolder]) throws -> ArrowColumn in - var arrays = [ArrowArray]() - for arrayHolder in arrayHolders { - if let array = arrayHolder.array as? ArrowArray { - arrays.append(array) - } - } - - return ArrowColumn(field, chunked: ChunkedArrayHolder(try ChunkedArray(arrays))) - } - } - - public static func loadArray( // swiftlint:disable:this cyclomatic_complexity - _ arrowType: ArrowType, with: ArrowData) throws -> ArrowArrayHolder { - switch arrowType.id { - case .int8: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .int16: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .int32: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .int64: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .uint8: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .uint16: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .uint32: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .uint64: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .double: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .float: - return try ArrowArrayHolderImpl(FixedArray(with)) - case .date32: - return try ArrowArrayHolderImpl(Date32Array(with)) - case .date64: - return try ArrowArrayHolderImpl(Date64Array(with)) - case .time32: - return try ArrowArrayHolderImpl(Time32Array(with)) - case .time64: - return try ArrowArrayHolderImpl(Time64Array(with)) - case .string: - return try ArrowArrayHolderImpl(StringArray(with)) - case .boolean: - return try ArrowArrayHolderImpl(BoolArray(with)) - case .binary: - return try ArrowArrayHolderImpl(BinaryArray(with)) - case .strct: - return try ArrowArrayHolderImpl(StructArray(with)) - default: - throw ArrowError.invalid("Array not found for type: \(arrowType)") - } - } -} - -public class ArrowArray: AsString, AnyArray { - public typealias ItemType = T - public let arrowData: ArrowData - public var nullCount: UInt {return self.arrowData.nullCount} - public var length: UInt {return self.arrowData.length} - - public required init(_ arrowData: ArrowData) throws { - self.arrowData = arrowData - } - - public func isNull(_ at: UInt) throws -> Bool { - if at >= self.length { - throw ArrowError.outOfBounds(index: Int64(at)) - } - - return self.arrowData.isNull(at) - } - - public subscript(_ index: UInt) -> T? { - fatalError("subscript() has not been implemented") - } - - public func asString(_ index: UInt) -> String { - if self[index] == nil { - return "" - } - - return "\(self[index]!)" - } - - public func asAny(_ index: UInt) -> Any? { - if self[index] == nil { - return nil - } - - return self[index]! - } -} - -public class FixedArray: ArrowArray { - public override subscript(_ index: UInt) -> T? { - if self.arrowData.isNull(index) { - return nil - } - - let byteOffset = self.arrowData.stride * Int(index) - return self.arrowData.buffers[1].rawPointer.advanced(by: byteOffset).load(as: T.self) - } -} - -public class StringArray: ArrowArray { - public override subscript(_ index: UInt) -> String? { - let offsetIndex = MemoryLayout.stride * Int(index) - if self.arrowData.isNull(index) { - return nil - } - - let offsets = self.arrowData.buffers[1] - let values = self.arrowData.buffers[2] - - var startIndex: Int32 = 0 - if index > 0 { - startIndex = offsets.rawPointer.advanced(by: offsetIndex).load(as: Int32.self) - } - - let endIndex = offsets.rawPointer.advanced(by: offsetIndex + MemoryLayout.stride ) - .load(as: Int32.self) - let arrayLength = Int(endIndex - startIndex) - let rawPointer = values.rawPointer.advanced(by: Int(startIndex)) - .bindMemory(to: UInt8.self, capacity: arrayLength) - let buffer = UnsafeBufferPointer(start: rawPointer, count: arrayLength) - let byteArray = Array(buffer) - return String(data: Data(byteArray), encoding: .utf8) - } -} - -public class BoolArray: ArrowArray { - public override subscript(_ index: UInt) -> Bool? { - if self.arrowData.isNull(index) { - return nil - } - - let valueBuffer = self.arrowData.buffers[1] - return BitUtility.isSet(index, buffer: valueBuffer) - } -} - -public class Date32Array: ArrowArray { - public override subscript(_ index: UInt) -> Date? { - if self.arrowData.isNull(index) { - return nil - } - - let byteOffset = self.arrowData.stride * Int(index) - let milliseconds = self.arrowData.buffers[1].rawPointer.advanced(by: byteOffset).load(as: UInt32.self) - return Date(timeIntervalSince1970: TimeInterval(milliseconds * 86400)) - } -} - -public class Date64Array: ArrowArray { - public override subscript(_ index: UInt) -> Date? { - if self.arrowData.isNull(index) { - return nil - } - - let byteOffset = self.arrowData.stride * Int(index) - let milliseconds = self.arrowData.buffers[1].rawPointer.advanced(by: byteOffset).load(as: UInt64.self) - return Date(timeIntervalSince1970: TimeInterval(milliseconds / 1000)) - } -} - -public class Time32Array: FixedArray {} -public class Time64Array: FixedArray {} - -public class BinaryArray: ArrowArray { - public struct Options { - public var printAsHex = false - public var printEncoding: String.Encoding = .utf8 - } - - public var options = Options() - - public override subscript(_ index: UInt) -> Data? { - let offsetIndex = MemoryLayout.stride * Int(index) - if self.arrowData.isNull(index) { - return nil - } - - let offsets = self.arrowData.buffers[1] - let values = self.arrowData.buffers[2] - var startIndex: Int32 = 0 - if index > 0 { - startIndex = offsets.rawPointer.advanced(by: offsetIndex).load(as: Int32.self) - } - - let endIndex = offsets.rawPointer.advanced(by: offsetIndex + MemoryLayout.stride ) - .load(as: Int32.self) - let arrayLength = Int(endIndex - startIndex) - let rawPointer = values.rawPointer.advanced(by: Int(startIndex)) - .bindMemory(to: UInt8.self, capacity: arrayLength) - let buffer = UnsafeBufferPointer(start: rawPointer, count: arrayLength) - let byteArray = Array(buffer) - return Data(byteArray) - } - - public override func asString(_ index: UInt) -> String { - if self[index] == nil {return ""} - let data = self[index]! - if options.printAsHex { - return data.hexEncodedString() - } else { - return String(data: data, encoding: .utf8)! - } - } -} - -public class StructArray: ArrowArray<[Any?]> { - public private(set) var arrowFields: [ArrowArrayHolder]? - public required init(_ arrowData: ArrowData) throws { - try super.init(arrowData) - var fields = [ArrowArrayHolder]() - for child in arrowData.children { - fields.append(try ArrowArrayHolderImpl.loadArray(child.type, with: child)) - } - - self.arrowFields = fields - } - - public override subscript(_ index: UInt) -> [Any?]? { - if self.arrowData.isNull(index) { - return nil - } - - if let fields = arrowFields { - var result = [Any?]() - for field in fields { - result.append(field.array.asAny(index)) - } - - return result - } - - return nil - } - - public override func asString(_ index: UInt) -> String { - if self.arrowData.isNull(index) { - return "" - } - - var output = "{" - if let fields = arrowFields { - for fieldIndex in 0.. ArrowArrayHolder - func appendAny(_ val: Any?) -} - -public class ArrowArrayBuilder>: ArrowArrayHolderBuilder { - let type: ArrowType - let bufferBuilder: T - public var length: UInt {return self.bufferBuilder.length} - public var capacity: UInt {return self.bufferBuilder.capacity} - public var nullCount: UInt {return self.bufferBuilder.nullCount} - public var offset: UInt {return self.bufferBuilder.offset} - - fileprivate init(_ type: ArrowType) throws { - self.type = type - self.bufferBuilder = try T() - } - - public func append(_ vals: T.ItemType?...) { - for val in vals { - self.bufferBuilder.append(val) - } - } - - public func append(_ vals: [T.ItemType?]) { - for val in vals { - self.bufferBuilder.append(val) - } - } - - public func append(_ val: T.ItemType?) { - self.bufferBuilder.append(val) - } - - public func appendAny(_ val: Any?) { - self.bufferBuilder.append(val as? T.ItemType) - } - - public func finish() throws -> ArrowArray { - let buffers = self.bufferBuilder.finish() - let arrowData = try ArrowData(self.type, buffers: buffers, nullCount: self.nullCount) - let array = try U(arrowData) - return array - } - - public func getStride() -> Int { - return self.type.getStride() - } - - public func toHolder() throws -> ArrowArrayHolder { - return try ArrowArrayHolderImpl(self.finish()) - } -} - -public class NumberArrayBuilder: ArrowArrayBuilder, FixedArray> { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.infoForNumericType(T.self))) - } -} - -public class StringArrayBuilder: ArrowArrayBuilder, StringArray> { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.ArrowString)) - } -} - -public class BinaryArrayBuilder: ArrowArrayBuilder, BinaryArray> { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.ArrowBinary)) - } -} - -public class BoolArrayBuilder: ArrowArrayBuilder { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.ArrowBool)) - } -} - -public class Date32ArrayBuilder: ArrowArrayBuilder { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.ArrowDate32)) - } -} - -public class Date64ArrayBuilder: ArrowArrayBuilder { - fileprivate convenience init() throws { - try self.init(ArrowType(ArrowType.ArrowDate64)) - } -} - -public class Time32ArrayBuilder: ArrowArrayBuilder, Time32Array> { - fileprivate convenience init(_ unit: ArrowTime32Unit) throws { - try self.init(ArrowTypeTime32(unit)) - } -} - -public class Time64ArrayBuilder: ArrowArrayBuilder, Time64Array> { - fileprivate convenience init(_ unit: ArrowTime64Unit) throws { - try self.init(ArrowTypeTime64(unit)) - } -} - -public class StructArrayBuilder: ArrowArrayBuilder { - let builders: [any ArrowArrayHolderBuilder] - let fields: [ArrowField] - public init(_ fields: [ArrowField], builders: [any ArrowArrayHolderBuilder]) throws { - self.fields = fields - self.builders = builders - try super.init(ArrowNestedType(ArrowType.ArrowStruct, fields: fields)) - self.bufferBuilder.initializeTypeInfo(fields) - } - - public init(_ fields: [ArrowField]) throws { - self.fields = fields - var builders = [any ArrowArrayHolderBuilder]() - for field in fields { - builders.append(try ArrowArrayBuilders.loadBuilder(arrowType: field.type)) - } - - self.builders = builders - try super.init(ArrowNestedType(ArrowType.ArrowStruct, fields: fields)) - } - - public override func append(_ values: [Any?]?) { - self.bufferBuilder.append(values) - if let anyValues = values { - for index in 0.. StructArray { - let buffers = self.bufferBuilder.finish() - var childData = [ArrowData]() - for builder in self.builders { - childData.append(try builder.toHolder().array.arrowData) - } - - let arrowData = try ArrowData(self.type, buffers: buffers, - children: childData, nullCount: self.nullCount, - length: self.length) - let structArray = try StructArray(arrowData) - return structArray - } -} - -public class ArrowArrayBuilders { - public static func loadBuilder( // swiftlint:disable:this cyclomatic_complexity - _ builderType: Any.Type) throws -> ArrowArrayHolderBuilder { - if builderType == Int8.self || builderType == Int8?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == Int16.self || builderType == Int16?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == Int32.self || builderType == Int32?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == Int64.self || builderType == Int64?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == Float.self || builderType == Float?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == UInt8.self || builderType == UInt8?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == UInt16.self || builderType == UInt16?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == UInt32.self || builderType == UInt32?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == UInt64.self || builderType == UInt64?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == Double.self || builderType == Double?.self { - return try ArrowArrayBuilders.loadNumberArrayBuilder() as NumberArrayBuilder - } else if builderType == String.self || builderType == String?.self { - return try ArrowArrayBuilders.loadStringArrayBuilder() - } else if builderType == Bool.self || builderType == Bool?.self { - return try ArrowArrayBuilders.loadBoolArrayBuilder() - } else if builderType == Date.self || builderType == Date?.self { - return try ArrowArrayBuilders.loadDate64ArrayBuilder() - } else { - throw ArrowError.invalid("Invalid type for builder: \(builderType)") - } - } - - public static func isValidBuilderType(_ type: T.Type) -> Bool { - return type == Int8?.self || type == Int16?.self || - type == Int32?.self || type == Int64?.self || - type == UInt8?.self || type == UInt16?.self || - type == UInt32?.self || type == UInt64?.self || - type == String?.self || type == Double?.self || - type == Float?.self || type == Date?.self || - type == Bool?.self || type == Bool.self || - type == Int8.self || type == Int16.self || - type == Int32.self || type == Int64.self || - type == UInt8.self || type == UInt16.self || - type == UInt32.self || type == UInt64.self || - type == String.self || type == Double.self || - type == Float.self || type == Date.self - } - - public static func loadStructArrayBuilderForType(_ obj: T) throws -> StructArrayBuilder { - let mirror = Mirror(reflecting: obj) - var builders = [ArrowArrayHolderBuilder]() - var fields = [ArrowField]() - for (property, value) in mirror.children { - guard let propertyName = property else { - continue - } - - let builderType = type(of: value) - let arrowType = ArrowType(ArrowType.infoForType(builderType)) - fields.append(ArrowField(propertyName, type: arrowType, isNullable: true)) - builders.append(try loadBuilder(arrowType: arrowType)) - } - - return try StructArrayBuilder(fields, builders: builders) - } - - public static func loadBuilder( // swiftlint:disable:this cyclomatic_complexity - arrowType: ArrowType) throws -> ArrowArrayHolderBuilder { - switch arrowType.id { - case .uint8: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .uint16: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .uint32: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .uint64: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .int8: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .int16: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .int32: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .int64: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .double: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .float: - return try loadNumberArrayBuilder() as NumberArrayBuilder - case .string: - return try StringArrayBuilder() - case .boolean: - return try BoolArrayBuilder() - case .binary: - return try BinaryArrayBuilder() - case .date32: - return try Date32ArrayBuilder() - case .date64: - return try Date64ArrayBuilder() - case .time32: - guard let timeType = arrowType as? ArrowTypeTime32 else { - throw ArrowError.invalid("Expected arrow type for \(arrowType.id) not found") - } - return try Time32ArrayBuilder(timeType.unit) - case .time64: - guard let timeType = arrowType as? ArrowTypeTime64 else { - throw ArrowError.invalid("Expected arrow type for \(arrowType.id) not found") - } - return try Time64ArrayBuilder(timeType.unit) - default: - throw ArrowError.unknownType("Builder not found for arrow type: \(arrowType.id)") - } - } - - public static func loadNumberArrayBuilder() throws -> NumberArrayBuilder { - let type = T.self - if type == Int8.self { - return try NumberArrayBuilder() - } else if type == Int16.self { - return try NumberArrayBuilder() - } else if type == Int32.self { - return try NumberArrayBuilder() - } else if type == Int64.self { - return try NumberArrayBuilder() - } else if type == UInt8.self { - return try NumberArrayBuilder() - } else if type == UInt16.self { - return try NumberArrayBuilder() - } else if type == UInt32.self { - return try NumberArrayBuilder() - } else if type == UInt64.self { - return try NumberArrayBuilder() - } else if type == Float.self { - return try NumberArrayBuilder() - } else if type == Double.self { - return try NumberArrayBuilder() - } else { - throw ArrowError.unknownType("Type is invalid for NumberArrayBuilder") - } - } - - public static func loadStringArrayBuilder() throws -> StringArrayBuilder { - return try StringArrayBuilder() - } - - public static func loadBoolArrayBuilder() throws -> BoolArrayBuilder { - return try BoolArrayBuilder() - } - - public static func loadDate32ArrayBuilder() throws -> Date32ArrayBuilder { - return try Date32ArrayBuilder() - } - - public static func loadDate64ArrayBuilder() throws -> Date64ArrayBuilder { - return try Date64ArrayBuilder() - } - - public static func loadBinaryArrayBuilder() throws -> BinaryArrayBuilder { - return try BinaryArrayBuilder() - } - - public static func loadTime32ArrayBuilder(_ unit: ArrowTime32Unit) throws -> Time32ArrayBuilder { - return try Time32ArrayBuilder(unit) - } - - public static func loadTime64ArrayBuilder(_ unit: ArrowTime64Unit) throws -> Time64ArrayBuilder { - return try Time64ArrayBuilder(unit) - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowBuffer.swift b/swift/Arrow/Sources/Arrow/ArrowBuffer.swift deleted file mode 100644 index 1ff53cd7dd5..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowBuffer.swift +++ /dev/null @@ -1,88 +0,0 @@ -// 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 Foundation - -public class ArrowBuffer { - static let minLength: UInt = 1 << 5 - static let maxLength = UInt.max - fileprivate(set) var length: UInt - let capacity: UInt - public let rawPointer: UnsafeMutableRawPointer - let isMemoryOwner: Bool - - init(length: UInt, capacity: UInt, rawPointer: UnsafeMutableRawPointer, isMemoryOwner: Bool = true) { - self.length = length - self.capacity = capacity - self.rawPointer = rawPointer - self.isMemoryOwner = isMemoryOwner - } - - deinit { - if isMemoryOwner { - self.rawPointer.deallocate() - } - } - - func append(to data: inout Data) { - let ptr = UnsafePointer(rawPointer.assumingMemoryBound(to: UInt8.self)) - data.append(ptr, count: Int(capacity)) - } - - static func createEmptyBuffer() -> ArrowBuffer { - return ArrowBuffer( - length: 0, - capacity: 0, - rawPointer: UnsafeMutableRawPointer.allocate(byteCount: 0, alignment: .zero)) - } - - 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.minLength) - let byteCount = size * actualLen - var capacity = byteCount - if doAlign { - capacity = alignTo64(byteCount) - } - - let memory = MemoryAllocator(64) - let rawPointer = memory.allocateArray(Int(capacity)) - rawPointer.initializeMemory(as: UInt8.self, repeating: 0, count: Int(capacity)) - return ArrowBuffer(length: length, capacity: capacity, rawPointer: rawPointer) - } - - static func copyCurrent(_ from: ArrowBuffer, to: inout ArrowBuffer, len: UInt) { - to.rawPointer.copyMemory(from: from.rawPointer, byteCount: Int(len)) - } - - private static func alignTo64(_ length: UInt) -> UInt { - let bufAlignment = length % 64 - if bufAlignment != 0 { - return length + (64 - bufAlignment) + 8 - } - - return length + 8 - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift b/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift deleted file mode 100644 index 47f9c40354b..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowBufferBuilder.swift +++ /dev/null @@ -1,381 +0,0 @@ -// 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 Foundation - -public protocol ArrowBufferBuilder { - associatedtype ItemType - var capacity: UInt {get} - var length: UInt {get} - var nullCount: UInt {get} - var offset: UInt {get} - init() throws - func append(_ newValue: ItemType?) - func isNull(_ index: UInt) -> Bool - func resize(_ length: UInt) - func finish() -> [ArrowBuffer] -} - -public class BaseBufferBuilder { - var nulls: ArrowBuffer - public var offset: UInt = 0 - public var capacity: UInt {return self.nulls.capacity} - public var length: UInt = 0 - public var nullCount: UInt = 0 - - init(_ nulls: ArrowBuffer) { - self.nulls = nulls - } - - public func isNull(_ index: UInt) -> Bool { - return self.nulls.length == 0 || BitUtility.isSet(index + self.offset, buffer: self.nulls) - } - - func resizeLength(_ data: ArrowBuffer, len: UInt = 0) -> UInt { - if len == 0 || len < data.length * 2 { - if data.length == 0 || data.length * 2 < ArrowBuffer.minLength { - return ArrowBuffer.minLength - } - return UInt(data.length * 2) - } - - return UInt(len * 2) - } -} - -public class ValuesBufferBuilder: BaseBufferBuilder { - var values: ArrowBuffer - var stride: Int - public override var capacity: UInt {return self.values.capacity} - - init(values: ArrowBuffer, nulls: ArrowBuffer, stride: Int = MemoryLayout.stride) { - self.stride = stride - self.values = values - super.init(nulls) - } -} - -public class FixedBufferBuilder: ValuesBufferBuilder, ArrowBufferBuilder { - public typealias ItemType = T - private let defaultVal: ItemType - public required init() throws { - self.defaultVal = try FixedBufferBuilder.defaultValueForType() - let values = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - let nulls = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - super.init(values: values, nulls: nulls) - } - - public func append(_ newValue: ItemType?) { - let index = UInt(self.length) - let byteIndex = self.stride * Int(index) - self.length += 1 - if length > self.values.length { - self.resize(length) - } - - 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.clearBit(index + self.offset, buffer: self.nulls) - self.values.rawPointer.advanced(by: byteIndex).storeBytes(of: defaultVal, as: T.self) - } - } - - public func resize(_ length: UInt) { - if length > self.values.length { - let resizeLength = resizeLength(self.values) - var values = ArrowBuffer.createBuffer(resizeLength, size: UInt(MemoryLayout.size)) - var nulls = ArrowBuffer.createBuffer(resizeLength/8 + 1, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: self.values.capacity) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: self.nulls.capacity) - self.values = values - self.nulls = nulls - } - } - - public func finish() -> [ArrowBuffer] { - let length = self.length - var values = ArrowBuffer.createBuffer(length, size: UInt(MemoryLayout.size)) - var nulls = ArrowBuffer.createBuffer(length/8 + 1, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: values.capacity) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: nulls.capacity) - return [nulls, values] - } - - fileprivate static func defaultValueForType() throws -> T { - let type = T.self - if type == Int8.self { - return Int8(0) as! T // swiftlint:disable:this force_cast - } else if type == Int16.self { - return Int16(0) as! T // swiftlint:disable:this force_cast - } else if type == Int32.self { - return Int32(0) as! T // swiftlint:disable:this force_cast - } else if type == Int64.self { - return Int64(0) as! T // swiftlint:disable:this force_cast - } else if type == UInt8.self { - return UInt8(0) as! T // swiftlint:disable:this force_cast - } else if type == UInt16.self { - return UInt16(0) as! T // swiftlint:disable:this force_cast - } else if type == UInt32.self { - return UInt32(0) as! T // swiftlint:disable:this force_cast - } else if type == UInt64.self { - return UInt64(0) as! T // swiftlint:disable:this force_cast - } else if type == Float.self { - return Float(0) as! T // swiftlint:disable:this force_cast - } else if type == Double.self { - return Double(0) as! T // swiftlint:disable:this force_cast - } - - throw ArrowError.unknownType("Unable to determine default value") - } -} - -public class BoolBufferBuilder: ValuesBufferBuilder, ArrowBufferBuilder { - public typealias ItemType = Bool - public required init() throws { - let values = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - let nulls = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - super.init(values: values, nulls: nulls) - } - - public func append(_ newValue: ItemType?) { - let index = UInt(self.length) - self.length += 1 - if (length/8) > self.values.length { - self.resize(length) - } - - if newValue != nil { - BitUtility.setBit(index + self.offset, buffer: self.nulls) - if newValue == true { - BitUtility.setBit(index + self.offset, buffer: self.values) - } else { - BitUtility.clearBit(index + self.offset, buffer: self.values) - } - - } else { - self.nullCount += 1 - BitUtility.clearBit(index + self.offset, buffer: self.nulls) - BitUtility.clearBit(index + self.offset, buffer: self.values) - } - } - - public func resize(_ length: UInt) { - if (length/8) > self.values.length { - let resizeLength = resizeLength(self.values) - var values = ArrowBuffer.createBuffer(resizeLength, size: UInt(MemoryLayout.size)) - var nulls = ArrowBuffer.createBuffer(resizeLength, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: self.values.capacity) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: self.nulls.capacity) - self.values = values - self.nulls = nulls - } - } - - public func finish() -> [ArrowBuffer] { - let length = self.length - var values = ArrowBuffer.createBuffer(length, size: UInt(MemoryLayout.size)) - var nulls = ArrowBuffer.createBuffer(length, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: values.capacity) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: nulls.capacity) - return [nulls, values] - } -} - -public class VariableBufferBuilder: ValuesBufferBuilder, ArrowBufferBuilder { - public typealias ItemType = T - var offsets: ArrowBuffer - let binaryStride = MemoryLayout.stride - public required init() throws { - let values = ArrowBuffer.createBuffer(0, size: UInt(binaryStride)) - let nulls = ArrowBuffer.createBuffer(0, size: UInt(binaryStride)) - self.offsets = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - super.init(values: values, nulls: nulls, stride: binaryStride) - } - - public func append(_ newValue: ItemType?) { - let index = UInt(self.length) - self.length += 1 - let offsetIndex = MemoryLayout.stride * Int(index) - if self.length >= self.offsets.length { - self.resize(UInt( self.offsets.length + 1)) - } - var binData: Data - var isNull = false - if let val = newValue { - binData = getBytesFor(val)! - } else { - var nullVal = 0 - isNull = true - binData = Data(bytes: &nullVal, count: MemoryLayout.size) - } - - var currentIndex: Int32 = 0 - var currentOffset: Int32 = Int32(binData.count) - if index > 0 { - currentIndex = self.offsets.rawPointer.advanced(by: offsetIndex).load(as: Int32.self) - currentOffset += currentIndex - if currentOffset > self.values.length { - self.value_resize(UInt(currentOffset)) - } - } - - if isNull { - self.nullCount += 1 - BitUtility.clearBit(index + self.offset, buffer: self.nulls) - } else { - BitUtility.setBit(index + self.offset, buffer: self.nulls) - } - - binData.withUnsafeBytes { bufferPointer in - let rawPointer = bufferPointer.baseAddress! - self.values.rawPointer.advanced(by: Int(currentIndex)) - .copyMemory(from: rawPointer, byteCount: binData.count) - } - - self.offsets.rawPointer.advanced(by: (offsetIndex + MemoryLayout.stride)) - .storeBytes(of: currentOffset, as: Int32.self) - } - - public func value_resize(_ length: UInt) { - if length > self.values.length { - let resizeLength = resizeLength(self.values, len: length) - var values = ArrowBuffer.createBuffer(resizeLength, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: self.values.capacity) - self.values = values - } - } - - public func resize(_ length: UInt) { - if length > self.offsets.length { - let resizeLength = resizeLength(self.offsets, len: length) - var nulls = ArrowBuffer.createBuffer(resizeLength/8 + 1, size: UInt(MemoryLayout.size)) - var offsets = ArrowBuffer.createBuffer(resizeLength, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: self.nulls.capacity) - ArrowBuffer.copyCurrent(self.offsets, to: &offsets, len: self.offsets.capacity) - self.nulls = nulls - self.offsets = offsets - } - } - - public func finish() -> [ArrowBuffer] { - let length = self.length - var values = ArrowBuffer.createBuffer(self.values.length, size: UInt(MemoryLayout.size)) - var nulls = ArrowBuffer.createBuffer(length/8 + 1, size: UInt(MemoryLayout.size)) - var offsets = ArrowBuffer.createBuffer(length, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.values, to: &values, len: values.capacity) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: nulls.capacity) - ArrowBuffer.copyCurrent(self.offsets, to: &offsets, len: offsets.capacity) - return [nulls, offsets, values] - } -} - -public class AbstractWrapperBufferBuilder: ArrowBufferBuilder { - public typealias ItemType = T - public var capacity: UInt {return self.bufferBuilder.capacity} - public var length: UInt {return self.bufferBuilder.length} - public var nullCount: UInt {return self.bufferBuilder.nullCount} - public var offset: UInt {return self.bufferBuilder.offset} - let bufferBuilder: FixedBufferBuilder - public required init() throws { - self.bufferBuilder = try FixedBufferBuilder() - } - - public func append(_ newValue: ItemType?) { - fatalError("Method is not implemented") - } - - public func isNull(_ index: UInt) -> Bool { - return self.bufferBuilder.isNull(index) - } - - public func resize(_ length: UInt) { - self.bufferBuilder.resize(length) - } - - public func finish() -> [ArrowBuffer] { - return self.bufferBuilder.finish() - } -} - -public class Date32BufferBuilder: AbstractWrapperBufferBuilder { - public override func append(_ newValue: ItemType?) { - if let val = newValue { - let daysSinceEpoch = Int32(val.timeIntervalSince1970 / 86400) - self.bufferBuilder.append(daysSinceEpoch) - } else { - self.bufferBuilder.append(nil) - } - } -} - -public class Date64BufferBuilder: AbstractWrapperBufferBuilder { - public override func append(_ newValue: ItemType?) { - if let val = newValue { - let daysSinceEpoch = Int64(val.timeIntervalSince1970 * 1000) - self.bufferBuilder.append(daysSinceEpoch) - } else { - self.bufferBuilder.append(nil) - } - } -} - -public final class StructBufferBuilder: BaseBufferBuilder, ArrowBufferBuilder { - public typealias ItemType = [Any?] - var info: ArrowNestedType? - public init() throws { - let nulls = ArrowBuffer.createBuffer(0, size: UInt(MemoryLayout.stride)) - super.init(nulls) - } - - public func initializeTypeInfo(_ fields: [ArrowField]) { - info = ArrowNestedType(ArrowType.ArrowStruct, fields: fields) - } - - public func append(_ newValue: [Any?]?) { - let index = UInt(self.length) - self.length += 1 - if length > self.nulls.length { - self.resize(length) - } - - if newValue != nil { - BitUtility.setBit(index + self.offset, buffer: self.nulls) - } else { - self.nullCount += 1 - BitUtility.clearBit(index + self.offset, buffer: self.nulls) - } - } - - public func resize(_ length: UInt) { - if length > self.nulls.length { - let resizeLength = resizeLength(self.nulls) - var nulls = ArrowBuffer.createBuffer(resizeLength/8 + 1, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: self.nulls.capacity) - self.nulls = nulls - } - } - - public func finish() -> [ArrowBuffer] { - let length = self.length - var nulls = ArrowBuffer.createBuffer(length/8 + 1, size: UInt(MemoryLayout.size)) - ArrowBuffer.copyCurrent(self.nulls, to: &nulls, len: nulls.capacity) - return [nulls] - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowCExporter.swift b/swift/Arrow/Sources/Arrow/ArrowCExporter.swift deleted file mode 100644 index f2dd8ab56d8..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowCExporter.swift +++ /dev/null @@ -1,141 +0,0 @@ -// 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 Foundation -import ArrowC -import Atomics - -// The memory used by UnsafeAtomic is not automatically -// reclaimed. Since this value is initialized once -// and used until the program/app is closed it's -// memory will be released on program/app exit -let exportDataCounter: UnsafeAtomic = .create(0) - -public class ArrowCExporter { - private class ExportData { - let id: Int - init() { - id = exportDataCounter.loadThenWrappingIncrement(ordering: .relaxed) - ArrowCExporter.exportedData[id] = self - } - } - - private class ExportSchema: ExportData { - public let arrowTypeNameCstr: UnsafePointer - public let nameCstr: UnsafePointer - private let arrowType: ArrowType - private let name: String - private let arrowTypeName: String - init(_ arrowType: ArrowType, name: String = "") throws { - self.arrowType = arrowType - // keeping the name str to ensure the cstring buffer remains valid - self.name = name - self.arrowTypeName = try arrowType.cDataFormatId - self.nameCstr = (self.name as NSString).utf8String! - self.arrowTypeNameCstr = (self.arrowTypeName as NSString).utf8String! - super.init() - } - } - - private class ExportArray: ExportData { - private let arrowData: ArrowData - private(set) var data = [UnsafeRawPointer?]() - private(set) var buffers: UnsafeMutablePointer - init(_ arrowData: ArrowData) { - // keep a reference to the ArrowData - // obj so the memory doesn't get - // deallocated - self.arrowData = arrowData - for arrowBuffer in arrowData.buffers { - self.data.append(arrowBuffer.rawPointer) - } - - self.buffers = UnsafeMutablePointer.allocate(capacity: self.data.count) - self.buffers.initialize(from: &self.data, count: self.data.count) - super.init() - } - - deinit { - self.buffers.deinitialize(count: self.data.count) - self.buffers.deallocate() - } - } - - private static var exportedData = [Int: ExportData]() - public init() {} - - public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType: ArrowType, name: String = "") -> - Result { - do { - let exportSchema = try ExportSchema(arrowType, name: name) - cSchema.format = exportSchema.arrowTypeNameCstr - cSchema.name = exportSchema.nameCstr - cSchema.private_data = - UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern: exportSchema.id)) - cSchema.release = {(data: UnsafeMutablePointer?) in - let arraySchema = data!.pointee - let exportId = Int(bitPattern: arraySchema.private_data) - guard ArrowCExporter.exportedData[exportId] != nil else { - fatalError("Export schema not found with id \(exportId)") - } - - // the data associated with this exportSchema object - // which includes the C strings for the format and name - // be deallocated upon removal - ArrowCExporter.exportedData.removeValue(forKey: exportId) - ArrowC.ArrowSwiftClearReleaseSchema(data) - } - } catch { - return .failure(.unknownError("\(error)")) - } - return .success(true) - } - - public func exportField(_ schema: inout ArrowC.ArrowSchema, field: ArrowField) -> - Result { - return exportType(&schema, arrowType: field.type, name: field.name) - } - - public func exportArray(_ cArray: inout ArrowC.ArrowArray, arrowData: ArrowData) { - let exportArray = ExportArray(arrowData) - cArray.buffers = exportArray.buffers - cArray.length = Int64(arrowData.length) - cArray.null_count = Int64(arrowData.nullCount) - cArray.n_buffers = Int64(arrowData.buffers.count) - // Swift Arrow does not currently support children or dictionaries - // This will need to be updated once support has been added - cArray.n_children = 0 - cArray.children = nil - cArray.dictionary = nil - cArray.private_data = - UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern: exportArray.id)) - cArray.release = {(data: UnsafeMutablePointer?) in - let arrayData = data!.pointee - let exportId = Int(bitPattern: arrayData.private_data) - guard ArrowCExporter.exportedData[exportId] != nil else { - fatalError("Export data not found with id \(exportId)") - } - - // the data associated with this exportArray object - // which includes the entire arrowData object - // and the buffers UnsafeMutablePointer[] will - // be deallocated upon removal - ArrowCExporter.exportedData.removeValue(forKey: exportId) - ArrowC.ArrowSwiftClearReleaseArray(data) - } - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowCImporter.swift b/swift/Arrow/Sources/Arrow/ArrowCImporter.swift deleted file mode 100644 index e65d78d730b..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowCImporter.swift +++ /dev/null @@ -1,180 +0,0 @@ -// 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 Foundation -import ArrowC - -public class ImportArrayHolder: ArrowArrayHolder { - let cArrayPtr: UnsafePointer - public var type: ArrowType {self.holder.type} - public var length: UInt {self.holder.length} - public var nullCount: UInt {self.holder.nullCount} - public var array: AnyArray {self.holder.array} - public var data: ArrowData {self.holder.data} - public var getBufferData: () -> [Data] {self.holder.getBufferData} - public var getBufferDataSizes: () -> [Int] {self.holder.getBufferDataSizes} - public var getArrowColumn: (ArrowField, [ArrowArrayHolder]) throws -> ArrowColumn {self.holder.getArrowColumn} - private let holder: ArrowArrayHolder - init(_ holder: ArrowArrayHolder, cArrayPtr: UnsafePointer) { - self.cArrayPtr = cArrayPtr - self.holder = holder - } - - deinit { - if self.cArrayPtr.pointee.release != nil { - ArrowCImporter.release(self.cArrayPtr) - } - } -} - -public class ArrowCImporter { - private func appendToBuffer( - _ cBuffer: UnsafeRawPointer?, - arrowBuffers: inout [ArrowBuffer], - length: UInt) { - if cBuffer == nil { - arrowBuffers.append(ArrowBuffer.createEmptyBuffer()) - return - } - - let pointer = UnsafeMutableRawPointer(mutating: cBuffer)! - arrowBuffers.append( - ArrowBuffer(length: length, capacity: length, rawPointer: pointer, isMemoryOwner: false)) - } - - public init() {} - - public func importType(_ cArrow: String, name: String = "") -> - Result { - do { - let type = try ArrowType.fromCDataFormatId(cArrow) - return .success(ArrowField(name, type: ArrowType(type.info), isNullable: true)) - } catch { - return .failure(.invalid("Error occurred while attempting to import type: \(error)")) - } - } - - public func importField(_ cSchema: ArrowC.ArrowSchema) -> - Result { - if cSchema.n_children > 0 { - ArrowCImporter.release(cSchema) - return .failure(.invalid("Children currently not supported")) - } else if cSchema.dictionary != nil { - ArrowCImporter.release(cSchema) - return .failure(.invalid("Dictinoary types currently not supported")) - } - - switch importType( - String(cString: cSchema.format), name: String(cString: cSchema.name)) { - case .success(let field): - ArrowCImporter.release(cSchema) - return .success(field) - case .failure(let err): - ArrowCImporter.release(cSchema) - return .failure(err) - } - } - - public func importArray( - _ cArray: UnsafePointer, - arrowType: ArrowType, - isNullable: Bool = false - ) -> Result { - let arrowField = ArrowField("", type: arrowType, isNullable: isNullable) - return importArray(cArray, arrowField: arrowField) - } - - public func importArray( // swiftlint:disable:this cyclomatic_complexity function_body_length - _ cArrayPtr: UnsafePointer, - arrowField: ArrowField - ) -> Result { - let cArray = cArrayPtr.pointee - if cArray.null_count < 0 { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("Uncomputed null count is not supported")) - } else if cArray.n_children > 0 { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("Children currently not supported")) - } else if cArray.dictionary != nil { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("Dictionary types currently not supported")) - } else if cArray.offset != 0 { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("Offset of 0 is required but found offset: \(cArray.offset)")) - } - - let arrowType = arrowField.type - let length = UInt(cArray.length) - let nullCount = UInt(cArray.null_count) - var arrowBuffers = [ArrowBuffer]() - - if cArray.n_buffers > 0 { - if cArray.buffers == nil { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("C array buffers is nil")) - } - - switch arrowType.info { - case .variableInfo: - if cArray.n_buffers != 3 { - ArrowCImporter.release(cArrayPtr) - return .failure( - .invalid("Variable buffer count expected 3 but found \(cArray.n_buffers)")) - } - - appendToBuffer(cArray.buffers[0], arrowBuffers: &arrowBuffers, length: UInt(ceil(Double(length) / 8))) - appendToBuffer(cArray.buffers[1], arrowBuffers: &arrowBuffers, length: length) - let lastOffsetLength = cArray.buffers[1]! - .advanced(by: Int(length) * MemoryLayout.stride) - .load(as: Int32.self) - appendToBuffer(cArray.buffers[2], arrowBuffers: &arrowBuffers, length: UInt(lastOffsetLength)) - default: - if cArray.n_buffers != 2 { - ArrowCImporter.release(cArrayPtr) - return .failure(.invalid("Expected buffer count 2 but found \(cArray.n_buffers)")) - } - - appendToBuffer(cArray.buffers[0], arrowBuffers: &arrowBuffers, length: UInt(ceil(Double(length) / 8))) - appendToBuffer(cArray.buffers[1], arrowBuffers: &arrowBuffers, length: length) - } - } - - switch makeArrayHolder(arrowField, buffers: arrowBuffers, - nullCount: nullCount, children: nil, rbLength: 0) { - case .success(let holder): - return .success(ImportArrayHolder(holder, cArrayPtr: cArrayPtr)) - case .failure(let err): - ArrowCImporter.release(cArrayPtr) - return .failure(err) - } - } - - public static func release(_ cArrayPtr: UnsafePointer) { - if cArrayPtr.pointee.release != nil { - let cSchemaMutablePtr = UnsafeMutablePointer(mutating: cArrayPtr) - cArrayPtr.pointee.release(cSchemaMutablePtr) - } - } - - public static func release(_ cSchema: ArrowC.ArrowSchema) { - if cSchema.release != nil { - let cSchemaPtr = UnsafeMutablePointer.allocate(capacity: 1) - cSchemaPtr.initialize(to: cSchema) - cSchema.release(cSchemaPtr) - } - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowData.swift b/swift/Arrow/Sources/Arrow/ArrowData.swift deleted file mode 100644 index 2728b9fc8b6..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowData.swift +++ /dev/null @@ -1,67 +0,0 @@ -// 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 Foundation - -public class ArrowData { - public let type: ArrowType - public let buffers: [ArrowBuffer] - public let children: [ArrowData] - public let nullCount: UInt - public let length: UInt - public let stride: Int - - convenience init(_ arrowType: ArrowType, buffers: [ArrowBuffer], nullCount: UInt) throws { - try self.init(arrowType, buffers: buffers, - children: [ArrowData](), nullCount: nullCount, - length: buffers[1].length) - } - - init(_ arrowType: ArrowType, buffers: [ArrowBuffer], children: [ArrowData], nullCount: UInt, length: UInt) throws { - let infoType = arrowType.info - switch infoType { - case let .primitiveInfo(typeId): - if typeId == ArrowTypeId.unknown { - throw ArrowError.unknownType("Unknown primitive type for data") - } - case let .variableInfo(typeId): - if typeId == ArrowTypeId.unknown { - throw ArrowError.unknownType("Unknown variable type for data") - } - case let .timeInfo(typeId): - if typeId == ArrowTypeId.unknown { - throw ArrowError.unknownType("Unknown time type for data") - } - case let .complexInfo(typeId): - if typeId == ArrowTypeId.unknown { - throw ArrowError.unknownType("Unknown complex type for data") - } - } - - self.type = arrowType - self.buffers = buffers - self.children = children - self.nullCount = nullCount - self.length = length - self.stride = arrowType.getStride() - } - - public func isNull(_ at: UInt) -> Bool { - let nullBuffer = buffers[0] - return nullBuffer.length > 0 && !BitUtility.isSet(at, buffer: nullBuffer) - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowDecoder.swift b/swift/Arrow/Sources/Arrow/ArrowDecoder.swift deleted file mode 100644 index 35dd4dcd1e8..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowDecoder.swift +++ /dev/null @@ -1,376 +0,0 @@ -// 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 Foundation - -public class ArrowDecoder: Decoder { - var rbIndex: UInt = 0 - var singleRBCol: Int = 0 - public var codingPath: [CodingKey] = [] - public var userInfo: [CodingUserInfoKey: Any] = [:] - public let rb: RecordBatch - public let nameToCol: [String: ArrowArrayHolder] - public let columns: [ArrowArrayHolder] - public init(_ decoder: ArrowDecoder) { - self.userInfo = decoder.userInfo - self.codingPath = decoder.codingPath - self.rb = decoder.rb - self.columns = decoder.columns - self.nameToCol = decoder.nameToCol - self.rbIndex = decoder.rbIndex - } - - public init(_ rb: RecordBatch) { - self.rb = rb - var colMapping = [String: ArrowArrayHolder]() - var columns = [ArrowArrayHolder]() - for index in 0..(_ type: [T: U].Type) throws -> [T: U] { - var output = [T: U]() - if rb.columnCount != 2 { - throw ArrowError.invalid("RecordBatch column count of 2 is required to decode to map") - } - - for index in 0..(_ type: T.Type) throws -> [T] { - var output = [T]() - for index in 0..(keyedBy type: Key.Type - ) -> KeyedDecodingContainer where Key: CodingKey { - let container = ArrowKeyedDecoding(self, codingPath: codingPath) - return KeyedDecodingContainer(container) - } - - public func unkeyedContainer() -> UnkeyedDecodingContainer { - return ArrowUnkeyedDecoding(self, codingPath: codingPath) - } - - public func singleValueContainer() -> SingleValueDecodingContainer { - return ArrowSingleValueDecoding(self, codingPath: codingPath) - } - - func getCol(_ name: String) throws -> AnyArray { - guard let col = self.nameToCol[name] else { - throw ArrowError.invalid("Column for key \"\(name)\" not found") - } - - return col.array - } - - func getCol(_ index: Int) throws -> AnyArray { - if index >= self.columns.count { - throw ArrowError.outOfBounds(index: Int64(index)) - } - - return self.columns[index].array - } - - func doDecode(_ key: CodingKey) throws -> T? { - let array: AnyArray = try self.getCol(key.stringValue) - return array.asAny(self.rbIndex) as? T - } - - func doDecode(_ col: Int) throws -> T? { - let array: AnyArray = try self.getCol(col) - return array.asAny(self.rbIndex) as? T - } - - func isNull(_ key: CodingKey) throws -> Bool { - let array: AnyArray = try self.getCol(key.stringValue) - return array.asAny(self.rbIndex) == nil - } - - func isNull(_ col: Int) throws -> Bool { - let array: AnyArray = try self.getCol(col) - return array.asAny(self.rbIndex) == nil - } -} - -private struct ArrowUnkeyedDecoding: UnkeyedDecodingContainer { - var codingPath: [CodingKey] - var count: Int? = 0 - var isAtEnd: Bool = false - var currentIndex: Int = 0 - let decoder: ArrowDecoder - - init(_ decoder: ArrowDecoder, codingPath: [CodingKey]) { - self.decoder = decoder - self.codingPath = codingPath - self.count = self.decoder.columns.count - } - - mutating func increment() { - self.currentIndex += 1 - self.isAtEnd = self.currentIndex >= self.count! - } - - mutating func decodeNil() throws -> Bool { - defer {increment()} - return try self.decoder.isNull(self.currentIndex) - } - - mutating func decode(_ type: T.Type) throws -> T where T: Decodable { - if type == Int8?.self || type == Int16?.self || - type == Int32?.self || type == Int64?.self || - type == UInt8?.self || type == UInt16?.self || - type == UInt32?.self || type == UInt64?.self || - type == String?.self || type == Double?.self || - type == Float?.self || type == Date?.self || - type == Bool?.self || type == Bool.self || - type == Int8.self || type == Int16.self || - type == Int32.self || type == Int64.self || - type == UInt8.self || type == UInt16.self || - type == UInt32.self || type == UInt64.self || - type == String.self || type == Double.self || - type == Float.self || type == Date.self { - defer {increment()} - return try self.decoder.doDecode(self.currentIndex)! - } else { - throw ArrowError.invalid("Type \(type) is currently not supported") - } - } - - func nestedContainer( - keyedBy type: NestedKey.Type - ) throws -> KeyedDecodingContainer where NestedKey: CodingKey { - throw ArrowError.invalid("Nested decoding is currently not supported.") - } - - func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer { - throw ArrowError.invalid("Nested decoding is currently not supported.") - } - - func superDecoder() throws -> Decoder { - throw ArrowError.invalid("super decoding is currently not supported.") - } -} - -private struct ArrowKeyedDecoding: KeyedDecodingContainerProtocol { - var codingPath = [CodingKey]() - var allKeys = [Key]() - let decoder: ArrowDecoder - - init(_ decoder: ArrowDecoder, codingPath: [CodingKey]) { - self.decoder = decoder - self.codingPath = codingPath - } - - func contains(_ key: Key) -> Bool { - return self.decoder.nameToCol.keys.contains(key.stringValue) - } - - func decodeNil(forKey key: Key) throws -> Bool { - try self.decoder.isNull(key) - } - - func decode(_ type: Bool.Type, forKey key: Key) throws -> Bool { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: String.Type, forKey key: Key) throws -> String { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Double.Type, forKey key: Key) throws -> Double { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Float.Type, forKey key: Key) throws -> Float { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Int.Type, forKey key: Key) throws -> Int { - throw ArrowError.invalid( - "Int type is not supported (please use Int8, Int16, Int32 or Int64)") - } - - func decode(_ type: Int8.Type, forKey key: Key) throws -> Int8 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Int16.Type, forKey key: Key) throws -> Int16 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Int32.Type, forKey key: Key) throws -> Int32 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: Int64.Type, forKey key: Key) throws -> Int64 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: UInt.Type, forKey key: Key) throws -> UInt { - throw ArrowError.invalid( - "UInt type is not supported (please use UInt8, UInt16, UInt32 or UInt64)") - } - - func decode(_ type: UInt8.Type, forKey key: Key) throws -> UInt8 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: UInt16.Type, forKey key: Key) throws -> UInt16 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: UInt32.Type, forKey key: Key) throws -> UInt32 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: UInt64.Type, forKey key: Key) throws -> UInt64 { - return try self.decoder.doDecode(key)! - } - - func decode(_ type: T.Type, forKey key: Key) throws -> T where T: Decodable { - if ArrowArrayBuilders.isValidBuilderType(type) || type == Date.self { - return try self.decoder.doDecode(key)! - } else { - throw ArrowError.invalid("Type \(type) is currently not supported") - } - } - - func nestedContainer( - keyedBy type: NestedKey.Type, - forKey key: Key - ) throws -> KeyedDecodingContainer where NestedKey: CodingKey { - throw ArrowError.invalid("Nested decoding is currently not supported.") - } - - func nestedUnkeyedContainer(forKey key: Key) throws -> UnkeyedDecodingContainer { - throw ArrowError.invalid("Nested decoding is currently not supported.") - } - - func superDecoder() throws -> Decoder { - throw ArrowError.invalid("super decoding is currently not supported.") - } - - func superDecoder(forKey key: Key) throws -> Decoder { - throw ArrowError.invalid("super decoding is currently not supported.") - } -} - -private struct ArrowSingleValueDecoding: SingleValueDecodingContainer { - var codingPath = [CodingKey]() - let decoder: ArrowDecoder - - init(_ decoder: ArrowDecoder, codingPath: [CodingKey]) { - self.decoder = decoder - self.codingPath = codingPath - } - - func decodeNil() -> Bool { - do { - return try self.decoder.isNull(self.decoder.singleRBCol) - } catch { - return false - } - } - - func decode(_ type: Bool.Type) throws -> Bool { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: String.Type) throws -> String { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Double.Type) throws -> Double { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Float.Type) throws -> Float { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Int.Type) throws -> Int { - throw ArrowError.invalid( - "Int type is not supported (please use Int8, Int16, Int32 or Int64)") - } - - func decode(_ type: Int8.Type) throws -> Int8 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Int16.Type) throws -> Int16 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Int32.Type) throws -> Int32 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: Int64.Type) throws -> Int64 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: UInt.Type) throws -> UInt { - throw ArrowError.invalid( - "UInt type is not supported (please use UInt8, UInt16, UInt32 or UInt64)") - } - - func decode(_ type: UInt8.Type) throws -> UInt8 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: UInt16.Type) throws -> UInt16 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: UInt32.Type) throws -> UInt32 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: UInt64.Type) throws -> UInt64 { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } - - func decode(_ type: T.Type) throws -> T where T: Decodable { - if ArrowArrayBuilders.isValidBuilderType(type) || type == Date.self { - return try self.decoder.doDecode(self.decoder.singleRBCol)! - } else { - throw ArrowError.invalid("Type \(type) is currently not supported") - } - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowEncoder.swift b/swift/Arrow/Sources/Arrow/ArrowEncoder.swift deleted file mode 100644 index 8c72c0482f2..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowEncoder.swift +++ /dev/null @@ -1,456 +0,0 @@ -// 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 Foundation - -public class ArrowEncoder: Encoder { - public private(set) var builders = [String: ArrowArrayHolderBuilder]() - private var byIndex = [String]() - public var codingPath: [CodingKey] = [] - public var userInfo: [CodingUserInfoKey: Any] = [:] - var errorMsg: String? - // this is used for Dictionary types. A dictionary type - // will give each key and value there own index so instead - // of having a 2 column RecordBatch you would have - // 2 * length(dictionary) column RecordBatch. Which would not - // be the expected output. - var modForIndex: Int? - - public init() {} - - public init(_ builders: [String: ArrowArrayHolderBuilder], byIndex: [String]) { - self.builders = builders - self.byIndex = byIndex - } - - public static func encode(_ data: T) throws -> RecordBatch { - let encoder = try loadEncoder(data) - try data.encode(to: encoder) - return try encoder.finish() - } - - public static func encode(_ rows: [T]) throws -> RecordBatch? { - if rows.isEmpty { - return nil - } - - let encoder = try loadEncoder(rows[0]) - for row in rows { - try row.encode(to: encoder) - } - - return try encoder.finish() - } - - static func loadEncoder(_ data: T) throws -> ArrowEncoder { - // this will check if T is a simple built in type - // (UInt, Int, Int8, String, Date, etc...). - if ArrowArrayBuilders.isValidBuilderType(T.self) { - let builders = ["col0": try ArrowArrayBuilders.loadBuilder(T.self)] - return ArrowEncoder(builders, byIndex: ["col0"]) - } else { - let encoder = ArrowEncoder() - if data is [AnyHashable: Any] { - encoder.modForIndex = 2 - } - - return encoder - } - } - - public func finish() throws -> RecordBatch { - try throwIfInvalid() - let batchBuilder = RecordBatch.Builder() - for key in byIndex { - batchBuilder.addColumn(key, arrowArray: try builders[key]!.toHolder()) - } - - switch batchBuilder.finish() { - case .success(let rb): - return rb - case .failure(let error): - throw error - } - } - - public func container(keyedBy type: Key.Type) -> KeyedEncodingContainer where Key: CodingKey { - var container = ArrowKeyedEncoding(self) - container.codingPath = codingPath - return KeyedEncodingContainer(container) - } - - public func unkeyedContainer() -> UnkeyedEncodingContainer { - return ArrowUnkeyedEncoding(self, codingPath: self.codingPath) - } - - public func singleValueContainer() -> SingleValueEncodingContainer { - return ArrowSingleValueEncoding(self, codingPath: codingPath) - } - - func doEncodeNil(key: CodingKey) throws { - try throwIfInvalid() - guard let builder = builders[key.stringValue] else { - throw ArrowError.invalid("Column not found for key: \(key)") - } - - builder.appendAny(nil) - } - - // This is required by the keyed and unkeyed encoders as columns are - // added when the first row of the data is encoded. This is done due - // to limitations in the Swifts Mirror API (ex: it is unable to correctly - // find the type for String? in [Int: String?]) - @discardableResult - func ensureColumnExists(_ value: T, key: String) throws -> ArrowArrayHolderBuilder { - try throwIfInvalid() - var builder = builders[key] - if builder == nil { - builder = try ArrowArrayBuilders.loadBuilder(T.self) - builders[key] = builder - byIndex.append(key) - } - - return builder! - } - - func getIndex(_ index: Int) -> Int { - return self.modForIndex == nil ? index : index % self.modForIndex! - } - - func doEncodeNil(_ keyIndex: Int) throws { - try throwIfInvalid() - let index = self.getIndex(keyIndex) - if index >= builders.count { - throw ArrowError.outOfBounds(index: Int64(index)) - } - - builders[byIndex[index]]!.appendAny(nil) - } - - func doEncode(_ value: T, key: CodingKey) throws { - try throwIfInvalid() - let builder = try ensureColumnExists(value, key: key.stringValue) - builder.appendAny(value) - } - - func doEncode(_ value: T, keyIndex: Int) throws { - try throwIfInvalid() - let index = self.getIndex(keyIndex) - if index >= builders.count { - if index == builders.count { - try ensureColumnExists(value, key: "col\(index)") - } else { - throw ArrowError.outOfBounds(index: Int64(index)) - } - } - - builders[byIndex[index]]!.appendAny(value) - } - - func throwIfInvalid() throws { - if let errorMsg = self.errorMsg { - throw ArrowError.invalid(errorMsg) - } - } -} - -private struct ArrowKeyedEncoding: KeyedEncodingContainerProtocol { - var codingPath: [CodingKey] = [] - let encoder: ArrowEncoder - init(_ encoder: ArrowEncoder) { - self.encoder = encoder - } - - // If this method is called on row 0 and the encoder is - // lazily bulding holders then this will produce an error - // as this method does not know what the underlying type - // is for the column. This method is not called for - // nullable types (String?, Int32?, Date?) and the workaround - // for this issue would be to predefine the builders for the - // encoder. (I have only encoutered this issue when allowing - // nullable types at the encode func level which is currently - // not allowed) - mutating func encodeNil(forKey key: Key) throws { - try encoder.doEncodeNil(key: key) - } - - mutating func doEncodeIf(_ value: T?, forKey key: Key) throws { - if value == nil { - try encoder.ensureColumnExists(value, key: key.stringValue) - try encoder.doEncodeNil(key: key) - } else { - try encoder.doEncode(value, key: key) - } - } - - mutating func encode(_ value: Bool, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Bool?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: String, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: String?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Double, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Double?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Float, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Float?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Int, forKey key: Key) throws { - throw ArrowError.invalid( - "Int type is not supported (please use Int8, Int16, Int32 or Int64)") - } - - mutating func encodeIfPresent(_ value: Int?, forKey key: Key) throws { - throw ArrowError.invalid( - "Int type is not supported (please use Int8, Int16, Int32 or Int64)") - } - - mutating func encode(_ value: Int8, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Int8?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Int16, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Int16?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Int32, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Int32?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: Int64, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: Int64?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: UInt, forKey key: Key) throws { - throw ArrowError.invalid( - "UInt type is not supported (please use UInt8, UInt16, UInt32 or UInt64)") - } - - mutating func encodeIfPresent(_ value: UInt?, forKey key: Key) throws { - throw ArrowError.invalid( - "UInt type is not supported (please use UInt8, UInt16, UInt32 or UInt64)") - } - - mutating func encode(_ value: UInt8, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: UInt8?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: UInt16, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: UInt16?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: UInt32, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: UInt32?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: UInt64, forKey key: Key) throws { - try encoder.doEncode(value, key: key) - } - - mutating func encodeIfPresent(_ value: UInt64?, forKey key: Key) throws { - try doEncodeIf(value, forKey: key) - } - - mutating func encode(_ value: T, forKey key: Key) throws { - if ArrowArrayBuilders.isValidBuilderType(T.self) { - try encoder.doEncode(value, key: key) - } else { - throw ArrowError.invalid("Type \(T.self) is currently not supported") - } - } - - mutating func encodeIfPresent(_ value: T?, forKey key: Self.Key) throws where T: Encodable { - if ArrowArrayBuilders.isValidBuilderType(T?.self) { - try doEncodeIf(value, forKey: key) - } else { - throw ArrowError.invalid("Type \(T.self) is currently not supported") - } - } - - // nested container is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func nestedContainer( - keyedBy keyType: NestedKey.Type, - forKey key: Key) -> KeyedEncodingContainer { - self.encoder.errorMsg = "Nested decoding is currently not supported." - var container = ArrowKeyedEncoding(self.encoder) - container.codingPath = codingPath - return KeyedEncodingContainer(container) - } - - // nested container is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer { - self.encoder.errorMsg = "Nested decoding is currently not supported." - return ArrowUnkeyedEncoding(self.encoder, codingPath: self.codingPath) - } - - // super encoding is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func superEncoder() -> Encoder { - self.encoder.errorMsg = "super encoding is currently not supported." - return self.encoder - } - - // super encoding is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func superEncoder(forKey key: Key) -> Encoder { - self.encoder.errorMsg = "super encoding is currently not supported." - return self.encoder - } -} - -private struct ArrowUnkeyedEncoding: UnkeyedEncodingContainer { - public private(set) var encoder: ArrowEncoder - var codingPath: [CodingKey] = [] - var currentIndex: Int - var count: Int = 0 - - init(_ encoder: ArrowEncoder, codingPath: [CodingKey], currentIndex: Int = 0) { - self.encoder = encoder - self.currentIndex = currentIndex - } - - mutating func increment() { - self.currentIndex += 1 - } - - // If this method is called on row 0 and the encoder is - // lazily bulding holders then this will produce an error - // as this method does not know what the underlying type - // is for the column. This method is not called for - // nullable types (String?, Int32?, Date?) and the workaround - // for this issue would be to predefine the builders for the - // encoder. (I have only encoutered this issue when allowing - // nullable types at the encode func level which is currently - // not allowed) - mutating func encodeNil() throws { - try encoder.doEncodeNil(self.currentIndex) - } - - mutating func encode(_ value: T) throws where T: Encodable { - let type = T.self - if ArrowArrayBuilders.isValidBuilderType(type) { - defer {increment()} - return try self.encoder.doEncode(value, keyIndex: self.currentIndex) - } else { - throw ArrowError.invalid("Type \(type) is currently not supported") - } - } - - // nested container is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func nestedContainer(keyedBy keyType: NestedKey.Type - ) -> KeyedEncodingContainer where NestedKey: CodingKey { - self.encoder.errorMsg = "Nested decoding is currently not supported." - var container = ArrowKeyedEncoding(self.encoder) - container.codingPath = codingPath - return KeyedEncodingContainer(container) - } - - // nested container is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func nestedUnkeyedContainer() -> UnkeyedEncodingContainer { - self.encoder.errorMsg = "Nested decoding is currently not supported." - return ArrowUnkeyedEncoding(self.encoder, codingPath: self.codingPath) - } - - // super encoding is currently not allowed. This method doesn't throw - // so setting an error mesg that will be throw by the encoder at the next - // method call that throws - mutating func superEncoder() -> Encoder { - self.encoder.errorMsg = "super encoding is currently not supported." - return self.encoder - } -} - -private struct ArrowSingleValueEncoding: SingleValueEncodingContainer { - public private(set) var encoder: ArrowEncoder - var codingPath: [CodingKey] = [] - - public init(_ encoder: ArrowEncoder, codingPath: [CodingKey]) { - self.encoder = encoder - self.codingPath = codingPath - } - - mutating func encodeNil() throws { - return try self.encoder.doEncodeNil(0) - } - - mutating func encode(_ value: T) throws { - if ArrowArrayBuilders.isValidBuilderType(T.self) { - return try self.encoder.doEncode(value, keyIndex: 0) - } else { - throw ArrowError.invalid("Type \(T.self) is currently not supported") - } - } -} -// swiftlint:disable:this file_length diff --git a/swift/Arrow/Sources/Arrow/ArrowReader.swift b/swift/Arrow/Sources/Arrow/ArrowReader.swift deleted file mode 100644 index 8515a782afa..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowReader.swift +++ /dev/null @@ -1,419 +0,0 @@ -// 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 - -let FILEMARKER = "ARROW1" -let CONTINUATIONMARKER = UInt32(0xFFFFFFFF) - -public class ArrowReader { // swiftlint:disable:this type_body_length - private class RecordBatchData { - let schema: org_apache_arrow_flatbuf_Schema - let recordBatch: org_apache_arrow_flatbuf_RecordBatch - private var fieldIndex: Int32 = 0 - private var nodeIndex: Int32 = 0 - private var bufferIndex: Int32 = 0 - init(_ recordBatch: org_apache_arrow_flatbuf_RecordBatch, - schema: org_apache_arrow_flatbuf_Schema) { - self.recordBatch = recordBatch - self.schema = schema - } - - func nextNode() -> org_apache_arrow_flatbuf_FieldNode? { - if nodeIndex >= self.recordBatch.nodesCount {return nil} - defer {nodeIndex += 1} - return self.recordBatch.nodes(at: nodeIndex) - } - - func nextBuffer() -> org_apache_arrow_flatbuf_Buffer? { - if bufferIndex >= self.recordBatch.buffersCount {return nil} - defer {bufferIndex += 1} - return self.recordBatch.buffers(at: bufferIndex) - } - - func nextField() -> org_apache_arrow_flatbuf_Field? { - if fieldIndex >= self.schema.fieldsCount {return nil} - defer {fieldIndex += 1} - return self.schema.fields(at: fieldIndex) - } - - func isDone() -> Bool { - return nodeIndex >= self.recordBatch.nodesCount - } - } - - private struct DataLoadInfo { - let fileData: Data - let messageOffset: Int64 - var batchData: RecordBatchData - } - - public class ArrowReaderResult { - fileprivate var messageSchema: org_apache_arrow_flatbuf_Schema? - public var schema: ArrowSchema? - public var batches = [RecordBatch]() - } - - public init() {} - - private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) -> Result { - let builder = ArrowSchema.Builder() - for index in 0 ..< schema.fieldsCount { - let field = schema.fields(at: index)! - let fieldType = findArrowType(field) - if fieldType.info == ArrowType.ArrowUnknown { - return .failure(.unknownType("Unsupported field type found: \(field.typeType)")) - } - let arrowField = ArrowField(field.name!, type: fieldType, isNullable: field.nullable) - builder.addField(arrowField) - } - - return .success(builder.finish()) - } - - private func loadStructData(_ loadInfo: DataLoadInfo, - field: org_apache_arrow_flatbuf_Field) - -> Result { - guard let node = loadInfo.batchData.nextNode() else { - return .failure(.invalid("Node not found")) - } - - guard let nullBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Null buffer not found")) - } - - let nullLength = UInt(ceil(Double(node.length) / 8)) - let arrowNullBuffer = makeBuffer(nullBuffer, fileData: loadInfo.fileData, - length: nullLength, messageOffset: loadInfo.messageOffset) - var children = [ArrowData]() - for index in 0.. Result { - guard let node = loadInfo.batchData.nextNode() else { - return .failure(.invalid("Node not found")) - } - - guard let nullBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Null buffer not found")) - } - - guard let valueBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Value buffer not found")) - } - - let nullLength = UInt(ceil(Double(node.length) / 8)) - let arrowNullBuffer = makeBuffer(nullBuffer, fileData: loadInfo.fileData, - length: nullLength, messageOffset: loadInfo.messageOffset) - let arrowValueBuffer = makeBuffer(valueBuffer, fileData: loadInfo.fileData, - length: UInt(node.length), messageOffset: loadInfo.messageOffset) - return makeArrayHolder(field, buffers: [arrowNullBuffer, arrowValueBuffer], - nullCount: UInt(node.nullCount), children: nil, - rbLength: UInt(loadInfo.batchData.recordBatch.length)) - } - - private func loadVariableData( - _ loadInfo: DataLoadInfo, - field: org_apache_arrow_flatbuf_Field) - -> Result { - guard let node = loadInfo.batchData.nextNode() else { - return .failure(.invalid("Node not found")) - } - - guard let nullBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Null buffer not found")) - } - - guard let offsetBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Offset buffer not found")) - } - - guard let valueBuffer = loadInfo.batchData.nextBuffer() else { - return .failure(.invalid("Value buffer not found")) - } - - let nullLength = UInt(ceil(Double(node.length) / 8)) - let arrowNullBuffer = makeBuffer(nullBuffer, fileData: loadInfo.fileData, - length: nullLength, messageOffset: loadInfo.messageOffset) - let arrowOffsetBuffer = makeBuffer(offsetBuffer, fileData: loadInfo.fileData, - length: UInt(node.length), messageOffset: loadInfo.messageOffset) - let arrowValueBuffer = makeBuffer(valueBuffer, fileData: loadInfo.fileData, - length: UInt(node.length), messageOffset: loadInfo.messageOffset) - return makeArrayHolder(field, buffers: [arrowNullBuffer, arrowOffsetBuffer, arrowValueBuffer], - nullCount: UInt(node.nullCount), children: nil, - rbLength: UInt(loadInfo.batchData.recordBatch.length)) - } - - private func loadField( - _ loadInfo: DataLoadInfo, - field: org_apache_arrow_flatbuf_Field) - -> Result { - if isNestedType(field.typeType) { - return loadStructData(loadInfo, field: field) - } else if isFixedPrimitive(field.typeType) { - return loadPrimitiveData(loadInfo, field: field) - } else { - return loadVariableData(loadInfo, field: field) - } - } - - private func loadRecordBatch( - _ recordBatch: org_apache_arrow_flatbuf_RecordBatch, - schema: org_apache_arrow_flatbuf_Schema, - arrowSchema: ArrowSchema, - data: Data, - messageEndOffset: Int64 - ) -> Result { - var columns: [ArrowArrayHolder] = [] - let batchData = RecordBatchData(recordBatch, schema: schema) - let loadInfo = DataLoadInfo(fileData: data, - messageOffset: messageEndOffset, - batchData: batchData) - while !batchData.isDone() { - guard let field = batchData.nextField() else { - return .failure(.invalid("Field not found")) - } - - let result = loadField(loadInfo, field: field) - switch result { - case .success(let holder): - columns.append(holder) - case .failure(let error): - return .failure(error) - } - } - - return .success(RecordBatch(arrowSchema, columns: columns)) - } - - /* - This is for reading the Arrow streaming format. The Arrow streaming format - is slightly different from the Arrow File format as it doesn't contain a header - and footer. - */ - public func readStreaming( // swiftlint:disable:this function_body_length - _ input: Data, - useUnalignedBuffers: Bool = false - ) -> Result { - let result = ArrowReaderResult() - var offset: Int = 0 - var length = getUInt32(input, offset: offset) - var streamData = input - var schemaMessage: org_apache_arrow_flatbuf_Schema? - while length != 0 { - if length == CONTINUATIONMARKER { - offset += Int(MemoryLayout.size) - length = getUInt32(input, offset: offset) - if length == 0 { - return .success(result) - } - } - - offset += Int(MemoryLayout.size) - streamData = input[offset...] - let dataBuffer = ByteBuffer( - data: streamData, - allowReadingUnalignedBuffers: true) - let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: dataBuffer) - switch message.headerType { - case .recordbatch: - do { - let rbMessage = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)! - let recordBatch = try loadRecordBatch( - rbMessage, - schema: schemaMessage!, - arrowSchema: result.schema!, - data: input, - messageEndOffset: (Int64(offset) + Int64(length))).get() - result.batches.append(recordBatch) - offset += Int(message.bodyLength + Int64(length)) - length = getUInt32(input, offset: offset) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("Unexpected error: \(error)")) - } - case .schema: - schemaMessage = message.header(type: org_apache_arrow_flatbuf_Schema.self)! - let schemaResult = loadSchema(schemaMessage!) - switch schemaResult { - case .success(let schema): - result.schema = schema - case .failure(let error): - return .failure(error) - } - offset += Int(message.bodyLength + Int64(length)) - length = getUInt32(input, offset: offset) - default: - return .failure(.unknownError("Unhandled header type: \(message.headerType)")) - } - } - return .success(result) - } - - /* - This is for reading the Arrow file format. The Arrow file format supports - random accessing the data. The Arrow file format contains a header and - footer around the Arrow streaming format. - */ - public func readFile( // swiftlint:disable:this function_body_length - _ fileData: Data, - useUnalignedBuffers: Bool = false - ) -> Result { - let footerLength = fileData.withUnsafeBytes { rawBuffer in - rawBuffer.loadUnaligned(fromByteOffset: fileData.count - 4, as: Int32.self) - } - - let result = ArrowReaderResult() - let footerStartOffset = fileData.count - Int(footerLength + 4) - let footerData = fileData[footerStartOffset...] - let footerBuffer = ByteBuffer( - data: footerData, - allowReadingUnalignedBuffers: useUnalignedBuffers) - let footer = org_apache_arrow_flatbuf_Footer.getRootAsFooter(bb: footerBuffer) - let schemaResult = loadSchema(footer.schema!) - switch schemaResult { - case .success(let schema): - result.schema = schema - case .failure(let error): - return .failure(error) - } - - 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: UInt32.self) - } - - var messageOffset: Int64 = 1 - if messageLength == CONTINUATIONMARKER { - messageOffset += 1 - messageLength = fileData.withUnsafeBytes { rawBuffer in - rawBuffer.loadUnaligned( - fromByteOffset: Int(recordBatch.offset + Int64(MemoryLayout.size)), - as: UInt32.self) - } - } - - let messageStartOffset = recordBatch.offset + (Int64(MemoryLayout.size) * messageOffset) - let messageEndOffset = messageStartOffset + Int64(messageLength) - let recordBatchData = fileData[messageStartOffset ..< messageEndOffset] - let mbb = ByteBuffer( - data: recordBatchData, - allowReadingUnalignedBuffers: useUnalignedBuffers) - let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: mbb) - switch message.headerType { - case .recordbatch: - do { - let rbMessage = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)! - let recordBatch = try loadRecordBatch( - rbMessage, - schema: footer.schema!, - arrowSchema: result.schema!, - data: fileData, - messageEndOffset: messageEndOffset).get() - result.batches.append(recordBatch) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("Unexpected error: \(error)")) - } - default: - return .failure(.unknownError("Unhandled header type: \(message.headerType)")) - } - } - - return .success(result) - } - - public func fromFile(_ fileURL: URL) -> Result { - do { - let fileData = try Data(contentsOf: fileURL) - if !validateFileData(fileData) { - return .failure(.ioError("Not a valid arrow file.")) - } - - let markerLength = FILEMARKER.utf8.count - let footerLengthEnd = Int(fileData.count - markerLength) - let data = fileData[..<(footerLengthEnd)] - return readFile(data) - } catch { - return .failure(.unknownError("Error loading file: \(error)")) - } - } - - static public func makeArrowReaderResult() -> ArrowReaderResult { - return ArrowReaderResult() - } - - public func fromMessage( - _ dataHeader: Data, - dataBody: Data, - result: ArrowReaderResult, - useUnalignedBuffers: Bool = false - ) -> Result { - let mbb = ByteBuffer( - data: dataHeader, - allowReadingUnalignedBuffers: useUnalignedBuffers) - let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: mbb) - switch message.headerType { - case .schema: - let sMessage = message.header(type: org_apache_arrow_flatbuf_Schema.self)! - switch loadSchema(sMessage) { - case .success(let schema): - result.schema = schema - result.messageSchema = sMessage - return .success(()) - case .failure(let error): - return .failure(error) - } - case .recordbatch: - let rbMessage = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)! - do { - let recordBatch = try loadRecordBatch( - rbMessage, schema: result.messageSchema!, arrowSchema: result.schema!, - data: dataBody, messageEndOffset: 0).get() - result.batches.append(recordBatch) - return .success(()) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("Unexpected error: \(error)")) - } - default: - return .failure(.unknownError("Unhandled header type: \(message.headerType)")) - } - } - -} -// swiftlint:disable:this file_length diff --git a/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift b/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift deleted file mode 100644 index 18cf41ad25a..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowReaderHelper.swift +++ /dev/null @@ -1,298 +0,0 @@ -// 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 - -private func makeBinaryHolder(_ buffers: [ArrowBuffer], - nullCount: UInt) -> Result { - do { - let arrowType = ArrowType(ArrowType.ArrowBinary) - let arrowData = try ArrowData(arrowType, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try BinaryArray(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -private func makeStringHolder(_ buffers: [ArrowBuffer], - nullCount: UInt) -> Result { - do { - let arrowType = ArrowType(ArrowType.ArrowString) - let arrowData = try ArrowData(arrowType, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try StringArray(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -private func makeDateHolder(_ field: ArrowField, - buffers: [ArrowBuffer], - nullCount: UInt -) -> Result { - do { - if field.type.id == .date32 { - let arrowData = try ArrowData(field.type, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try Date32Array(arrowData))) - } - - let arrowData = try ArrowData(field.type, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try Date64Array(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -private func makeTimeHolder(_ field: ArrowField, - buffers: [ArrowBuffer], - nullCount: UInt -) -> Result { - do { - if field.type.id == .time32 { - if let arrowType = field.type as? ArrowTypeTime32 { - let arrowData = try ArrowData(arrowType, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try FixedArray(arrowData))) - } else { - return .failure(.invalid("Incorrect field type for time: \(field.type)")) - } - } - - if let arrowType = field.type as? ArrowTypeTime64 { - let arrowData = try ArrowData(arrowType, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try FixedArray(arrowData))) - } else { - return .failure(.invalid("Incorrect field type for time: \(field.type)")) - } - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -private func makeBoolHolder(_ buffers: [ArrowBuffer], - nullCount: UInt) -> Result { - do { - let arrowType = ArrowType(ArrowType.ArrowBool) - let arrowData = try ArrowData(arrowType, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try BoolArray(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -private func makeFixedHolder( - _: T.Type, field: ArrowField, buffers: [ArrowBuffer], - nullCount: UInt -) -> Result { - do { - let arrowData = try ArrowData(field.type, buffers: buffers, nullCount: nullCount) - return .success(ArrowArrayHolderImpl(try FixedArray(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - - func makeStructHolder( - _ field: ArrowField, - buffers: [ArrowBuffer], - nullCount: UInt, - children: [ArrowData], - rbLength: UInt -) -> Result { - do { - let arrowData = try ArrowData(field.type, - buffers: buffers, children: children, - nullCount: nullCount, length: rbLength) - return .success(ArrowArrayHolderImpl(try StructArray(arrowData))) - } catch let error as ArrowError { - return .failure(error) - } catch { - return .failure(.unknownError("\(error)")) - } -} - -func makeArrayHolder( - _ field: org_apache_arrow_flatbuf_Field, - buffers: [ArrowBuffer], - nullCount: UInt, - children: [ArrowData]?, - rbLength: UInt -) -> Result { - let arrowField = fromProto(field: field) - return makeArrayHolder(arrowField, buffers: buffers, nullCount: nullCount, children: children, rbLength: rbLength) -} - -func makeArrayHolder( // swiftlint:disable:this cyclomatic_complexity - _ field: ArrowField, - buffers: [ArrowBuffer], - nullCount: UInt, - children: [ArrowData]?, - rbLength: UInt -) -> Result { - let typeId = field.type.id - switch typeId { - case .int8: - return makeFixedHolder(Int8.self, field: field, buffers: buffers, nullCount: nullCount) - case .uint8: - return makeFixedHolder(UInt8.self, field: field, buffers: buffers, nullCount: nullCount) - case .int16: - return makeFixedHolder(Int16.self, field: field, buffers: buffers, nullCount: nullCount) - case .uint16: - return makeFixedHolder(UInt16.self, field: field, buffers: buffers, nullCount: nullCount) - case .int32: - return makeFixedHolder(Int32.self, field: field, buffers: buffers, nullCount: nullCount) - case .uint32: - return makeFixedHolder(UInt32.self, field: field, buffers: buffers, nullCount: nullCount) - case .int64: - return makeFixedHolder(Int64.self, field: field, buffers: buffers, nullCount: nullCount) - case .uint64: - return makeFixedHolder(UInt64.self, field: field, buffers: buffers, nullCount: nullCount) - case .boolean: - return makeBoolHolder(buffers, nullCount: nullCount) - case .float: - return makeFixedHolder(Float.self, field: field, buffers: buffers, nullCount: nullCount) - case .double: - return makeFixedHolder(Double.self, field: field, buffers: buffers, nullCount: nullCount) - case .string: - return makeStringHolder(buffers, nullCount: nullCount) - case .binary: - return makeBinaryHolder(buffers, nullCount: nullCount) - case .date32, .date64: - return makeDateHolder(field, buffers: buffers, nullCount: nullCount) - case .time32, .time64: - return makeTimeHolder(field, buffers: buffers, nullCount: nullCount) - case .strct: - return makeStructHolder(field, buffers: buffers, nullCount: nullCount, children: children!, rbLength: rbLength) - default: - return .failure(.unknownType("Type \(typeId) currently not supported")) - } -} - -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, .time: - return true - default: - return false - } -} - -func isNestedType(_ type: org_apache_arrow_flatbuf_Type_) -> Bool { - switch type { - case .struct_: - return true - default: - return false - } -} - -func findArrowType( // swiftlint:disable:this cyclomatic_complexity function_body_length - _ field: org_apache_arrow_flatbuf_Field) -> ArrowType { - 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 ArrowType(intType.isSigned ? ArrowType.ArrowInt8 : ArrowType.ArrowUInt8) } - if bitWidth == 16 { return ArrowType(intType.isSigned ? ArrowType.ArrowInt16 : ArrowType.ArrowUInt16) } - if bitWidth == 32 { return ArrowType(intType.isSigned ? ArrowType.ArrowInt32 : ArrowType.ArrowUInt32) } - if bitWidth == 64 { return ArrowType(intType.isSigned ? ArrowType.ArrowInt64 : ArrowType.ArrowUInt64) } - return ArrowType(ArrowType.ArrowUnknown) - case .bool: - return ArrowType(ArrowType.ArrowBool) - case .floatingpoint: - let floatType = field.type(type: org_apache_arrow_flatbuf_FloatingPoint.self)! - switch floatType.precision { - case .single: - return ArrowType(ArrowType.ArrowFloat) - case .double: - return ArrowType(ArrowType.ArrowDouble) - default: - return ArrowType(ArrowType.ArrowUnknown) - } - case .utf8: - return ArrowType(ArrowType.ArrowString) - case .binary: - return ArrowType(ArrowType.ArrowBinary) - case .date: - let dateType = field.type(type: org_apache_arrow_flatbuf_Date.self)! - if dateType.unit == .day { - return ArrowType(ArrowType.ArrowDate32) - } - - return ArrowType(ArrowType.ArrowDate64) - case .time: - let timeType = field.type(type: org_apache_arrow_flatbuf_Time.self)! - if timeType.unit == .second || timeType.unit == .millisecond { - return ArrowTypeTime32(timeType.unit == .second ? .seconds : .milliseconds) - } - - return ArrowTypeTime64(timeType.unit == .microsecond ? .microseconds : .nanoseconds) - case .struct_: - _ = field.type(type: org_apache_arrow_flatbuf_Struct_.self)! - var fields = [ArrowField]() - for index in 0..= recordBatch.buffersCount { - throw ArrowError.outOfBounds(index: Int64(index)) - } -} - -func validateFileData(_ data: Data) -> Bool { - let markerLength = FILEMARKER.utf8.count - let startString = String(decoding: data[.. UInt32 { - let token = data.withUnsafeBytes { rawBuffer in - rawBuffer.loadUnaligned(fromByteOffset: offset, as: UInt32.self) - } - return token -} diff --git a/swift/Arrow/Sources/Arrow/ArrowSchema.swift b/swift/Arrow/Sources/Arrow/ArrowSchema.swift deleted file mode 100644 index 65c506d51cd..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowSchema.swift +++ /dev/null @@ -1,73 +0,0 @@ -// 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 Foundation -public class ArrowField { - public let type: ArrowType - public let name: String - public let isNullable: Bool - - init(_ name: String, type: ArrowType, isNullable: Bool) { - self.name = name - self.type = type - self.isNullable = isNullable - } -} - -public class ArrowSchema { - public let fields: [ArrowField] - public let fieldLookup: [String: Int] - init(_ fields: [ArrowField]) { - var fieldLookup = [String: Int]() - for (index, field) in fields.enumerated() { - fieldLookup[field.name] = index - } - - self.fields = fields - self.fieldLookup = fieldLookup - } - - public func field(_ index: Int) -> ArrowField { - return self.fields[index] - } - - public func fieldIndex(_ name: String) -> Int? { - return self.fieldLookup[name] - } - - public class Builder { - private var fields: [ArrowField] = [] - - public init() {} - - @discardableResult - public func addField(_ field: ArrowField) -> Builder { - fields.append(field) - return self - } - - @discardableResult - public func addField(_ name: String, type: ArrowType, isNullable: Bool) -> Builder { - fields.append(ArrowField(name, type: type, isNullable: isNullable)) - return self - } - - public func finish() -> ArrowSchema { - return ArrowSchema(fields) - } - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowTable.swift b/swift/Arrow/Sources/Arrow/ArrowTable.swift deleted file mode 100644 index dedf90f791c..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowTable.swift +++ /dev/null @@ -1,202 +0,0 @@ -// 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 Foundation - -public class ArrowColumn { - public let field: ArrowField - fileprivate let dataHolder: ChunkedArrayHolder - public var type: ArrowType {return self.dataHolder.type} - public var length: UInt {return self.dataHolder.length} - public var nullCount: UInt {return self.dataHolder.nullCount} - - public func data() -> ChunkedArray { - return (self.dataHolder.holder as! ChunkedArray) // swiftlint:disable:this force_cast - } - - public var name: String {return field.name} - public init(_ field: ArrowField, chunked: ChunkedArrayHolder) { - self.field = field - self.dataHolder = chunked - } -} - -public class ArrowTable { - public let schema: ArrowSchema - public var columnCount: UInt {return UInt(self.columns.count)} - public let rowCount: UInt - public let columns: [ArrowColumn] - init(_ schema: ArrowSchema, columns: [ArrowColumn]) { - self.schema = schema - self.columns = columns - self.rowCount = columns[0].length - } - - public static func from(recordBatches: [RecordBatch]) -> Result { - if recordBatches.isEmpty { - return .failure(.arrayHasNoElements) - } - - var holders = [[ArrowArrayHolder]]() - let schema = recordBatches[0].schema - for recordBatch in recordBatches { - for index in 0.. Result { - do { - return .success(try holders[0].getArrowColumn(field, holders)) - } catch { - return .failure(.runtimeError("\(error)")) - } - } - - public class Builder { - let schemaBuilder = ArrowSchema.Builder() - var columns = [ArrowColumn]() - - public init() {} - - @discardableResult - public func addColumn(_ fieldName: String, arrowArray: ArrowArray) throws -> Builder { - return self.addColumn(fieldName, chunked: try ChunkedArray([arrowArray])) - } - - @discardableResult - public func addColumn(_ fieldName: String, chunked: ChunkedArray) -> Builder { - let field = ArrowField(fieldName, type: chunked.type, isNullable: chunked.nullCount != 0) - self.schemaBuilder.addField(field) - self.columns.append(ArrowColumn(field, chunked: ChunkedArrayHolder(chunked))) - return self - } - - @discardableResult - public func addColumn(_ field: ArrowField, arrowArray: ArrowArray) throws -> Builder { - self.schemaBuilder.addField(field) - let holder = ChunkedArrayHolder(try ChunkedArray([arrowArray])) - self.columns.append(ArrowColumn(field, chunked: holder)) - return self - } - - @discardableResult - public func addColumn(_ field: ArrowField, chunked: ChunkedArray) -> Builder { - self.schemaBuilder.addField(field) - self.columns.append(ArrowColumn(field, chunked: ChunkedArrayHolder(chunked))) - return self - } - - @discardableResult - public func addColumn(_ column: ArrowColumn) -> Builder { - self.schemaBuilder.addField(column.field) - self.columns.append(column) - return self - } - - public func finish() -> ArrowTable { - return ArrowTable(self.schemaBuilder.finish(), columns: self.columns) - } - } -} - -public class RecordBatch { - public let schema: ArrowSchema - public var columnCount: UInt {return UInt(self.columns.count)} - public let columns: [ArrowArrayHolder] - public let length: UInt - public init(_ schema: ArrowSchema, columns: [ArrowArrayHolder]) { - self.schema = schema - self.columns = columns - self.length = columns[0].length - } - - public class Builder { - let schemaBuilder = ArrowSchema.Builder() - var columns = [ArrowArrayHolder]() - - public init() {} - - @discardableResult - public func addColumn(_ fieldName: String, arrowArray: ArrowArrayHolder) -> Builder { - let field = ArrowField(fieldName, type: arrowArray.type, isNullable: arrowArray.nullCount != 0) - self.schemaBuilder.addField(field) - self.columns.append(arrowArray) - return self - } - - @discardableResult - public func addColumn(_ field: ArrowField, arrowArray: ArrowArrayHolder) -> Builder { - self.schemaBuilder.addField(field) - self.columns.append(arrowArray) - return self - } - - public func finish() -> Result { - if columns.count > 0 { - let columnLength = columns[0].length - for column in columns { - if column.length != columnLength { // swiftlint:disable:this for_where - return .failure(.runtimeError("Columns have different sizes")) - } - } - } - return .success(RecordBatch(self.schemaBuilder.finish(), columns: self.columns)) - } - } - - public func data(for columnIndex: Int) -> ArrowArray { - let arrayHolder = column(columnIndex) - return (arrayHolder.array as! ArrowArray) // swiftlint:disable:this force_cast - } - - public func anyData(for columnIndex: Int) -> AnyArray { - let arrayHolder = column(columnIndex) - return arrayHolder.array - } - - public func column(_ index: Int) -> ArrowArrayHolder { - return self.columns[index] - } - - public func column(_ name: String) -> ArrowArrayHolder? { - if let index = self.schema.fieldIndex(name) { - return self.columns[index] - } - - return nil - } -} diff --git a/swift/Arrow/Sources/Arrow/ArrowType.swift b/swift/Arrow/Sources/Arrow/ArrowType.swift deleted file mode 100644 index b44f8591859..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowType.swift +++ /dev/null @@ -1,405 +0,0 @@ -// 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 Foundation - -public typealias Time32 = Int32 -public typealias Time64 = Int64 -public typealias Date32 = Int32 -public typealias Date64 = Int64 - -func FlatBuffersVersion_23_1_4() { // swiftlint:disable:this identifier_name -} - -public enum ArrowError: Error { - case none - case unknownType(String) - case runtimeError(String) - case outOfBounds(index: Int64) - case arrayHasNoElements - case unknownError(String) - case notImplemented - case ioError(String) - case invalid(String) -} - -public enum ArrowTypeId { - case binary - case boolean - case date32 - case date64 - case dateType - case decimal128 - case decimal256 - case dictionary - case double - case fixedSizeBinary - case fixedWidthType - case float - // case HalfFloatType - case int16 - case int32 - case int64 - case int8 - case integer - case intervalUnit - case list - case nested - case null - case number - case string - case strct - case time32 - case time64 - case time - case uint16 - case uint32 - case uint64 - case uint8 - case union - case unknown -} - -public enum ArrowTime32Unit { - case seconds - case milliseconds -} - -public enum ArrowTime64Unit { - case microseconds - case nanoseconds -} - -public class ArrowTypeTime32: ArrowType { - let unit: ArrowTime32Unit - public init(_ unit: ArrowTime32Unit) { - self.unit = unit - super.init(ArrowType.ArrowTime32) - } - - public override var cDataFormatId: String { - get throws { - switch self.unit { - case .milliseconds: - return "ttm" - case .seconds: - return "tts" - } - } - } -} - -public class ArrowTypeTime64: ArrowType { - let unit: ArrowTime64Unit - public init(_ unit: ArrowTime64Unit) { - self.unit = unit - super.init(ArrowType.ArrowTime64) - } - - public override var cDataFormatId: String { - get throws { - switch self.unit { - case .microseconds: - return "ttu" - case .nanoseconds: - return "ttn" - } - } - } -} - -public class ArrowNestedType: ArrowType { - let fields: [ArrowField] - public init(_ info: ArrowType.Info, fields: [ArrowField]) { - self.fields = fields - super.init(info) - } -} - -public class ArrowType { - public private(set) var info: ArrowType.Info - public static let ArrowInt8 = Info.primitiveInfo(ArrowTypeId.int8) - 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 ArrowFloat = Info.primitiveInfo(ArrowTypeId.float) - public static let ArrowDouble = Info.primitiveInfo(ArrowTypeId.double) - public static let ArrowUnknown = Info.primitiveInfo(ArrowTypeId.unknown) - public static let ArrowString = Info.variableInfo(ArrowTypeId.string) - public static let ArrowBool = Info.primitiveInfo(ArrowTypeId.boolean) - public static let ArrowDate32 = Info.primitiveInfo(ArrowTypeId.date32) - public static let ArrowDate64 = Info.primitiveInfo(ArrowTypeId.date64) - public static let ArrowBinary = Info.variableInfo(ArrowTypeId.binary) - public static let ArrowTime32 = Info.timeInfo(ArrowTypeId.time32) - public static let ArrowTime64 = Info.timeInfo(ArrowTypeId.time64) - public static let ArrowStruct = Info.complexInfo(ArrowTypeId.strct) - - public init(_ info: ArrowType.Info) { - self.info = info - } - - public var id: ArrowTypeId { - switch self.info { - case .primitiveInfo(let id): - return id - case .timeInfo(let id): - return id - case .variableInfo(let id): - return id - case .complexInfo(let id): - return id - } - } - - public enum Info { - case primitiveInfo(ArrowTypeId) - case variableInfo(ArrowTypeId) - case timeInfo(ArrowTypeId) - case complexInfo(ArrowTypeId) - } - - public static func infoForType( // swiftlint:disable:this cyclomatic_complexity - _ type: Any.Type) -> ArrowType.Info { - if type == String.self { - return ArrowType.ArrowString - } else if type == Date.self { - return ArrowType.ArrowDate64 - } else if type == Bool.self { - return ArrowType.ArrowBool - } else if type == Data.self { - return ArrowType.ArrowBinary - } else if type == Int8.self { - return ArrowType.ArrowInt8 - } else if type == Int16.self { - return ArrowType.ArrowInt16 - } else if type == Int32.self { - return ArrowType.ArrowInt32 - } else if type == Int64.self { - return ArrowType.ArrowInt64 - } else if type == UInt8.self { - return ArrowType.ArrowUInt8 - } else if type == UInt16.self { - return ArrowType.ArrowUInt16 - } else if type == UInt32.self { - return ArrowType.ArrowUInt32 - } else if type == UInt64.self { - return ArrowType.ArrowUInt64 - } else if type == Float.self { - return ArrowType.ArrowFloat - } else if type == Double.self { - return ArrowType.ArrowDouble - } else { - return ArrowType.ArrowUnknown - } - } - - public static func infoForNumericType(_ type: T.Type) -> ArrowType.Info { - if type == Int8.self { - return ArrowType.ArrowInt8 - } else if type == Int16.self { - return ArrowType.ArrowInt16 - } else if type == Int32.self { - return ArrowType.ArrowInt32 - } else if type == Int64.self { - return ArrowType.ArrowInt64 - } else if type == UInt8.self { - return ArrowType.ArrowUInt8 - } else if type == UInt16.self { - return ArrowType.ArrowUInt16 - } else if type == UInt32.self { - return ArrowType.ArrowUInt32 - } else if type == UInt64.self { - return ArrowType.ArrowUInt64 - } else if type == Float.self { - return ArrowType.ArrowFloat - } else if type == Double.self { - return ArrowType.ArrowDouble - } else { - return ArrowType.ArrowUnknown - } - } - - public func getStride( // swiftlint:disable:this cyclomatic_complexity - ) -> Int { - switch self.id { - case .int8: - return MemoryLayout.stride - case .int16: - return MemoryLayout.stride - case .int32: - return MemoryLayout.stride - case .int64: - return MemoryLayout.stride - case .uint8: - return MemoryLayout.stride - case .uint16: - return MemoryLayout.stride - case .uint32: - return MemoryLayout.stride - case .uint64: - return MemoryLayout.stride - case .float: - return MemoryLayout.stride - case .double: - return MemoryLayout.stride - case .boolean: - return MemoryLayout.stride - case .date32: - return MemoryLayout.stride - case .date64: - return MemoryLayout.stride - case .time32: - return MemoryLayout.stride - case .time64: - return MemoryLayout.stride - case .binary: - return MemoryLayout.stride - case .string: - return MemoryLayout.stride - case .strct: - return 0 - default: - fatalError("Stride requested for unknown type: \(self)") - } - } - - public var cDataFormatId: String { - get throws { - switch self.id { - case ArrowTypeId.int8: - return "c" - case ArrowTypeId.int16: - return "s" - case ArrowTypeId.int32: - return "i" - case ArrowTypeId.int64: - return "l" - case ArrowTypeId.uint8: - return "C" - case ArrowTypeId.uint16: - return "S" - case ArrowTypeId.uint32: - return "I" - case ArrowTypeId.uint64: - return "L" - case ArrowTypeId.float: - return "f" - case ArrowTypeId.double: - return "g" - case ArrowTypeId.boolean: - return "b" - case ArrowTypeId.date32: - return "tdD" - case ArrowTypeId.date64: - return "tdm" - case ArrowTypeId.time32: - if let time32 = self as? ArrowTypeTime32 { - return try time32.cDataFormatId - } - return "tts" - case ArrowTypeId.time64: - if let time64 = self as? ArrowTypeTime64 { - return try time64.cDataFormatId - } - return "ttu" - case ArrowTypeId.binary: - return "z" - case ArrowTypeId.string: - return "u" - default: - throw ArrowError.notImplemented - } - } - } - - public static func fromCDataFormatId( // swiftlint:disable:this cyclomatic_complexity - _ from: String) throws -> ArrowType { - if from == "c" { - return ArrowType(ArrowType.ArrowInt8) - } else if from == "s" { - return ArrowType(ArrowType.ArrowInt16) - } else if from == "i" { - return ArrowType(ArrowType.ArrowInt32) - } else if from == "l" { - return ArrowType(ArrowType.ArrowInt64) - } else if from == "C" { - return ArrowType(ArrowType.ArrowUInt8) - } else if from == "S" { - return ArrowType(ArrowType.ArrowUInt16) - } else if from == "I" { - return ArrowType(ArrowType.ArrowUInt32) - } else if from == "L" { - return ArrowType(ArrowType.ArrowUInt64) - } else if from == "f" { - return ArrowType(ArrowType.ArrowFloat) - } else if from == "g" { - return ArrowType(ArrowType.ArrowDouble) - } else if from == "b" { - return ArrowType(ArrowType.ArrowBool) - } else if from == "tdD" { - return ArrowType(ArrowType.ArrowDate32) - } else if from == "tdm" { - return ArrowType(ArrowType.ArrowDate64) - } else if from == "tts" { - return ArrowTypeTime32(.seconds) - } else if from == "ttm" { - return ArrowTypeTime32(.milliseconds) - } else if from == "ttu" { - return ArrowTypeTime64(.microseconds) - } else if from == "ttn" { - return ArrowTypeTime64(.nanoseconds) - } else if from == "z" { - return ArrowType(ArrowType.ArrowBinary) - } else if from == "u" { - return ArrowType(ArrowType.ArrowString) - } - - throw ArrowError.notImplemented - } -} - -extension ArrowType.Info: Equatable { - public static func == (lhs: ArrowType.Info, rhs: ArrowType.Info) -> Bool { - switch(lhs, rhs) { - case (.primitiveInfo(let lhsId), .primitiveInfo(let rhsId)): - return lhsId == rhsId - case (.variableInfo(let lhsId), .variableInfo(let rhsId)): - return lhsId == rhsId - case (.timeInfo(let lhsId), .timeInfo(let rhsId)): - return lhsId == rhsId - case (.complexInfo(let lhsId), .complexInfo(let rhsId)): - return lhsId == rhsId - default: - return false - } - } -} - -func getBytesFor(_ data: T) -> Data? { - if let temp = data as? String { - return temp.data(using: .utf8) - } else if T.self == Data.self { - return data as? Data - } else { - return nil - } -} -// swiftlint:disable:this file_length diff --git a/swift/Arrow/Sources/Arrow/ArrowWriter.swift b/swift/Arrow/Sources/Arrow/ArrowWriter.swift deleted file mode 100644 index 3aa25b62b49..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowWriter.swift +++ /dev/null @@ -1,434 +0,0 @@ -// 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 Foundation -import FlatBuffers - -public protocol DataWriter { - var count: Int {get} - func append(_ data: Data) -} - -public class ArrowWriter { // swiftlint:disable:this type_body_length - public class InMemDataWriter: DataWriter { - public private(set) var data: Data - public var count: Int { return data.count } - public init(_ data: Data) { - self.data = data - } - convenience init() { - self.init(Data()) - } - - public func append(_ data: Data) { - self.data.append(data) - } - } - - public class FileDataWriter: DataWriter { - private var handle: FileHandle - private var currentSize: Int = 0 - public var count: Int { return currentSize } - public init(_ handle: FileHandle) { - self.handle = handle - } - - public func append(_ data: Data) { - self.handle.write(data) - self.currentSize += data.count - } - } - - public class Info { - public let type: org_apache_arrow_flatbuf_MessageHeader - public let schema: ArrowSchema - public let batches: [RecordBatch] - public init(_ type: org_apache_arrow_flatbuf_MessageHeader, schema: ArrowSchema, batches: [RecordBatch]) { - self.type = type - self.schema = schema - self.batches = batches - } - - public convenience init(_ type: org_apache_arrow_flatbuf_MessageHeader, schema: ArrowSchema) { - self.init(type, schema: schema, batches: [RecordBatch]()) - } - } - - public init() {} - - private func writeField(_ fbb: inout FlatBufferBuilder, field: ArrowField) -> Result { - var fieldsOffset: Offset? - if let nestedField = field.type as? ArrowNestedType { - var offsets = [Offset]() - for field in nestedField.fields { - switch writeField(&fbb, field: field) { - case .success(let offset): - offsets.append(offset) - case .failure(let error): - return .failure(error) - } - } - - fieldsOffset = fbb.createVector(ofOffsets: offsets) - } - - let nameOffset = fbb.create(string: field.name) - let fieldTypeOffsetResult = toFBType(&fbb, arrowType: field.type) - let startOffset = org_apache_arrow_flatbuf_Field.startField(&fbb) - org_apache_arrow_flatbuf_Field.add(name: nameOffset, &fbb) - org_apache_arrow_flatbuf_Field.add(nullable: field.isNullable, &fbb) - if let childrenOffset = fieldsOffset { - org_apache_arrow_flatbuf_Field.addVectorOf(children: childrenOffset, &fbb) - } - - switch toFBTypeEnum(field.type) { - case .success(let type): - org_apache_arrow_flatbuf_Field.add(typeType: type, &fbb) - case .failure(let error): - return .failure(error) - } - - switch fieldTypeOffsetResult { - case .success(let offset): - org_apache_arrow_flatbuf_Field.add(type: offset, &fbb) - return .success(org_apache_arrow_flatbuf_Field.endField(&fbb, start: startOffset)) - case .failure(let error): - return .failure(error) - } - } - - private func writeSchema(_ fbb: inout FlatBufferBuilder, schema: ArrowSchema) -> Result { - var fieldOffsets = [Offset]() - for field in schema.fields { - switch writeField(&fbb, field: field) { - case .success(let offset): - fieldOffsets.append(offset) - case .failure(let error): - return .failure(error) - } - } - - let fieldsOffset: Offset = fbb.createVector(ofOffsets: fieldOffsets) - let schemaOffset = - org_apache_arrow_flatbuf_Schema.createSchema(&fbb, - endianness: .little, - fieldsVectorOffset: fieldsOffset) - return .success(schemaOffset) - - } - - private func writeRecordBatches( - _ writer: inout DataWriter, - batches: [RecordBatch] - ) -> Result<[org_apache_arrow_flatbuf_Block], ArrowError> { - var rbBlocks = [org_apache_arrow_flatbuf_Block]() - - for batch in batches { - let startIndex = writer.count - switch writeRecordBatch(batch: batch) { - case .success(let rbResult): - withUnsafeBytes(of: CONTINUATIONMARKER.littleEndian) {writer.append(Data($0))} - withUnsafeBytes(of: rbResult.1.o.littleEndian) {writer.append(Data($0))} - writer.append(rbResult.0) - switch writeRecordBatchData(&writer, fields: batch.schema.fields, columns: batch.columns) { - case .success: - rbBlocks.append( - org_apache_arrow_flatbuf_Block(offset: Int64(startIndex), - metaDataLength: Int32(0), - bodyLength: Int64(rbResult.1.o))) - case .failure(let error): - return .failure(error) - } - case .failure(let error): - return .failure(error) - } - } - - return .success(rbBlocks) - } - - private func writeFieldNodes(_ fields: [ArrowField], columns: [ArrowArrayHolder], offsets: inout [Offset], - fbb: inout FlatBufferBuilder) { - for index in (0 ..< fields.count).reversed() { - let column = columns[index] - let fieldNode = - org_apache_arrow_flatbuf_FieldNode(length: Int64(column.length), - nullCount: Int64(column.nullCount)) - offsets.append(fbb.create(struct: fieldNode)) - if let nestedType = column.type as? ArrowNestedType { - let structArray = column.array as? StructArray - writeFieldNodes(nestedType.fields, columns: structArray!.arrowFields!, offsets: &offsets, fbb: &fbb) - } - } - } - - private func writeBufferInfo(_ fields: [ArrowField], - columns: [ArrowArrayHolder], - bufferOffset: inout Int, - buffers: inout [org_apache_arrow_flatbuf_Buffer], - fbb: inout FlatBufferBuilder) { - for index in 0 ..< fields.count { - let column = columns[index] - let colBufferDataSizes = column.getBufferDataSizes() - for var bufferDataSize in colBufferDataSizes { - bufferDataSize = getPadForAlignment(bufferDataSize) - let buffer = org_apache_arrow_flatbuf_Buffer(offset: Int64(bufferOffset), length: Int64(bufferDataSize)) - buffers.append(buffer) - bufferOffset += bufferDataSize - if let nestedType = column.type as? ArrowNestedType { - let structArray = column.array as? StructArray - writeBufferInfo(nestedType.fields, columns: structArray!.arrowFields!, - bufferOffset: &bufferOffset, buffers: &buffers, fbb: &fbb) - } - } - } - } - - private func writeRecordBatch(batch: RecordBatch) -> Result<(Data, Offset), ArrowError> { - let schema = batch.schema - var fbb = FlatBufferBuilder() - - // write out field nodes - var fieldNodeOffsets = [Offset]() - fbb.startVector(schema.fields.count, elementSize: MemoryLayout.size) - writeFieldNodes(schema.fields, columns: batch.columns, offsets: &fieldNodeOffsets, fbb: &fbb) - let nodeOffset = fbb.endVector(len: fieldNodeOffsets.count) - - // write out buffers - var buffers = [org_apache_arrow_flatbuf_Buffer]() - var bufferOffset = Int(0) - writeBufferInfo(schema.fields, columns: batch.columns, - bufferOffset: &bufferOffset, buffers: &buffers, - fbb: &fbb) - org_apache_arrow_flatbuf_RecordBatch.startVectorOfBuffers(batch.schema.fields.count, in: &fbb) - for buffer in buffers.reversed() { - fbb.create(struct: buffer) - } - - let batchBuffersOffset = fbb.endVector(len: buffers.count) - let startRb = org_apache_arrow_flatbuf_RecordBatch.startRecordBatch(&fbb) - org_apache_arrow_flatbuf_RecordBatch.addVectorOf(nodes: nodeOffset, &fbb) - org_apache_arrow_flatbuf_RecordBatch.addVectorOf(buffers: batchBuffersOffset, &fbb) - org_apache_arrow_flatbuf_RecordBatch.add(length: Int64(batch.length), &fbb) - let recordBatchOffset = org_apache_arrow_flatbuf_RecordBatch.endRecordBatch(&fbb, start: startRb) - let bodySize = Int64(bufferOffset) - let startMessage = org_apache_arrow_flatbuf_Message.startMessage(&fbb) - org_apache_arrow_flatbuf_Message.add(version: .max, &fbb) - org_apache_arrow_flatbuf_Message.add(bodyLength: Int64(bodySize), &fbb) - org_apache_arrow_flatbuf_Message.add(headerType: .recordbatch, &fbb) - org_apache_arrow_flatbuf_Message.add(header: recordBatchOffset, &fbb) - let messageOffset = org_apache_arrow_flatbuf_Message.endMessage(&fbb, start: startMessage) - fbb.finish(offset: messageOffset) - return .success((fbb.data, Offset(offset: UInt32(fbb.data.count)))) - } - - private func writeRecordBatchData( - _ writer: inout DataWriter, fields: [ArrowField], - columns: [ArrowArrayHolder]) - -> Result { - for index in 0 ..< fields.count { - let column = columns[index] - let colBufferData = column.getBufferData() - for var bufferData in colBufferData { - addPadForAlignment(&bufferData) - writer.append(bufferData) - if let nestedType = column.type as? ArrowNestedType { - guard let structArray = column.array as? StructArray else { - return .failure(.invalid("Struct type array expected for nested type")) - } - - switch writeRecordBatchData(&writer, fields: nestedType.fields, columns: structArray.arrowFields!) { - case .success: - continue - case .failure(let error): - return .failure(error) - } - } - } - } - - return .success(true) - } - - private func writeFooter(schema: ArrowSchema, - rbBlocks: [org_apache_arrow_flatbuf_Block] - ) -> Result { - var fbb: FlatBufferBuilder = FlatBufferBuilder() - switch writeSchema(&fbb, schema: schema) { - case .success(let schemaOffset): - fbb.startVector(rbBlocks.count, elementSize: MemoryLayout.size) - for blkInfo in rbBlocks.reversed() { - fbb.create(struct: blkInfo) - } - - let rbBlkEnd = fbb.endVector(len: rbBlocks.count) - let footerStartOffset = org_apache_arrow_flatbuf_Footer.startFooter(&fbb) - org_apache_arrow_flatbuf_Footer.add(schema: schemaOffset, &fbb) - org_apache_arrow_flatbuf_Footer.addVectorOf(recordBatches: rbBlkEnd, &fbb) - let footerOffset = org_apache_arrow_flatbuf_Footer.endFooter(&fbb, start: footerStartOffset) - fbb.finish(offset: footerOffset) - return .success(fbb.data) - case .failure(let error): - return .failure(error) - } - } - - private func writeFile(_ writer: inout DataWriter, info: ArrowWriter.Info) -> Result { - var fbb: FlatBufferBuilder = FlatBufferBuilder() - switch writeSchema(&fbb, schema: info.schema) { - case .success(let schemaOffset): - fbb.finish(offset: schemaOffset) - writer.append(fbb.data) - case .failure(let error): - return .failure(error) - } - - switch writeRecordBatches(&writer, batches: info.batches) { - case .success(let rbBlocks): - switch writeFooter(schema: info.schema, rbBlocks: rbBlocks) { - case .success(let footerData): - fbb.finish(offset: Offset(offset: fbb.buffer.size)) - let footerOffset = writer.count - writer.append(footerData) - addPadForAlignment(&writer) - - withUnsafeBytes(of: Int32(0).littleEndian) { writer.append(Data($0)) } - let footerDiff = (UInt32(writer.count) - UInt32(footerOffset)) - withUnsafeBytes(of: footerDiff.littleEndian) { writer.append(Data($0)) } - case .failure(let error): - return .failure(error) - } - case .failure(let error): - return .failure(error) - } - - return .success(true) - } - - public func writeStreaming(_ info: ArrowWriter.Info) -> Result { - let writer: any DataWriter = InMemDataWriter() - switch toMessage(info.schema) { - case .success(let schemaData): - withUnsafeBytes(of: CONTINUATIONMARKER.littleEndian) {writer.append(Data($0))} - withUnsafeBytes(of: UInt32(schemaData.count).littleEndian) {writer.append(Data($0))} - writer.append(schemaData) - case .failure(let error): - return .failure(error) - } - - for batch in info.batches { - switch toMessage(batch) { - case .success(let batchData): - withUnsafeBytes(of: CONTINUATIONMARKER.littleEndian) {writer.append(Data($0))} - withUnsafeBytes(of: UInt32(batchData[0].count).littleEndian) {writer.append(Data($0))} - writer.append(batchData[0]) - writer.append(batchData[1]) - case .failure(let error): - return .failure(error) - } - } - - withUnsafeBytes(of: CONTINUATIONMARKER.littleEndian) {writer.append(Data($0))} - withUnsafeBytes(of: UInt32(0).littleEndian) {writer.append(Data($0))} - if let memWriter = writer as? InMemDataWriter { - return .success(memWriter.data) - } else { - return .failure(.invalid("Unable to cast writer")) - } - } - - public func writeFile(_ info: ArrowWriter.Info) -> Result { - var writer: any DataWriter = InMemDataWriter() - switch writeFile(&writer, info: info) { - case .success: - if let memWriter = writer as? InMemDataWriter { - return .success(memWriter.data) - } else { - return .failure(.invalid("Unable to cast writer")) - } - case .failure(let error): - return .failure(error) - } - } - - public func toFile(_ fileName: URL, info: ArrowWriter.Info) -> Result { - do { - try Data().write(to: fileName) - } catch { - return .failure(.ioError("\(error)")) - } - - let fileHandle = FileHandle(forUpdatingAtPath: fileName.path)! - defer { fileHandle.closeFile() } - - var markerData = FILEMARKER.data(using: .utf8)! - addPadForAlignment(&markerData) - - var writer: any DataWriter = FileDataWriter(fileHandle) - writer.append(FILEMARKER.data(using: .utf8)!) - switch writeFile(&writer, info: info) { - case .success: - writer.append(FILEMARKER.data(using: .utf8)!) - case .failure(let error): - return .failure(error) - } - - return .success(true) - } - - public func toMessage(_ batch: RecordBatch) -> Result<[Data], ArrowError> { - var writer: any DataWriter = InMemDataWriter() - switch writeRecordBatch(batch: batch) { - case .success(let message): - writer.append(message.0) - addPadForAlignment(&writer) - var dataWriter: any DataWriter = InMemDataWriter() - switch writeRecordBatchData(&dataWriter, fields: batch.schema.fields, columns: batch.columns) { - case .success: - return .success([ - (writer as! InMemDataWriter).data, // swiftlint:disable:this force_cast - (dataWriter as! InMemDataWriter).data // swiftlint:disable:this force_cast - ]) - case .failure(let error): - return .failure(error) - } - case .failure(let error): - return .failure(error) - } - } - - public func toMessage(_ schema: ArrowSchema) -> Result { - var schemaSize: Int32 = 0 - var fbb = FlatBufferBuilder() - switch writeSchema(&fbb, schema: schema) { - case .success(let schemaOffset): - schemaSize = Int32(schemaOffset.o) - case .failure(let error): - return .failure(error) - } - - let startMessage = org_apache_arrow_flatbuf_Message.startMessage(&fbb) - org_apache_arrow_flatbuf_Message.add(bodyLength: Int64(0), &fbb) - org_apache_arrow_flatbuf_Message.add(headerType: .schema, &fbb) - org_apache_arrow_flatbuf_Message.add(header: Offset(offset: UOffset(schemaSize)), &fbb) - org_apache_arrow_flatbuf_Message.add(version: .max, &fbb) - let messageOffset = org_apache_arrow_flatbuf_Message.endMessage(&fbb, start: startMessage) - fbb.finish(offset: messageOffset) - return .success(fbb.data) - } -} -// swiftlint:disable:this file_length diff --git a/swift/Arrow/Sources/Arrow/ArrowWriterHelper.swift b/swift/Arrow/Sources/Arrow/ArrowWriterHelper.swift deleted file mode 100644 index 4d63192585f..00000000000 --- a/swift/Arrow/Sources/Arrow/ArrowWriterHelper.swift +++ /dev/null @@ -1,135 +0,0 @@ -// 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 Foundation -import FlatBuffers - -extension Data { - func hexEncodedString() -> String { - return map { String(format: "%02hhx", $0) }.joined() - } -} - -func toFBTypeEnum(_ arrowType: ArrowType) -> Result { - let typeId = arrowType.id - switch typeId { - case .int8, .int16, .int32, .int64, .uint8, .uint16, .uint32, .uint64: - return .success(org_apache_arrow_flatbuf_Type_.int) - case .float, .double: - return .success(org_apache_arrow_flatbuf_Type_.floatingpoint) - case .string: - return .success(org_apache_arrow_flatbuf_Type_.utf8) - case .binary: - return .success(org_apache_arrow_flatbuf_Type_.binary) - case .boolean: - return .success(org_apache_arrow_flatbuf_Type_.bool) - case .date32, .date64: - return .success(org_apache_arrow_flatbuf_Type_.date) - case .time32, .time64: - return .success(org_apache_arrow_flatbuf_Type_.time) - case .strct: - return .success(org_apache_arrow_flatbuf_Type_.struct_) - default: - return .failure(.unknownType("Unable to find flatbuf type for Arrow type: \(typeId)")) - } -} - -func toFBType( // swiftlint:disable:this cyclomatic_complexity function_body_length - _ fbb: inout FlatBufferBuilder, - arrowType: ArrowType -) -> Result { - let infoType = arrowType.info - switch arrowType.id { - case .int8, .uint8: - return .success(org_apache_arrow_flatbuf_Int.createInt( - &fbb, bitWidth: 8, isSigned: infoType == ArrowType.ArrowInt8)) - case .int16, .uint16: - return .success(org_apache_arrow_flatbuf_Int.createInt( - &fbb, bitWidth: 16, isSigned: infoType == ArrowType.ArrowInt16)) - case .int32, .uint32: - return .success(org_apache_arrow_flatbuf_Int.createInt( - &fbb, bitWidth: 32, isSigned: infoType == ArrowType.ArrowInt32)) - case .int64, .uint64: - return .success(org_apache_arrow_flatbuf_Int.createInt( - &fbb, bitWidth: 64, isSigned: infoType == ArrowType.ArrowInt64)) - case .float: - return .success(org_apache_arrow_flatbuf_FloatingPoint.createFloatingPoint(&fbb, precision: .single)) - case .double: - return .success(org_apache_arrow_flatbuf_FloatingPoint.createFloatingPoint(&fbb, precision: .double)) - case .string: - return .success(org_apache_arrow_flatbuf_Utf8.endUtf8( - &fbb, start: org_apache_arrow_flatbuf_Utf8.startUtf8(&fbb))) - case .binary: - return .success(org_apache_arrow_flatbuf_Binary.endBinary( - &fbb, start: org_apache_arrow_flatbuf_Binary.startBinary(&fbb))) - case .boolean: - return .success(org_apache_arrow_flatbuf_Bool.endBool( - &fbb, start: org_apache_arrow_flatbuf_Bool.startBool(&fbb))) - case .date32: - let startOffset = org_apache_arrow_flatbuf_Date.startDate(&fbb) - org_apache_arrow_flatbuf_Date.add(unit: .day, &fbb) - return .success(org_apache_arrow_flatbuf_Date.endDate(&fbb, start: startOffset)) - case .date64: - let startOffset = org_apache_arrow_flatbuf_Date.startDate(&fbb) - org_apache_arrow_flatbuf_Date.add(unit: .millisecond, &fbb) - return .success(org_apache_arrow_flatbuf_Date.endDate(&fbb, start: startOffset)) - case .time32: - let startOffset = org_apache_arrow_flatbuf_Time.startTime(&fbb) - if let timeType = arrowType as? ArrowTypeTime32 { - org_apache_arrow_flatbuf_Time.add(unit: timeType.unit == .seconds ? .second : .millisecond, &fbb) - return .success(org_apache_arrow_flatbuf_Time.endTime(&fbb, start: startOffset)) - } - - return .failure(.invalid("Unable to case to Time32")) - case .time64: - let startOffset = org_apache_arrow_flatbuf_Time.startTime(&fbb) - if let timeType = arrowType as? ArrowTypeTime64 { - org_apache_arrow_flatbuf_Time.add(unit: timeType.unit == .microseconds ? .microsecond : .nanosecond, &fbb) - return .success(org_apache_arrow_flatbuf_Time.endTime(&fbb, start: startOffset)) - } - - return .failure(.invalid("Unable to case to Time64")) - case .strct: - let startOffset = org_apache_arrow_flatbuf_Struct_.startStruct_(&fbb) - return .success(org_apache_arrow_flatbuf_Struct_.endStruct_(&fbb, start: startOffset)) - default: - return .failure(.unknownType("Unable to add flatbuf type for Arrow type: \(infoType)")) - } -} - -func addPadForAlignment(_ data: inout Data, alignment: Int = 8) { - let padding = data.count % Int(alignment) - if padding > 0 { - data.append(Data([UInt8](repeating: 0, count: alignment - padding))) - } -} - -func addPadForAlignment(_ writer: inout DataWriter, alignment: Int = 8) { - let padding = writer.count % Int(alignment) - if padding > 0 { - writer.append(Data([UInt8](repeating: 0, count: alignment - padding))) - } -} - -func getPadForAlignment(_ count: Int, alignment: Int = 8) -> Int { - let padding = count % Int(alignment) - if padding > 0 { - return count + (alignment - padding) - } - - return count -} diff --git a/swift/Arrow/Sources/Arrow/BitUtility.swift b/swift/Arrow/Sources/Arrow/BitUtility.swift deleted file mode 100644 index 84edf9889b6..00000000000 --- a/swift/Arrow/Sources/Arrow/BitUtility.swift +++ /dev/null @@ -1,40 +0,0 @@ -// 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 Foundation - -class BitUtility { - static func isSet(_ bit: UInt, buffer: ArrowBuffer) -> Bool { - let byteIndex = UInt(bit / 8) - let theByte = buffer.rawPointer.load(fromByteOffset: Int(byteIndex), as: UInt8.self) - 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 |= 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 &= ~(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 deleted file mode 100644 index fb5734f64b6..00000000000 --- a/swift/Arrow/Sources/Arrow/ChunkedArray.swift +++ /dev/null @@ -1,149 +0,0 @@ -// 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 Foundation - -public protocol AnyArray { - var arrowData: ArrowData {get} - func asAny(_ index: UInt) -> Any? - var length: UInt {get} -} - -public protocol AsString { - func asString(_ index: UInt) -> String -} - -public class ChunkedArrayHolder { - public let type: ArrowType - public let length: UInt - public let nullCount: UInt - public let holder: Any - - public let getBufferData: () -> Result<[Data], ArrowError> - public let getBufferDataSizes: () -> Result<[Int], ArrowError> - public init(_ chunked: ChunkedArray) { // swiftlint:disable:this cyclomatic_complexity - self.holder = chunked - self.length = chunked.length - self.type = chunked.type - self.nullCount = chunked.nullCount - self.getBufferData = {() -> Result<[Data], ArrowError> in - var bufferData = [Data]() - var numBuffers = 2 - switch toFBTypeEnum(chunked.type) { - case .success(let fbType): - if !isFixedPrimitive(fbType) { - numBuffers = 3 - } - case .failure(let error): - return .failure(error) - } - - for _ in 0 ..< numBuffers { - bufferData.append(Data()) - } - - for arrowData in chunked.arrays { - for index in 0 ..< numBuffers { - arrowData.arrowData.buffers[index].append(to: &bufferData[index]) - } - } - - return .success(bufferData) - } - - self.getBufferDataSizes = {() -> Result<[Int], ArrowError> in - var bufferDataSizes = [Int]() - var numBuffers = 2 - - switch toFBTypeEnum(chunked.type) { - case .success(let fbType): - if !isFixedPrimitive(fbType) { - numBuffers = 3 - } - case .failure(let error): - return .failure(error) - } - - for _ in 0 ..< numBuffers { - bufferDataSizes.append(Int(0)) - } - - for arrowData in chunked.arrays { - for index in 0 ..< numBuffers { - bufferDataSizes[index] += Int(arrowData.arrowData.buffers[index].capacity) - } - } - - return .success(bufferDataSizes) - } - } -} - -public class ChunkedArray: AsString { - public let arrays: [ArrowArray] - public let type: ArrowType - public let nullCount: UInt - public let length: UInt - public var arrayCount: UInt {return UInt(self.arrays.count)} - - public init(_ arrays: [ArrowArray]) throws { - if arrays.count == 0 { - throw ArrowError.arrayHasNoElements - } - - self.type = arrays[0].arrowData.type - var len: UInt = 0 - var nullCount: UInt = 0 - for array in arrays { - len += array.length - nullCount += array.nullCount - } - - self.arrays = arrays - self.length = len - self.nullCount = nullCount - } - - 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 - 1) { - 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 deleted file mode 100644 index 53888e48d60..00000000000 --- a/swift/Arrow/Sources/Arrow/File_generated.swift +++ /dev/null @@ -1,160 +0,0 @@ -// 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(_ 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.position)) } - 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.size, elementSize: MemoryLayout.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.size, elementSize: MemoryLayout.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(_ 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.self) - try _v.visit(field: VTOFFSET.dictionaries.p, fieldName: "dictionaries", required: false, type: ForwardOffset>.self) - try _v.visit(field: VTOFFSET.recordBatches.p, fieldName: "recordBatches", required: false, type: ForwardOffset>.self) - try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset, org_apache_arrow_flatbuf_KeyValue>>.self) - _v.finish() - } -} - diff --git a/swift/Arrow/Sources/Arrow/MemoryAllocator.swift b/swift/Arrow/Sources/Arrow/MemoryAllocator.swift deleted file mode 100644 index 0f6e54ec042..00000000000 --- a/swift/Arrow/Sources/Arrow/MemoryAllocator.swift +++ /dev/null @@ -1,31 +0,0 @@ -// 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 Foundation - -public class MemoryAllocator { - let alignment: Int - init(_ alignment: Int) { - self.alignment = alignment - } - - func allocateArray(_ byteCount: Int) -> UnsafeMutableRawPointer { - return UnsafeMutableRawPointer.allocate( - byteCount: byteCount, - alignment: self.alignment) - } -} diff --git a/swift/Arrow/Sources/Arrow/Message_generated.swift b/swift/Arrow/Sources/Arrow/Message_generated.swift deleted file mode 100644 index 6820aa11c42..00000000000 --- a/swift/Arrow/Sources/Arrow/Message_generated.swift +++ /dev/null @@ -1,421 +0,0 @@ -// 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.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.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.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 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(_ 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 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(_ 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.position)) } - 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.size, elementSize: MemoryLayout.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.size, elementSize: MemoryLayout.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(_ 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>.self) - try _v.visit(field: VTOFFSET.buffers.p, fieldName: "buffers", required: false, type: ForwardOffset>.self) - try _v.visit(field: VTOFFSET.compression.p, fieldName: "compression", required: false, type: ForwardOffset.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.position)) } - /// 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(_ 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.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(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(_ 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.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Schema.self) - case .dictionarybatch: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_DictionaryBatch.self) - case .recordbatch: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RecordBatch.self) - case .tensor: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Tensor.self) - case .sparsetensor: - try ForwardOffset.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, org_apache_arrow_flatbuf_KeyValue>>.self) - _v.finish() - } -} - diff --git a/swift/Arrow/Sources/Arrow/ProtoUtil.swift b/swift/Arrow/Sources/Arrow/ProtoUtil.swift deleted file mode 100644 index 88cfb0bfcde..00000000000 --- a/swift/Arrow/Sources/Arrow/ProtoUtil.swift +++ /dev/null @@ -1,80 +0,0 @@ -// 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 Foundation - -func fromProto( // swiftlint:disable:this cyclomatic_complexity function_body_length - field: org_apache_arrow_flatbuf_Field -) -> ArrowField { - let type = field.typeType - var arrowType = ArrowType(ArrowType.ArrowUnknown) - switch type { - case .int: - let intType = field.type(type: org_apache_arrow_flatbuf_Int.self)! - let bitWidth = intType.bitWidth - if bitWidth == 8 { - arrowType = ArrowType(intType.isSigned ? ArrowType.ArrowInt8 : ArrowType.ArrowUInt8) - } else if bitWidth == 16 { - arrowType = ArrowType(intType.isSigned ? ArrowType.ArrowInt16 : ArrowType.ArrowUInt16) - } else if bitWidth == 32 { - arrowType = ArrowType(intType.isSigned ? ArrowType.ArrowInt32 : ArrowType.ArrowUInt32) - } else if bitWidth == 64 { - arrowType = ArrowType(intType.isSigned ? ArrowType.ArrowInt64 : ArrowType.ArrowUInt64) - } - case .bool: - arrowType = ArrowType(ArrowType.ArrowBool) - case .floatingpoint: - let floatType = field.type(type: org_apache_arrow_flatbuf_FloatingPoint.self)! - if floatType.precision == .single { - arrowType = ArrowType(ArrowType.ArrowFloat) - } else if floatType.precision == .double { - arrowType = ArrowType(ArrowType.ArrowDouble) - } - case .utf8: - arrowType = ArrowType(ArrowType.ArrowString) - case .binary: - arrowType = ArrowType(ArrowType.ArrowBinary) - case .date: - let dateType = field.type(type: org_apache_arrow_flatbuf_Date.self)! - if dateType.unit == .day { - arrowType = ArrowType(ArrowType.ArrowDate32) - } else { - arrowType = ArrowType(ArrowType.ArrowDate64) - } - case .time: - let timeType = field.type(type: org_apache_arrow_flatbuf_Time.self)! - if timeType.unit == .second || timeType.unit == .millisecond { - let arrowUnit: ArrowTime32Unit = timeType.unit == .second ? .seconds : .milliseconds - arrowType = ArrowTypeTime32(arrowUnit) - } else { - let arrowUnit: ArrowTime64Unit = timeType.unit == .microsecond ? .microseconds : .nanoseconds - arrowType = ArrowTypeTime64(arrowUnit) - } - case .struct_: - var children = [ArrowField]() - for index in 0...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.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.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.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.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.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.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.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.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.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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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> -/// -/// 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(_ 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(_ 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>.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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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 nonexistent. 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(_ 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.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(_ 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(_ 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(_ 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.self) - try _v.visit(field: VTOFFSET.value.p, fieldName: "value", required: false, type: ForwardOffset.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.position)) } - /// 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(_ 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.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(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.position)) } - /// 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(_ 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.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.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self) - case .int: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self) - case .floatingpoint: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self) - case .binary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self) - case .utf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self) - case .bool: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self) - case .decimal: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self) - case .date: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self) - case .time: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self) - case .timestamp: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self) - case .interval: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self) - case .list: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self) - case .struct_: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self) - case .union: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self) - case .fixedsizebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self) - case .fixedsizelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self) - case .map: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self) - case .duration: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self) - case .largebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self) - case .largeutf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self) - case .largelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self) - case .runendencoded: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self) - } - }) - try _v.visit(field: VTOFFSET.dictionary.p, fieldName: "dictionary", required: false, type: ForwardOffset.self) - try _v.visit(field: VTOFFSET.children.p, fieldName: "children", required: false, type: ForwardOffset, org_apache_arrow_flatbuf_Field>>.self) - try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset, 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(_ 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, org_apache_arrow_flatbuf_Field>>.self) - try _v.visit(field: VTOFFSET.customMetadata.p, fieldName: "customMetadata", required: false, type: ForwardOffset, org_apache_arrow_flatbuf_KeyValue>>.self) - try _v.visit(field: VTOFFSET.features.p, fieldName: "features", required: false, type: ForwardOffset>.self) - _v.finish() - } -} - diff --git a/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift b/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift deleted file mode 100644 index a2dfbdb4825..00000000000 --- a/swift/Arrow/Sources/Arrow/SparseTensor_generated.swift +++ /dev/null @@ -1,535 +0,0 @@ -// 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.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.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.position)) } - /// 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.position) } - /// 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(_ 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.self) - try _v.visit(field: VTOFFSET.indicesStrides.p, fieldName: "indicesStrides", required: false, type: ForwardOffset>.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.position)) } - /// 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.position) } - /// 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.position)) } - /// 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.position) } - 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(_ 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.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.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.position)) } - /// 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.position)) } - /// 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.size, elementSize: MemoryLayout.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.size, elementSize: MemoryLayout.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(_ 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.self) - try _v.visit(field: VTOFFSET.indptrBuffers.p, fieldName: "indptrBuffers", required: true, type: ForwardOffset>.self) - try _v.visit(field: VTOFFSET.indicesType.p, fieldName: "indicesType", required: true, type: ForwardOffset.self) - try _v.visit(field: VTOFFSET.indicesBuffers.p, fieldName: "indicesBuffers", required: true, type: ForwardOffset>.self) - try _v.visit(field: VTOFFSET.axisOrder.p, fieldName: "axisOrder", required: true, type: ForwardOffset>.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(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(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.position) } - 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(_ 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.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self) - case .int: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self) - case .floatingpoint: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self) - case .binary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self) - case .utf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self) - case .bool: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self) - case .decimal: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self) - case .date: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self) - case .time: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self) - case .timestamp: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self) - case .interval: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self) - case .list: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self) - case .struct_: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self) - case .union: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self) - case .fixedsizebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self) - case .fixedsizelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self) - case .map: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self) - case .duration: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self) - case .largebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self) - case .largeutf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self) - case .largelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self) - case .runendencoded: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self) - } - }) - try _v.visit(field: VTOFFSET.shape.p, fieldName: "shape", required: true, type: ForwardOffset, 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.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseTensorIndexCOO.self) - case .sparsematrixindexcsx: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_SparseMatrixIndexCSX.self) - case .sparsetensorindexcsf: - try ForwardOffset.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 deleted file mode 100644 index e9778d0b524..00000000000 --- a/swift/Arrow/Sources/Arrow/Tensor_generated.swift +++ /dev/null @@ -1,193 +0,0 @@ -// 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(_ 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.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(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.position) } - 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(_ 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.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Null.self) - case .int: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Int.self) - case .floatingpoint: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FloatingPoint.self) - case .binary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Binary.self) - case .utf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Utf8.self) - case .bool: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Bool.self) - case .decimal: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Decimal.self) - case .date: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Date.self) - case .time: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Time.self) - case .timestamp: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Timestamp.self) - case .interval: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Interval.self) - case .list: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_List.self) - case .struct_: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Struct_.self) - case .union: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Union.self) - case .fixedsizebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeBinary.self) - case .fixedsizelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_FixedSizeList.self) - case .map: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Map.self) - case .duration: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_Duration.self) - case .largebinary: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeBinary.self) - case .largeutf8: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeUtf8.self) - case .largelist: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_LargeList.self) - case .runendencoded: - try ForwardOffset.verify(&verifier, at: pos, of: org_apache_arrow_flatbuf_RunEndEncoded.self) - } - }) - try _v.visit(field: VTOFFSET.shape.p, fieldName: "shape", required: true, type: ForwardOffset, org_apache_arrow_flatbuf_TensorDim>>.self) - try _v.visit(field: VTOFFSET.strides.p, fieldName: "strides", required: false, type: ForwardOffset>.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/ArrowC/ArrowCData.c b/swift/Arrow/Sources/ArrowC/ArrowCData.c deleted file mode 100644 index fe0f8089971..00000000000 --- a/swift/Arrow/Sources/ArrowC/ArrowCData.c +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -#include -#include "include/ArrowCData.h" - -void ArrowSwiftClearReleaseSchema(struct ArrowSchema* arrowSchema) { - if(arrowSchema) { - arrowSchema->release = NULL; - } -} - -void ArrowSwiftClearReleaseArray(struct ArrowArray* arrowArray) { - if(arrowArray) { - arrowArray->release = NULL; - } -} diff --git a/swift/Arrow/Sources/ArrowC/include/ArrowCData.h b/swift/Arrow/Sources/ArrowC/include/ArrowCData.h deleted file mode 100644 index 4b2f35efcb9..00000000000 --- a/swift/Arrow/Sources/ArrowC/include/ArrowCData.h +++ /dev/null @@ -1,78 +0,0 @@ -// 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. - -#ifndef ARROW_C_DATA_INTERFACE -#define ARROW_C_DATA_INTERFACE - -#define ARROW_FLAG_DICTIONARY_ORDERED 1 -#define ARROW_FLAG_NULLABLE 2 -#define ARROW_FLAG_MAP_KEYS_SORTED 4 - -#include // For int64_t - -#ifdef __cplusplus -extern "C" { -#endif - -struct ArrowSchema { - // Array type description - const char* format; - const char* name; - const char* metadata; - int64_t flags; - int64_t n_children; - struct ArrowSchema** children; - struct ArrowSchema* dictionary; - - // Release callback - void (*release)(struct ArrowSchema*); - // Opaque producer-specific data - void* private_data; -}; - -struct ArrowArray { - // Array data description - int64_t length; - int64_t null_count; - int64_t offset; - int64_t n_buffers; - int64_t n_children; - const void** buffers; - struct ArrowArray** children; - struct ArrowArray* dictionary; - - // Release callback - void (*release)(struct ArrowArray*); - // Opaque producer-specific data - void* private_data; -}; - -// Not able to set the release on the schema -// to NULL in Swift. nil in Swift is not -// equivalent to NULL. -void ArrowSwiftClearReleaseSchema(struct ArrowSchema*); - -// Not able to set the release on the array -// to NULL in Swift. nil in Swift is not -// equivalent to NULL. -void ArrowSwiftClearReleaseArray(struct ArrowArray*); - -#ifdef __cplusplus -} -#endif - -#endif // ARROW_C_DATA_INTERFACE diff --git a/swift/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift b/swift/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift deleted file mode 100644 index 42e167f01fc..00000000000 --- a/swift/Arrow/Tests/ArrowTests/ArrayBuilderTest.swift +++ /dev/null @@ -1,85 +0,0 @@ -// 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 -@testable import Arrow - -final class ArrayBuilderTests: XCTestCase { - func testIsValidTypeForBuilder() throws { - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Bool.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int8?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int16?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int32?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Int64?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt8?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt16?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt32?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(UInt64?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Float?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Double?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Date?.self)) - XCTAssertTrue(ArrowArrayBuilders.isValidBuilderType(Bool?.self)) - - XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int.self)) - XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt.self)) - XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(Int?.self)) - XCTAssertFalse(ArrowArrayBuilders.isValidBuilderType(UInt?.self)) - } - - func testLoadArrayBuilders() throws { - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int8.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int16.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int32.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int64.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt8.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt16.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt32.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt64.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Float.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Double.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Date.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Bool.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int8?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int16?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int32?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Int64?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt8?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt16?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt32?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(UInt64?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Float?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Double?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Date?.self)) - XCTAssertNotNil(try ArrowArrayBuilders.loadBuilder(Bool?.self)) - - XCTAssertThrowsError(try ArrowArrayBuilders.loadBuilder(Int.self)) - XCTAssertThrowsError(try ArrowArrayBuilders.loadBuilder(UInt.self)) - XCTAssertThrowsError(try ArrowArrayBuilders.loadBuilder(Int?.self)) - XCTAssertThrowsError(try ArrowArrayBuilders.loadBuilder(UInt?.self)) - } -} diff --git a/swift/Arrow/Tests/ArrowTests/ArrayTests.swift b/swift/Arrow/Tests/ArrowTests/ArrayTests.swift deleted file mode 100644 index d793aa11dcb..00000000000 --- a/swift/Arrow/Tests/ArrowTests/ArrayTests.swift +++ /dev/null @@ -1,371 +0,0 @@ -// 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 -@testable import Arrow - -final class ArrayTests: XCTestCase { // swiftlint:disable:this type_body_length - func testPrimitiveArray() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - let arrayBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - for index in 0..<100 { - arrayBuilder.append(UInt8(index)) - } - - XCTAssertEqual(arrayBuilder.nullCount, 0) - arrayBuilder.append(nil) - XCTAssertEqual(arrayBuilder.length, 101) - XCTAssertEqual(arrayBuilder.capacity, 136) - XCTAssertEqual(arrayBuilder.nullCount, 1) - let array = try arrayBuilder.finish() - XCTAssertEqual(array.length, 101) - XCTAssertEqual(array[1]!, 1) - XCTAssertEqual(array[10]!, 10) - XCTAssertEqual(try array.isNull(100), true) - - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - doubleBuilder.append(14) - doubleBuilder.append(40.4) - XCTAssertEqual(doubleBuilder.nullCount, 0) - XCTAssertEqual(doubleBuilder.length, 2) - XCTAssertEqual(doubleBuilder.capacity, 264) - let doubleArray = try doubleBuilder.finish() - XCTAssertEqual(doubleArray.length, 2) - XCTAssertEqual(doubleArray[0]!, 14) - XCTAssertEqual(doubleArray[1]!, 40.4) - } - - func testStringArray() throws { - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - for index in 0..<100 { - if index % 10 == 9 { - stringBuilder.append(nil) - } else { - stringBuilder.append("test" + String(index)) - } - } - - XCTAssertEqual(stringBuilder.nullCount, 10) - XCTAssertEqual(stringBuilder.length, 100) - XCTAssertEqual(stringBuilder.capacity, 648) - let stringArray = try stringBuilder.finish() - XCTAssertEqual(stringArray.length, 100) - for index in 0..) - for index in 0..<100 { - uint8HBuilder.appendAny(UInt8(index)) - } - - let uint8Holder = try uint8HBuilder.toHolder() - XCTAssertEqual(uint8Holder.nullCount, 0) - XCTAssertEqual(uint8Holder.length, 100) - - let stringHBuilder: ArrowArrayHolderBuilder = - (try ArrowArrayBuilders.loadStringArrayBuilder()) - for index in 0..<100 { - if index % 10 == 9 { - stringHBuilder.appendAny(nil) - } else { - stringHBuilder.appendAny("test" + String(index)) - } - } - - let stringHolder = try stringHBuilder.toHolder() - XCTAssertEqual(stringHolder.nullCount, 10) - XCTAssertEqual(stringHolder.length, 100) - } - - func testAddVArgs() throws { - let arrayBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - arrayBuilder.append(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) - XCTAssertEqual(arrayBuilder.length, 10) - XCTAssertEqual(try arrayBuilder.finish()[2], 2) - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - doubleBuilder.append(0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8) - XCTAssertEqual(doubleBuilder.length, 9) - XCTAssertEqual(try doubleBuilder.finish()[4], 4.4) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("0", "1", "2", "3", "4", "5", "6") - XCTAssertEqual(stringBuilder.length, 7) - XCTAssertEqual(try stringBuilder.finish()[4], "4") - let boolBuilder = try ArrowArrayBuilders.loadBoolArrayBuilder() - boolBuilder.append(true, false, true, false) - XCTAssertEqual(try boolBuilder.finish()[2], true) - } - - func testAddArray() throws { - let arrayBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - arrayBuilder.append([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - XCTAssertEqual(arrayBuilder.length, 10) - XCTAssertEqual(try arrayBuilder.finish()[2], 2) - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - doubleBuilder.append([0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8]) - XCTAssertEqual(doubleBuilder.length, 9) - XCTAssertEqual(try doubleBuilder.finish()[4], 4.4) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append(["0", "1", "2", "3", "4", "5", "6"]) - XCTAssertEqual(stringBuilder.length, 7) - XCTAssertEqual(try stringBuilder.finish()[4], "4") - let boolBuilder = try ArrowArrayBuilders.loadBoolArrayBuilder() - boolBuilder.append([true, false, true, false]) - XCTAssertEqual(try boolBuilder.finish()[2], true) - } -} diff --git a/swift/Arrow/Tests/ArrowTests/CDataTests.swift b/swift/Arrow/Tests/ArrowTests/CDataTests.swift deleted file mode 100644 index 2344b234745..00000000000 --- a/swift/Arrow/Tests/ArrowTests/CDataTests.swift +++ /dev/null @@ -1,125 +0,0 @@ -// 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 Foundation -import XCTest -@testable import Arrow -import ArrowC - -final class CDataTests: XCTestCase { - func makeSchema() -> Arrow.ArrowSchema { - let schemaBuilder = ArrowSchema.Builder() - return schemaBuilder - .addField("colBool", type: ArrowType(ArrowType.ArrowBool), isNullable: false) - .addField("colUInt8", type: ArrowType(ArrowType.ArrowUInt8), isNullable: true) - .addField("colUInt16", type: ArrowType(ArrowType.ArrowUInt16), isNullable: true) - .addField("colUInt32", type: ArrowType(ArrowType.ArrowUInt32), isNullable: true) - .addField("colUInt64", type: ArrowType(ArrowType.ArrowUInt64), isNullable: true) - .addField("colInt8", type: ArrowType(ArrowType.ArrowInt8), isNullable: false) - .addField("colInt16", type: ArrowType(ArrowType.ArrowInt16), isNullable: false) - .addField("colInt32", type: ArrowType(ArrowType.ArrowInt32), isNullable: false) - .addField("colInt64", type: ArrowType(ArrowType.ArrowInt64), isNullable: false) - .addField("colString", type: ArrowType(ArrowType.ArrowString), isNullable: false) - .addField("colBinary", type: ArrowType(ArrowType.ArrowBinary), isNullable: false) - .addField("colDate32", type: ArrowType(ArrowType.ArrowDate32), isNullable: false) - .addField("colDate64", type: ArrowType(ArrowType.ArrowDate64), isNullable: false) - .addField("colTime32", type: ArrowType(ArrowType.ArrowTime32), isNullable: false) - .addField("colTime32s", type: ArrowTypeTime32(.seconds), isNullable: false) - .addField("colTime32m", type: ArrowTypeTime32(.milliseconds), isNullable: false) - .addField("colTime64", type: ArrowType(ArrowType.ArrowTime64), isNullable: false) - .addField("colTime64u", type: ArrowTypeTime64(.microseconds), isNullable: false) - .addField("colTime64n", type: ArrowTypeTime64(.nanoseconds), isNullable: false) - .addField("colTime64", type: ArrowType(ArrowType.ArrowTime64), isNullable: false) - .addField("colFloat", type: ArrowType(ArrowType.ArrowFloat), isNullable: false) - .addField("colDouble", type: ArrowType(ArrowType.ArrowDouble), isNullable: false) - .finish() - } - - func checkImportField(_ cSchema: ArrowC.ArrowSchema, name: String, type: ArrowType.Info) throws { - let importer = ArrowCImporter() - switch importer.importField(cSchema) { - case .success(let arrowField): - XCTAssertEqual(arrowField.type.info, type) - XCTAssertEqual(arrowField.name, name) - case .failure(let error): - throw error - } - } - - func testImportExportSchema() throws { - let schema = makeSchema() - let exporter = ArrowCExporter() - for arrowField in schema.fields { - var cSchema = ArrowC.ArrowSchema() - switch exporter.exportField(&cSchema, field: arrowField) { - case .success: - try checkImportField(cSchema, name: arrowField.name, type: arrowField.type.info) - case .failure(let error): - throw error - } - } - } - - func testImportExportArray() throws { - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - for index in 0..<100 { - if index % 10 == 9 { - stringBuilder.append(nil) - } else { - stringBuilder.append("test" + String(index)) - } - } - - XCTAssertEqual(stringBuilder.nullCount, 10) - XCTAssertEqual(stringBuilder.length, 100) - XCTAssertEqual(stringBuilder.capacity, 648) - let stringArray = try stringBuilder.finish() - let exporter = ArrowCExporter() - var cArray = ArrowC.ArrowArray() - exporter.exportArray(&cArray, arrowData: stringArray.arrowData) - let cArrayMutPtr = UnsafeMutablePointer.allocate(capacity: 1) - cArrayMutPtr.pointee = cArray - defer { - cArrayMutPtr.deallocate() - } - - let importer = ArrowCImporter() - switch importer.importArray(UnsafePointer(cArrayMutPtr), arrowType: ArrowType(ArrowType.ArrowString)) { - case .success(let holder): - let builder = RecordBatch.Builder() - switch builder - .addColumn("test", arrowArray: holder) - .finish() { - case .success(let rb): - XCTAssertEqual(rb.columnCount, 1) - XCTAssertEqual(rb.length, 100) - let col1: Arrow.ArrowArray = rb.data(for: 0) - for index in 0.. = try ArrowArrayBuilders.loadNumberArrayBuilder() - let int16Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let int32Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let int64Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let uint8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let uint16Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let uint32Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let uint64Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let floatBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - let dateBuilder = try ArrowArrayBuilders.loadDate64ArrayBuilder() - - boolBuilder.append(false, true, false) - int8Builder.append(10, 11, 12) - int16Builder.append(20, 21, 22) - int32Builder.append(30, 31, 32) - int64Builder.append(40, 41, 42) - uint8Builder.append(50, 51, 52) - uint16Builder.append(60, 61, 62) - uint32Builder.append(70, 71, 72) - uint64Builder.append(80, 81, 82) - floatBuilder.append(90.1, 91.1, 92.1) - doubleBuilder.append(101.1, nil, nil) - stringBuilder.append("test0", "test1", "test2") - dateBuilder.append(date1, date1, date1) - let result = RecordBatch.Builder() - .addColumn("propBool", arrowArray: try boolBuilder.toHolder()) - .addColumn("propInt8", arrowArray: try int8Builder.toHolder()) - .addColumn("propInt16", arrowArray: try int16Builder.toHolder()) - .addColumn("propInt32", arrowArray: try int32Builder.toHolder()) - .addColumn("propInt64", arrowArray: try int64Builder.toHolder()) - .addColumn("propUInt8", arrowArray: try uint8Builder.toHolder()) - .addColumn("propUInt16", arrowArray: try uint16Builder.toHolder()) - .addColumn("propUInt32", arrowArray: try uint32Builder.toHolder()) - .addColumn("propUInt64", arrowArray: try uint64Builder.toHolder()) - .addColumn("propFloat", arrowArray: try floatBuilder.toHolder()) - .addColumn("propDouble", arrowArray: try doubleBuilder.toHolder()) - .addColumn("propString", arrowArray: try stringBuilder.toHolder()) - .addColumn("propDate", arrowArray: try dateBuilder.toHolder()) - .finish() - switch result { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testClasses = try decoder.decode(TestClass.self) - for index in 0.. = try ArrowArrayBuilders.loadNumberArrayBuilder() - int8Builder.append(10, 11, 12) - let result = RecordBatch.Builder() - .addColumn("propInt8", arrowArray: try int8Builder.toHolder()) - .finish() - switch result { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testData = try decoder.decode(Int8?.self) - for index in 0.. = try ArrowArrayBuilders.loadNumberArrayBuilder() - int8WNilBuilder.append(10, nil, 12, nil) - let resultWNil = RecordBatch.Builder() - .addColumn("propInt8", arrowArray: try int8WNilBuilder.toHolder()) - .finish() - switch resultWNil { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testData = try decoder.decode(Int8?.self) - for index in 0.. = try ArrowArrayBuilders.loadNumberArrayBuilder() - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - int8Builder.append(10, 11, 12, 13) - stringBuilder.append("test10", "test11", "test12", "test13") - switch RecordBatch.Builder() - .addColumn("propInt8", arrowArray: try int8Builder.toHolder()) - .addColumn("propString", arrowArray: try stringBuilder.toHolder()) - .finish() { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testData = try decoder.decode([Int8: String].self) - for data in testData { - XCTAssertEqual("test\(data.key)", data.value) - } - case .failure(let err): - throw err - } - - switch RecordBatch.Builder() - .addColumn("propString", arrowArray: try stringBuilder.toHolder()) - .addColumn("propInt8", arrowArray: try int8Builder.toHolder()) - .finish() { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testData = try decoder.decode([String: Int8].self) - for data in testData { - XCTAssertEqual("test\(data.value)", data.key) - } - case .failure(let err): - throw err - } - } - - func testArrowMapDecoderWithNull() throws { - let int8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - let stringWNilBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - int8Builder.append(10, 11, 12, 13) - stringWNilBuilder.append(nil, "test11", nil, "test13") - let resultWNil = RecordBatch.Builder() - .addColumn("propInt8", arrowArray: try int8Builder.toHolder()) - .addColumn("propString", arrowArray: try stringWNilBuilder.toHolder()) - .finish() - switch resultWNil { - case .success(let rb): - let decoder = ArrowDecoder(rb) - let testData = try decoder.decode([Int8: String?].self) - for data in testData { - let str = data.value - if data.key % 2 == 0 { - XCTAssertNil(str) - } else { - XCTAssertEqual(str, "test\(data.key)") - } - } - case .failure(let err): - throw err - } - } - - func getArrayValue(_ rb: RecordBatch, colIndex: Int, rowIndex: UInt) -> T? { - let anyArray = rb.columns[colIndex].array - return anyArray.asAny(UInt(rowIndex)) as? T - } - - func testArrowKeyedEncoder() throws { // swiftlint:disable:this function_body_length - var infos = [TestClass]() - for index in 0..<10 { - let tClass = TestClass() - let offset = index * 12 - tClass.propBool = index % 2 == 0 - tClass.propInt8 = Int8(offset + 1) - tClass.propInt16 = Int16(offset + 2) - tClass.propInt32 = Int32(offset + 3) - tClass.propInt64 = Int64(offset + 4) - tClass.propUInt8 = UInt8(offset + 5) - tClass.propUInt16 = UInt16(offset + 6) - tClass.propUInt32 = UInt32(offset + 7) - tClass.propUInt64 = UInt64(offset + 8) - tClass.propFloat = Float(offset + 9) - tClass.propDouble = index % 2 == 0 ? Double(offset + 10) : nil - tClass.propString = "\(offset + 11)" - tClass.propDate = Date.now - infos.append(tClass) - } - - let rb = try ArrowEncoder.encode(infos)! - XCTAssertEqual(Int(rb.length), infos.count) - XCTAssertEqual(rb.columns.count, 13) - XCTAssertEqual(rb.columns[0].type.id, ArrowTypeId.boolean) - XCTAssertEqual(rb.columns[1].type.id, ArrowTypeId.int8) - XCTAssertEqual(rb.columns[2].type.id, ArrowTypeId.int16) - XCTAssertEqual(rb.columns[3].type.id, ArrowTypeId.int32) - XCTAssertEqual(rb.columns[4].type.id, ArrowTypeId.int64) - XCTAssertEqual(rb.columns[5].type.id, ArrowTypeId.uint8) - XCTAssertEqual(rb.columns[6].type.id, ArrowTypeId.uint16) - XCTAssertEqual(rb.columns[7].type.id, ArrowTypeId.uint32) - XCTAssertEqual(rb.columns[8].type.id, ArrowTypeId.uint64) - XCTAssertEqual(rb.columns[9].type.id, ArrowTypeId.float) - XCTAssertEqual(rb.columns[10].type.id, ArrowTypeId.double) - XCTAssertEqual(rb.columns[11].type.id, ArrowTypeId.string) - XCTAssertEqual(rb.columns[12].type.id, ArrowTypeId.date64) - for index in 0..<10 { - let offset = index * 12 - XCTAssertEqual(getArrayValue(rb, colIndex: 0, rowIndex: UInt(index)), index % 2 == 0) - XCTAssertEqual(getArrayValue(rb, colIndex: 1, rowIndex: UInt(index)), Int8(offset + 1)) - XCTAssertEqual(getArrayValue(rb, colIndex: 2, rowIndex: UInt(index)), Int16(offset + 2)) - XCTAssertEqual(getArrayValue(rb, colIndex: 3, rowIndex: UInt(index)), Int32(offset + 3)) - XCTAssertEqual(getArrayValue(rb, colIndex: 4, rowIndex: UInt(index)), Int64(offset + 4)) - XCTAssertEqual(getArrayValue(rb, colIndex: 5, rowIndex: UInt(index)), UInt8(offset + 5)) - XCTAssertEqual(getArrayValue(rb, colIndex: 6, rowIndex: UInt(index)), UInt16(offset + 6)) - XCTAssertEqual(getArrayValue(rb, colIndex: 7, rowIndex: UInt(index)), UInt32(offset + 7)) - XCTAssertEqual(getArrayValue(rb, colIndex: 8, rowIndex: UInt(index)), UInt64(offset + 8)) - XCTAssertEqual(getArrayValue(rb, colIndex: 9, rowIndex: UInt(index)), Float(offset + 9)) - if index % 2 == 0 { - XCTAssertEqual(getArrayValue(rb, colIndex: 10, rowIndex: UInt(index)), Double(offset + 10)) - } else { - XCTAssertEqual(getArrayValue(rb, colIndex: 10, rowIndex: UInt(index)), Double?(nil)) - } - - XCTAssertEqual(getArrayValue(rb, colIndex: 11, rowIndex: UInt(index)), String(offset + 11)) - } - } - - func testArrowUnkeyedEncoder() throws { - var testMap = [Int8: String?]() - for index in 0..<10 { - testMap[Int8(index)] = "test\(index)" - } - - let rb = try ArrowEncoder.encode(testMap) - XCTAssertEqual(Int(rb.length), testMap.count) - XCTAssertEqual(rb.columns.count, 2) - XCTAssertEqual(rb.columns[0].type.id, ArrowTypeId.int8) - XCTAssertEqual(rb.columns[1].type.id, ArrowTypeId.string) - for index in 0..<10 { - let key: Int8 = getArrayValue(rb, colIndex: 0, rowIndex: UInt(index))! - let value: String = getArrayValue(rb, colIndex: 1, rowIndex: UInt(index))! - XCTAssertEqual("test\(key)", value) - } - } - - func testArrowSingleEncoder() throws { - var intArray = [Int32?]() - for index in 0..<100 { - if index == 10 { - intArray.append(nil) - } else { - intArray.append(Int32(index)) - } - } - - let rb = try ArrowEncoder.encode(intArray)! - XCTAssertEqual(Int(rb.length), intArray.count) - XCTAssertEqual(rb.columns.count, 1) - XCTAssertEqual(rb.columns[0].type.id, ArrowTypeId.int32) - for index in 0..<100 { - if index == 10 { - let anyArray = rb.columns[0].array - XCTAssertNil(anyArray.asAny(UInt(index))) - } else { - XCTAssertEqual(getArrayValue(rb, colIndex: 0, rowIndex: UInt(index)), Int32(index)) - } - } - } -} diff --git a/swift/Arrow/Tests/ArrowTests/IPCTests.swift b/swift/Arrow/Tests/ArrowTests/IPCTests.swift deleted file mode 100644 index 26f38ce4e07..00000000000 --- a/swift/Arrow/Tests/ArrowTests/IPCTests.swift +++ /dev/null @@ -1,616 +0,0 @@ -// 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 - -let currentDate = Date.now -class StructTest { - var field0: Bool = false - var field1: Int8 = 0 - var field2: Int16 = 0 - var field: Int32 = 0 - var field4: Int64 = 0 - var field5: UInt8 = 0 - var field6: UInt16 = 0 - var field7: UInt32 = 0 - var field8: UInt64 = 0 - var field9: Double = 0 - var field10: Float = 0 - var field11: String = "" - var field12 = Data() - var field13: Date = currentDate -} - -@discardableResult -func checkBoolRecordBatch(_ result: Result) throws -> [RecordBatch] { - let recordBatches: [RecordBatch] - switch result { - case .success(let result): - recordBatches = result.batches - case .failure(let error): - throw error - } - - XCTAssertEqual(recordBatches.count, 1) - for recordBatch in recordBatches { - 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.info, ArrowType.ArrowBool) - XCTAssertEqual(recordBatch.schema.fields[1].name, "two") - XCTAssertEqual(recordBatch.schema.fields[1].type.info, ArrowType.ArrowString) - for index in 0..) throws -> [RecordBatch] { - let recordBatches: [RecordBatch] - switch result { - case .success(let result): - recordBatches = result.batches - case .failure(let error): - throw error - } - - XCTAssertEqual(recordBatches.count, 1) - for recordBatch in recordBatches { - XCTAssertEqual(recordBatch.length, 3) - XCTAssertEqual(recordBatch.columns.count, 1) - XCTAssertEqual(recordBatch.schema.fields.count, 1) - XCTAssertEqual(recordBatch.schema.fields[0].name, "my struct") - XCTAssertEqual(recordBatch.schema.fields[0].type.id, .strct) - let structArray = recordBatch.columns[0].array as? StructArray - XCTAssertEqual(structArray!.arrowFields!.count, 2) - XCTAssertEqual(structArray!.arrowFields![0].type.id, .string) - XCTAssertEqual(structArray!.arrowFields![1].type.id, .boolean) - let column = recordBatch.columns[0] - let str = column.array as? AsString - XCTAssertEqual("\(str!.asString(0))", "{0,false}") - XCTAssertEqual("\(str!.asString(1))", "{1,true}") - XCTAssertTrue(column.array.asAny(2) == nil) - } - - return recordBatches -} - -func currentDirectory(path: String = #file) -> URL { - return URL(fileURLWithPath: path).deletingLastPathComponent() -} - -func makeSchema() -> ArrowSchema { - let schemaBuilder = ArrowSchema.Builder() - return schemaBuilder.addField("col1", type: ArrowType(ArrowType.ArrowUInt8), isNullable: true) - .addField("col2", type: ArrowType(ArrowType.ArrowString), isNullable: false) - .addField("col3", type: ArrowType(ArrowType.ArrowDate32), isNullable: false) - .addField("col4", type: ArrowType(ArrowType.ArrowInt32), isNullable: false) - .addField("col5", type: ArrowType(ArrowType.ArrowFloat), isNullable: false) - .finish() -} - -func makeStructSchema() -> ArrowSchema { - let testObj = StructTest() - var fields = [ArrowField]() - let buildStructType = {() -> ArrowNestedType in - let mirror = Mirror(reflecting: testObj) - for (property, value) in mirror.children { - let arrowType = ArrowType(ArrowType.infoForType(type(of: value))) - fields.append(ArrowField(property!, type: arrowType, isNullable: true)) - } - - return ArrowNestedType(ArrowType.ArrowStruct, fields: fields) - } - - return ArrowSchema.Builder() - .addField("struct1", type: buildStructType(), isNullable: true) - .finish() -} - -func makeStructRecordBatch() throws -> RecordBatch { - let testData = StructTest() - let dateNow = Date.now - let structBuilder = try ArrowArrayBuilders.loadStructArrayBuilderForType(testData) - structBuilder.append([true, Int8(1), Int16(2), Int32(3), Int64(4), - UInt8(5), UInt16(6), UInt32(7), UInt64(8), Double(9.9), - Float(10.10), "11", Data("12".utf8), dateNow]) - structBuilder.append(nil) - structBuilder.append([true, Int8(13), Int16(14), Int32(15), Int64(16), - UInt8(17), UInt16(18), UInt32(19), UInt64(20), Double(21.21), - Float(22.22), "23", Data("24".utf8), dateNow]) - let structHolder = ArrowArrayHolderImpl(try structBuilder.finish()) - let result = RecordBatch.Builder() - .addColumn("struct1", arrowArray: structHolder) - .finish() - switch result { - case .success(let recordBatch): - return recordBatch - case .failure(let error): - throw error - } -} - -func makeRecordBatch() throws -> RecordBatch { - let uint8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder.append(10) - uint8Builder.append(nil) - uint8Builder.append(nil) - uint8Builder.append(44) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - stringBuilder.append("test33") - stringBuilder.append("test44") - let date32Builder = try ArrowArrayBuilders.loadDate32ArrayBuilder() - let date2 = Date(timeIntervalSinceReferenceDate: 86400 * 1) - let date1 = Date(timeIntervalSinceReferenceDate: 86400 * 5000 + 352) - date32Builder.append(date1) - date32Builder.append(date2) - date32Builder.append(date1) - date32Builder.append(date2) - let int32Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - int32Builder.append(1) - int32Builder.append(2) - int32Builder.append(3) - int32Builder.append(4) - let floatBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - floatBuilder.append(211.112) - floatBuilder.append(322.223) - floatBuilder.append(433.334) - floatBuilder.append(544.445) - - let uint8Holder = ArrowArrayHolderImpl(try uint8Builder.finish()) - let stringHolder = ArrowArrayHolderImpl(try stringBuilder.finish()) - let date32Holder = ArrowArrayHolderImpl(try date32Builder.finish()) - let int32Holder = ArrowArrayHolderImpl(try int32Builder.finish()) - let floatHolder = ArrowArrayHolderImpl(try floatBuilder.finish()) - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: uint8Holder) - .addColumn("col2", arrowArray: stringHolder) - .addColumn("col3", arrowArray: date32Holder) - .addColumn("col4", arrowArray: int32Holder) - .addColumn("col5", arrowArray: floatHolder) - .finish() - switch result { - case .success(let recordBatch): - return recordBatch - case .failure(let error): - throw error - } -} - -final class IPCStreamReaderTests: XCTestCase { - func testRBInMemoryToFromStream() throws { - let schema = makeSchema() - let recordBatch = try makeRecordBatch() - let arrowWriter = ArrowWriter() - let writerInfo = ArrowWriter.Info(.recordbatch, schema: schema, batches: [recordBatch]) - switch arrowWriter.writeStreaming(writerInfo) { - case .success(let writeData): - let arrowReader = ArrowReader() - switch arrowReader.readStreaming(writeData) { - case .success(let result): - let recordBatches = result.batches - XCTAssertEqual(recordBatches.count, 1) - for recordBatch in recordBatches { - XCTAssertEqual(recordBatch.length, 4) - XCTAssertEqual(recordBatch.columns.count, 5) - XCTAssertEqual(recordBatch.schema.fields.count, 5) - XCTAssertEqual(recordBatch.schema.fields[0].name, "col1") - XCTAssertEqual(recordBatch.schema.fields[0].type.info, ArrowType.ArrowUInt8) - XCTAssertEqual(recordBatch.schema.fields[1].name, "col2") - XCTAssertEqual(recordBatch.schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(recordBatch.schema.fields[2].name, "col3") - XCTAssertEqual(recordBatch.schema.fields[2].type.info, ArrowType.ArrowDate32) - XCTAssertEqual(recordBatch.schema.fields[3].name, "col4") - XCTAssertEqual(recordBatch.schema.fields[3].type.info, ArrowType.ArrowInt32) - XCTAssertEqual(recordBatch.schema.fields[4].name, "col5") - XCTAssertEqual(recordBatch.schema.fields[4].type.info, ArrowType.ArrowFloat) - let columns = recordBatch.columns - XCTAssertEqual(columns[0].nullCount, 2) - let dateVal = - "\((columns[2].array as! AsString).asString(0))" // swiftlint:disable:this force_cast - XCTAssertEqual(dateVal, "2014-09-10 00:00:00 +0000") - let stringVal = - "\((columns[1].array as! AsString).asString(1))" // swiftlint:disable:this force_cast - XCTAssertEqual(stringVal, "test22") - let uintVal = - "\((columns[0].array as! AsString).asString(0))" // swiftlint:disable:this force_cast - XCTAssertEqual(uintVal, "10") - let stringVal2 = - "\((columns[1].array as! AsString).asString(3))" // swiftlint:disable:this force_cast - XCTAssertEqual(stringVal2, "test44") - let uintVal2 = - "\((columns[0].array as! AsString).asString(3))" // swiftlint:disable:this force_cast - XCTAssertEqual(uintVal2, "44") - } - case.failure(let error): - throw error - } - case .failure(let error): - throw error - } - } -} - -final class IPCFileReaderTests: XCTestCase { // swiftlint:disable:this type_body_length - func testFileReader_double() throws { - let fileURL = currentDirectory().appendingPathComponent("../../testdata_double.arrow") - let arrowReader = ArrowReader() - let result = arrowReader.fromFile(fileURL) - let recordBatches: [RecordBatch] - switch result { - case .success(let result): - recordBatches = result.batches - case .failure(let error): - throw error - } - - XCTAssertEqual(recordBatches.count, 1) - for recordBatch in recordBatches { - 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.info, ArrowType.ArrowDouble) - XCTAssertEqual(recordBatch.schema.fields[1].name, "two") - XCTAssertEqual(recordBatch.schema.fields[1].type.info, ArrowType.ArrowString) - for index in 0.. (ArrowSchema, RecordBatch) { - let schemaBuilder = ArrowSchema.Builder() - let schema = schemaBuilder.addField("binary", type: ArrowType(ArrowType.ArrowBinary), isNullable: false) - .finish() - - let binaryBuilder = try ArrowArrayBuilders.loadBinaryArrayBuilder() - binaryBuilder.append("test10".data(using: .utf8)) - binaryBuilder.append("test22".data(using: .utf8)) - binaryBuilder.append("test33".data(using: .utf8)) - binaryBuilder.append("test44".data(using: .utf8)) - - let binaryHolder = ArrowArrayHolderImpl(try binaryBuilder.finish()) - let result = RecordBatch.Builder() - .addColumn("binary", arrowArray: binaryHolder) - .finish() - switch result { - case .success(let recordBatch): - return (schema, recordBatch) - case .failure(let error): - throw error - } - } - - func makeTimeDataset() throws -> (ArrowSchema, RecordBatch) { - let schemaBuilder = ArrowSchema.Builder() - let schema = schemaBuilder.addField("time64", type: ArrowTypeTime64(.microseconds), isNullable: false) - .addField("time32", type: ArrowTypeTime32(.milliseconds), isNullable: false) - .finish() - - let time64Builder = try ArrowArrayBuilders.loadTime64ArrayBuilder(.nanoseconds) - time64Builder.append(12345678) - time64Builder.append(1) - time64Builder.append(nil) - time64Builder.append(98765432) - let time32Builder = try ArrowArrayBuilders.loadTime32ArrayBuilder(.milliseconds) - time32Builder.append(1) - time32Builder.append(2) - time32Builder.append(nil) - time32Builder.append(3) - let time64Holder = ArrowArrayHolderImpl(try time64Builder.finish()) - let time32Holder = ArrowArrayHolderImpl(try time32Builder.finish()) - let result = RecordBatch.Builder() - .addColumn("time64", arrowArray: time64Holder) - .addColumn("time32", arrowArray: time32Holder) - .finish() - switch result { - case .success(let recordBatch): - return (schema, recordBatch) - case .failure(let error): - throw error - } - } - - func testStructRBInMemoryToFromStream() throws { - // read existing file - let schema = makeStructSchema() - let recordBatch = try makeStructRecordBatch() - let arrowWriter = ArrowWriter() - let writerInfo = ArrowWriter.Info(.recordbatch, schema: schema, batches: [recordBatch]) - switch arrowWriter.writeStreaming(writerInfo) { - case .success(let writeData): - let arrowReader = ArrowReader() - switch arrowReader.readStreaming(writeData) { - case .success(let result): - let recordBatches = result.batches - XCTAssertEqual(recordBatches.count, 1) - for recordBatch in recordBatches { - XCTAssertEqual(recordBatch.length, 3) - XCTAssertEqual(recordBatch.columns.count, 1) - XCTAssertEqual(recordBatch.schema.fields.count, 1) - XCTAssertEqual(recordBatch.schema.fields[0].name, "struct1") - XCTAssertEqual(recordBatch.schema.fields[0].type.id, .strct) - XCTAssertTrue(recordBatch.schema.fields[0].type is ArrowNestedType) - let nestedType = (recordBatch.schema.fields[0].type as? ArrowNestedType)! - XCTAssertEqual(nestedType.fields.count, 14) - let columns = recordBatch.columns - XCTAssertEqual(columns[0].nullCount, 1) - XCTAssertNil(columns[0].array.asAny(1)) - let structVal = - "\((columns[0].array as? AsString)!.asString(0))" - XCTAssertEqual(structVal, "{true,1,2,3,4,5,6,7,8,9.9,10.1,11,12,\(currentDate)}") - let structArray = (recordBatch.columns[0].array as? StructArray)! - XCTAssertEqual(structArray.length, 3) - XCTAssertEqual(structArray.arrowFields!.count, 14) - XCTAssertEqual(structArray.arrowFields![0].type.id, .boolean) - XCTAssertEqual(structArray.arrowFields![1].type.id, .int8) - XCTAssertEqual(structArray.arrowFields![2].type.id, .int16) - XCTAssertEqual(structArray.arrowFields![3].type.id, .int32) - XCTAssertEqual(structArray.arrowFields![4].type.id, .int64) - XCTAssertEqual(structArray.arrowFields![5].type.id, .uint8) - XCTAssertEqual(structArray.arrowFields![6].type.id, .uint16) - XCTAssertEqual(structArray.arrowFields![7].type.id, .uint32) - XCTAssertEqual(structArray.arrowFields![8].type.id, .uint64) - XCTAssertEqual(structArray.arrowFields![9].type.id, .double) - XCTAssertEqual(structArray.arrowFields![10].type.id, .float) - XCTAssertEqual(structArray.arrowFields![11].type.id, .string) - XCTAssertEqual(structArray.arrowFields![12].type.id, .binary) - XCTAssertEqual(structArray.arrowFields![13].type.id, .date64) - } - case.failure(let error): - throw error - } - case .failure(let error): - throw error - } - } - - func testBinaryInMemoryToFromStream() throws { - let dataset = try makeBinaryDataset() - let writerInfo = ArrowWriter.Info(.recordbatch, schema: dataset.0, batches: [dataset.1]) - let arrowWriter = ArrowWriter() - switch arrowWriter.writeFile(writerInfo) { - case .success(let writeData): - let arrowReader = ArrowReader() - switch arrowReader.readFile(writeData) { - case .success(let result): - XCTAssertNotNil(result.schema) - let schema = result.schema! - XCTAssertEqual(schema.fields.count, 1) - XCTAssertEqual(schema.fields[0].name, "binary") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowBinary) - XCTAssertEqual(result.batches.count, 1) - let recordBatch = result.batches[0] - XCTAssertEqual(recordBatch.length, 4) - let columns = recordBatch.columns - let stringVal = - "\((columns[0].array as! AsString).asString(1))" // swiftlint:disable:this force_cast - XCTAssertEqual(stringVal, "test22") - case.failure(let error): - throw error - } - case .failure(let error): - throw error - } - } - - func testTimeInMemoryToFromStream() throws { - let dataset = try makeTimeDataset() - let writerInfo = ArrowWriter.Info(.recordbatch, schema: dataset.0, batches: [dataset.1]) - let arrowWriter = ArrowWriter() - switch arrowWriter.writeFile(writerInfo) { - case .success(let writeData): - let arrowReader = ArrowReader() - switch arrowReader.readFile(writeData) { - case .success(let result): - XCTAssertNotNil(result.schema) - let schema = result.schema! - XCTAssertEqual(schema.fields.count, 2) - XCTAssertEqual(schema.fields[0].name, "time64") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowTime64) - XCTAssertEqual(schema.fields[1].name, "time32") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowTime32) - XCTAssertEqual(result.batches.count, 1) - let recordBatch = result.batches[0] - XCTAssertEqual(recordBatch.length, 4) - let columns = recordBatch.columns - let stringVal = - "\((columns[0].array as! AsString).asString(0))" // swiftlint:disable:this force_cast - XCTAssertEqual(stringVal, "12345678") - let stringVal2 = - "\((columns[1].array as! AsString).asString(3))" // swiftlint:disable:this force_cast - XCTAssertEqual(stringVal2, "3") - case.failure(let error): - throw error - } - case .failure(let error): - throw error - } - } -} -// swiftlint:disable:this file_length diff --git a/swift/Arrow/Tests/ArrowTests/RecordBatchTests.swift b/swift/Arrow/Tests/ArrowTests/RecordBatchTests.swift deleted file mode 100644 index 9961781f308..00000000000 --- a/swift/Arrow/Tests/ArrowTests/RecordBatchTests.swift +++ /dev/null @@ -1,58 +0,0 @@ -// 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 -@testable import Arrow - -final class RecordBatchTests: XCTestCase { - func testRecordBatch() throws { - let uint8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder.append(10) - uint8Builder.append(22) - uint8Builder.append(nil) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - stringBuilder.append("test33") - - let intHolder = ArrowArrayHolderImpl(try uint8Builder.finish()) - let stringHolder = ArrowArrayHolderImpl(try stringBuilder.finish()) - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: intHolder) - .addColumn("col2", arrowArray: stringHolder) - .finish() - switch result { - case .success(let recordBatch): - let schema = recordBatch.schema - XCTAssertEqual(schema.fields.count, 2) - XCTAssertEqual(schema.fields[0].name, "col1") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowUInt8) - XCTAssertEqual(schema.fields[0].isNullable, true) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(recordBatch.columns.count, 2) - let col1: ArrowArray = recordBatch.data(for: 0) - let col2: ArrowArray = recordBatch.data(for: 1) - XCTAssertEqual(col1.length, 3) - XCTAssertEqual(col2.length, 3) - XCTAssertEqual(col1.nullCount, 1) - case .failure(let error): - throw error - } - } -} diff --git a/swift/Arrow/Tests/ArrowTests/TableTests.swift b/swift/Arrow/Tests/ArrowTests/TableTests.swift deleted file mode 100644 index dc5cabcd652..00000000000 --- a/swift/Arrow/Tests/ArrowTests/TableTests.swift +++ /dev/null @@ -1,211 +0,0 @@ -// 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 -@testable import Arrow - -final class TableTests: XCTestCase { - func testSchema() throws { - let schemaBuilder = ArrowSchema.Builder() - let schema = schemaBuilder.addField("col1", type: ArrowType(ArrowType.ArrowInt8), isNullable: true) - .addField("col2", type: ArrowType(ArrowType.ArrowBool), isNullable: false) - .finish() - XCTAssertEqual(schema.fields.count, 2) - XCTAssertEqual(schema.fields[0].name, "col1") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowInt8) - XCTAssertEqual(schema.fields[0].isNullable, true) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowBool) - XCTAssertEqual(schema.fields[1].isNullable, false) - } - - func testSchemaNested() { - class StructTest { - var field0: Bool = false - var field1: Int8 = 0 - var field2: Int16 = 0 - var field3: Int32 = 0 - var field4: Int64 = 0 - var field5: UInt8 = 0 - var field6: UInt16 = 0 - var field7: UInt32 = 0 - var field8: UInt64 = 0 - var field9: Double = 0 - var field10: Float = 0 - var field11: String = "" - var field12 = Data() - var field13: Date = Date.now - } - - let testObj = StructTest() - var fields = [ArrowField]() - let buildStructType = {() -> ArrowNestedType in - let mirror = Mirror(reflecting: testObj) - for (property, value) in mirror.children { - let arrowType = ArrowType(ArrowType.infoForType(type(of: value))) - fields.append(ArrowField(property!, type: arrowType, isNullable: true)) - } - - return ArrowNestedType(ArrowType.ArrowStruct, fields: fields) - } - - let structType = buildStructType() - XCTAssertEqual(structType.id, ArrowTypeId.strct) - XCTAssertEqual(structType.fields.count, 14) - XCTAssertEqual(structType.fields[0].type.id, ArrowTypeId.boolean) - XCTAssertEqual(structType.fields[1].type.id, ArrowTypeId.int8) - XCTAssertEqual(structType.fields[2].type.id, ArrowTypeId.int16) - XCTAssertEqual(structType.fields[3].type.id, ArrowTypeId.int32) - XCTAssertEqual(structType.fields[4].type.id, ArrowTypeId.int64) - XCTAssertEqual(structType.fields[5].type.id, ArrowTypeId.uint8) - XCTAssertEqual(structType.fields[6].type.id, ArrowTypeId.uint16) - XCTAssertEqual(structType.fields[7].type.id, ArrowTypeId.uint32) - XCTAssertEqual(structType.fields[8].type.id, ArrowTypeId.uint64) - XCTAssertEqual(structType.fields[9].type.id, ArrowTypeId.double) - XCTAssertEqual(structType.fields[10].type.id, ArrowTypeId.float) - XCTAssertEqual(structType.fields[11].type.id, ArrowTypeId.string) - XCTAssertEqual(structType.fields[12].type.id, ArrowTypeId.binary) - XCTAssertEqual(structType.fields[13].type.id, ArrowTypeId.date64) - } - - func testTable() throws { - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - doubleBuilder.append(11.11) - doubleBuilder.append(22.22) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - let date32Builder: Date32ArrayBuilder = try ArrowArrayBuilders.loadDate32ArrayBuilder() - let date2 = Date(timeIntervalSinceReferenceDate: 86400 * 1) - let date1 = Date(timeIntervalSinceReferenceDate: 86400 * 5000 + 352) - date32Builder.append(date1) - date32Builder.append(date2) - let table = try ArrowTable.Builder() - .addColumn("col1", arrowArray: doubleBuilder.finish()) - .addColumn("col2", arrowArray: stringBuilder.finish()) - .addColumn("col3", arrowArray: date32Builder.finish()) - .finish() - let schema = table.schema - XCTAssertEqual(schema.fields.count, 3) - XCTAssertEqual(schema.fields[0].name, "col1") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowDouble) - XCTAssertEqual(schema.fields[0].isNullable, false) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(table.columns.count, 3) - let col1: ChunkedArray = table.columns[0].data() - let col2: ChunkedArray = table.columns[1].data() - let col3: ChunkedArray = table.columns[2].data() - XCTAssertEqual(col1.length, 2) - XCTAssertEqual(col2.length, 2) - XCTAssertEqual(col3.length, 2) - XCTAssertEqual(col1[0], 11.11) - XCTAssertEqual(col2[1], "test22") - } - - func testTableWithChunkedData() throws { - let uint8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder.append(10) - uint8Builder.append(22) - let uint8Builder2: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder2.append(33) - let uint8Builder3: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder3.append(44) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - let stringBuilder2 = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test33") - stringBuilder.append("test44") - let date32Builder: Date32ArrayBuilder = try ArrowArrayBuilders.loadDate32ArrayBuilder() - let date2 = Date(timeIntervalSinceReferenceDate: 86400 * 1) - let date1 = Date(timeIntervalSinceReferenceDate: 86400 * 5000 + 352) - date32Builder.append(date1) - date32Builder.append(date2) - date32Builder.append(date1) - date32Builder.append(date2) - let intArray = try ChunkedArray([uint8Builder.finish(), uint8Builder2.finish(), uint8Builder3.finish()]) - let stringArray = try ChunkedArray([stringBuilder.finish(), stringBuilder2.finish()]) - let dateArray = try ChunkedArray([date32Builder.finish()]) - let table = ArrowTable.Builder() - .addColumn("col1", chunked: intArray) - .addColumn("col2", chunked: stringArray) - .addColumn("col3", chunked: dateArray) - .finish() - let schema = table.schema - XCTAssertEqual(schema.fields.count, 3) - XCTAssertEqual(schema.fields[0].name, "col1") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowUInt8) - XCTAssertEqual(schema.fields[0].isNullable, false) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(table.columns.count, 3) - let col1: ChunkedArray = table.columns[0].data() - let col2: ChunkedArray = table.columns[1].data() - let col3: ChunkedArray = table.columns[2].data() - XCTAssertEqual(col1.length, 4) - XCTAssertEqual(col2.length, 4) - XCTAssertEqual(col3.length, 4) - XCTAssertEqual(col1.asString(0), "10") - XCTAssertEqual(col1.asString(3), "44") - XCTAssertEqual(col2.asString(0), "test10") - XCTAssertEqual(col2.asString(2), "test33") - } - - func testTableToRecordBatch() throws { - let uint8Builder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - uint8Builder.append(10) - uint8Builder.append(22) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - let intHolder = ArrowArrayHolderImpl(try uint8Builder.finish()) - let stringHolder = ArrowArrayHolderImpl(try stringBuilder.finish()) - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: intHolder) - .addColumn("col2", arrowArray: stringHolder) - .finish().flatMap({ rb in - return ArrowTable.from(recordBatches: [rb]) - }) - switch result { - case .success(let table): - let schema = table.schema - XCTAssertEqual(schema.fields.count, 2) - XCTAssertEqual(schema.fields[0].name, "col1") - XCTAssertEqual(schema.fields[0].type.info, ArrowType.ArrowUInt8) - XCTAssertEqual(schema.fields[0].isNullable, false) - XCTAssertEqual(schema.fields[1].name, "col2") - XCTAssertEqual(schema.fields[1].type.info, ArrowType.ArrowString) - XCTAssertEqual(schema.fields[1].isNullable, false) - XCTAssertEqual(table.columns.count, 2) - let col1: ChunkedArray = table.columns[0].data() - let col2: ChunkedArray = table.columns[1].data() - XCTAssertEqual(col1.length, 2) - XCTAssertEqual(col2.length, 2) - case .failure(let error): - throw error - } - } -} diff --git a/swift/ArrowFlight/.gitignore b/swift/ArrowFlight/.gitignore deleted file mode 100644 index d561187385c..00000000000 --- a/swift/ArrowFlight/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/ -.netrc -Package.resolved \ No newline at end of file diff --git a/swift/ArrowFlight/Package.swift b/swift/ArrowFlight/Package.swift deleted file mode 100644 index 581ec45898b..00000000000 --- a/swift/ArrowFlight/Package.swift +++ /dev/null @@ -1,61 +0,0 @@ -// swift-tools-version: 5.10 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -// 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 PackageDescription - -let package = Package( - name: "ArrowFlight", - platforms: [ - .macOS(.v10_15) - ], - products: [ - // Products define the executables and libraries a package produces, making them visible to other packages. - .library( - name: "ArrowFlight", - targets: ["ArrowFlight"]) - ], - dependencies: [ - .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.25.0"), - .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.29.0"), - .package(path: "../Arrow") - ], - targets: [ - // Targets are the basic building blocks of a package, defining a module or a test suite. - // Targets can depend on other targets in this package and products from dependencies. - .target( - name: "ArrowFlight", - dependencies: [ - .product(name: "Arrow", package: "Arrow"), - .product(name: "GRPC", package: "grpc-swift"), - .product(name: "SwiftProtobuf", package: "swift-protobuf") - ], - swiftSettings: [ - // build: .unsafeFlags(["-warnings-as-errors"]) - ] - ), - .testTarget( - name: "ArrowFlightTests", - dependencies: ["ArrowFlight"], - swiftSettings: [ - // build: .unsafeFlags(["-warnings-as-errors"]) - ] - ) - ] -) diff --git a/swift/ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift b/swift/ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift deleted file mode 100644 index 8daaa19f07b..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift +++ /dev/null @@ -1,1343 +0,0 @@ -// 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. -// -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the protocol buffer compiler. -// Source: Flight.proto -// -import GRPC -import NIO -import NIOConcurrencyHelpers -import SwiftProtobuf - - -/// -/// A flight service is an endpoint for retrieving or storing Arrow data. A -/// flight service can expose one or more predefined endpoints that can be -/// accessed using the Arrow Flight Protocol. Additionally, a flight service -/// can expose a set of actions that are available. -/// -/// Usage: instantiate `Arrow_Flight_Protocol_FlightServiceClient`, then call methods of this protocol to make API calls. -internal protocol Arrow_Flight_Protocol_FlightServiceClientProtocol: GRPCClient { - var serviceName: String { get } - var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? { get } - - func handshake( - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_HandshakeResponse) -> Void - ) -> BidirectionalStreamingCall - - func listFlights( - _ request: Arrow_Flight_Protocol_Criteria, - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_FlightInfo) -> Void - ) -> ServerStreamingCall - - func getFlightInfo( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? - ) -> UnaryCall - - func getSchema( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? - ) -> UnaryCall - - func doGet( - _ request: Arrow_Flight_Protocol_Ticket, - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_FlightData) -> Void - ) -> ServerStreamingCall - - func doPut( - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_PutResult) -> Void - ) -> BidirectionalStreamingCall - - func doExchange( - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_FlightData) -> Void - ) -> BidirectionalStreamingCall - - func doAction( - _ request: Arrow_Flight_Protocol_Action, - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_Result) -> Void - ) -> ServerStreamingCall - - func listActions( - _ request: Arrow_Flight_Protocol_Empty, - callOptions: CallOptions?, - handler: @escaping (Arrow_Flight_Protocol_ActionType) -> Void - ) -> ServerStreamingCall -} - -extension Arrow_Flight_Protocol_FlightServiceClientProtocol { - internal var serviceName: String { - return "arrow.flight.protocol.FlightService" - } - - /// - /// Handshake between client and server. Depending on the server, the - /// handshake may be required to determine the token that should be used for - /// future operations. Both request and response are streams to allow multiple - /// round-trips depending on auth mechanism. - /// - /// Callers should use the `send` method on the returned object to send messages - /// to the server. The caller should send an `.end` after the final message has been sent. - /// - /// - Parameters: - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. - internal func handshake( - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_HandshakeResponse) -> Void - ) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.handshake.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [], - handler: handler - ) - } - - /// - /// Get a list of available streams given a particular criteria. Most flight - /// services will expose one or more streams that are readily available for - /// retrieval. This api allows listing the streams available for - /// consumption. A user can also provide a criteria. The criteria can limit - /// the subset of streams that can be listed via this interface. Each flight - /// service allows its own definition of how to consume criteria. - /// - /// - Parameters: - /// - request: Request to send to ListFlights. - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. - internal func listFlights( - _ request: Arrow_Flight_Protocol_Criteria, - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_FlightInfo) -> Void - ) -> ServerStreamingCall { - return self.makeServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listFlights.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListFlightsInterceptors() ?? [], - handler: handler - ) - } - - /// - /// For a given FlightDescriptor, get information about how the flight can be - /// consumed. This is a useful interface if the consumer of the interface - /// already can identify the specific flight to consume. This interface can - /// also allow a consumer to generate a flight stream through a specified - /// descriptor. For example, a flight descriptor might be something that - /// includes a SQL statement or a Pickled Python operation that will be - /// executed. In those cases, the descriptor will not be previously available - /// within the list of available streams provided by ListFlights but will be - /// available for consumption for the duration defined by the specific flight - /// service. - /// - /// - Parameters: - /// - request: Request to send to GetFlightInfo. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - internal func getFlightInfo( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getFlightInfo.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetFlightInfoInterceptors() ?? [] - ) - } - - /// - /// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema - /// This is used when a consumer needs the Schema of flight stream. Similar to - /// GetFlightInfo this interface may generate a new flight that was not previously - /// available in ListFlights. - /// - /// - Parameters: - /// - request: Request to send to GetSchema. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - internal func getSchema( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getSchema.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetSchemaInterceptors() ?? [] - ) - } - - /// - /// Retrieve a single stream associated with a particular descriptor - /// associated with the referenced ticket. A Flight can be composed of one or - /// more streams where each stream can be retrieved using a separate opaque - /// ticket that the flight service uses for managing a collection of streams. - /// - /// - Parameters: - /// - request: Request to send to DoGet. - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. - internal func doGet( - _ request: Arrow_Flight_Protocol_Ticket, - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_FlightData) -> Void - ) -> ServerStreamingCall { - return self.makeServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doGet.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoGetInterceptors() ?? [], - handler: handler - ) - } - - /// - /// Push a stream to the flight service associated with a particular - /// flight stream. This allows a client of a flight service to upload a stream - /// of data. Depending on the particular flight service, a client consumer - /// could be allowed to upload a single stream per descriptor or an unlimited - /// number. In the latter, the service might implement a 'seal' action that - /// can be applied to a descriptor once all streams are uploaded. - /// - /// Callers should use the `send` method on the returned object to send messages - /// to the server. The caller should send an `.end` after the final message has been sent. - /// - /// - Parameters: - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. - internal func doPut( - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_PutResult) -> Void - ) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doPut.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [], - handler: handler - ) - } - - /// - /// Open a bidirectional data channel for a given descriptor. This - /// allows clients to send and receive arbitrary Arrow data and - /// application-specific metadata in a single logical stream. In - /// contrast to DoGet/DoPut, this is more suited for clients - /// offloading computation (rather than storage) to a Flight service. - /// - /// Callers should use the `send` method on the returned object to send messages - /// to the server. The caller should send an `.end` after the final message has been sent. - /// - /// - Parameters: - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ClientStreamingCall` with futures for the metadata and status. - internal func doExchange( - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_FlightData) -> Void - ) -> BidirectionalStreamingCall { - return self.makeBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doExchange.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [], - handler: handler - ) - } - - /// - /// Flight services can support an arbitrary number of simple actions in - /// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut - /// operations that are potentially available. DoAction allows a flight client - /// to do a specific action against a flight service. An action includes - /// opaque request and response objects that are specific to the type action - /// being undertaken. - /// - /// - Parameters: - /// - request: Request to send to DoAction. - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. - internal func doAction( - _ request: Arrow_Flight_Protocol_Action, - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_Result) -> Void - ) -> ServerStreamingCall { - return self.makeServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doAction.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoActionInterceptors() ?? [], - handler: handler - ) - } - - /// - /// A flight service exposes all of the available action types that it has - /// along with descriptions. This allows different flight consumers to - /// understand the capabilities of the flight service. - /// - /// - Parameters: - /// - request: Request to send to ListActions. - /// - callOptions: Call options. - /// - handler: A closure called when each response is received from the server. - /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. - internal func listActions( - _ request: Arrow_Flight_Protocol_Empty, - callOptions: CallOptions? = nil, - handler: @escaping (Arrow_Flight_Protocol_ActionType) -> Void - ) -> ServerStreamingCall { - return self.makeServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listActions.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListActionsInterceptors() ?? [], - handler: handler - ) - } -} - -@available(*, deprecated) -extension Arrow_Flight_Protocol_FlightServiceClient: @unchecked Sendable {} - -@available(*, deprecated, renamed: "Arrow_Flight_Protocol_FlightServiceNIOClient") -internal final class Arrow_Flight_Protocol_FlightServiceClient: Arrow_Flight_Protocol_FlightServiceClientProtocol { - private let lock = Lock() - private var _defaultCallOptions: CallOptions - private var _interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? - internal let channel: GRPCChannel - internal var defaultCallOptions: CallOptions { - get { self.lock.withLock { return self._defaultCallOptions } } - set { self.lock.withLockVoid { self._defaultCallOptions = newValue } } - } - internal var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? { - get { self.lock.withLock { return self._interceptors } } - set { self.lock.withLockVoid { self._interceptors = newValue } } - } - - /// Creates a client for the arrow.flight.protocol.FlightService service. - /// - /// - Parameters: - /// - channel: `GRPCChannel` to the service host. - /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. - /// - interceptors: A factory providing interceptors for each RPC. - internal init( - channel: GRPCChannel, - defaultCallOptions: CallOptions = CallOptions(), - interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? = nil - ) { - self.channel = channel - self._defaultCallOptions = defaultCallOptions - self._interceptors = interceptors - } -} - -internal struct Arrow_Flight_Protocol_FlightServiceNIOClient: Arrow_Flight_Protocol_FlightServiceClientProtocol { - internal var channel: GRPCChannel - internal var defaultCallOptions: CallOptions - internal var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? - - /// Creates a client for the arrow.flight.protocol.FlightService service. - /// - /// - Parameters: - /// - channel: `GRPCChannel` to the service host. - /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. - /// - interceptors: A factory providing interceptors for each RPC. - internal init( - channel: GRPCChannel, - defaultCallOptions: CallOptions = CallOptions(), - interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? = nil - ) { - self.channel = channel - self.defaultCallOptions = defaultCallOptions - self.interceptors = interceptors - } -} - -/// -/// A flight service is an endpoint for retrieving or storing Arrow data. A -/// flight service can expose one or more predefined endpoints that can be -/// accessed using the Arrow Flight Protocol. Additionally, a flight service -/// can expose a set of actions that are available. -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -internal protocol Arrow_Flight_Protocol_FlightServiceAsyncClientProtocol: GRPCClient { - static var serviceDescriptor: GRPCServiceDescriptor { get } - var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? { get } - - func makeHandshakeCall( - callOptions: CallOptions? - ) -> GRPCAsyncBidirectionalStreamingCall - - func makeListFlightsCall( - _ request: Arrow_Flight_Protocol_Criteria, - callOptions: CallOptions? - ) -> GRPCAsyncServerStreamingCall - - func makeGetFlightInfoCall( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? - ) -> GRPCAsyncUnaryCall - - func makeGetSchemaCall( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? - ) -> GRPCAsyncUnaryCall - - func makeDoGetCall( - _ request: Arrow_Flight_Protocol_Ticket, - callOptions: CallOptions? - ) -> GRPCAsyncServerStreamingCall - - func makeDoPutCall( - callOptions: CallOptions? - ) -> GRPCAsyncBidirectionalStreamingCall - - func makeDoExchangeCall( - callOptions: CallOptions? - ) -> GRPCAsyncBidirectionalStreamingCall - - func makeDoActionCall( - _ request: Arrow_Flight_Protocol_Action, - callOptions: CallOptions? - ) -> GRPCAsyncServerStreamingCall - - func makeListActionsCall( - _ request: Arrow_Flight_Protocol_Empty, - callOptions: CallOptions? - ) -> GRPCAsyncServerStreamingCall -} - -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -extension Arrow_Flight_Protocol_FlightServiceAsyncClientProtocol { - internal static var serviceDescriptor: GRPCServiceDescriptor { - return Arrow_Flight_Protocol_FlightServiceClientMetadata.serviceDescriptor - } - - internal var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? { - return nil - } - - internal func makeHandshakeCall( - callOptions: CallOptions? = nil - ) -> GRPCAsyncBidirectionalStreamingCall { - return self.makeAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.handshake.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [] - ) - } - - internal func makeListFlightsCall( - _ request: Arrow_Flight_Protocol_Criteria, - callOptions: CallOptions? = nil - ) -> GRPCAsyncServerStreamingCall { - return self.makeAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listFlights.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListFlightsInterceptors() ?? [] - ) - } - - internal func makeGetFlightInfoCall( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) -> GRPCAsyncUnaryCall { - return self.makeAsyncUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getFlightInfo.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetFlightInfoInterceptors() ?? [] - ) - } - - internal func makeGetSchemaCall( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) -> GRPCAsyncUnaryCall { - return self.makeAsyncUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getSchema.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetSchemaInterceptors() ?? [] - ) - } - - internal func makeDoGetCall( - _ request: Arrow_Flight_Protocol_Ticket, - callOptions: CallOptions? = nil - ) -> GRPCAsyncServerStreamingCall { - return self.makeAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doGet.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoGetInterceptors() ?? [] - ) - } - - internal func makeDoPutCall( - callOptions: CallOptions? = nil - ) -> GRPCAsyncBidirectionalStreamingCall { - return self.makeAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doPut.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [] - ) - } - - internal func makeDoExchangeCall( - callOptions: CallOptions? = nil - ) -> GRPCAsyncBidirectionalStreamingCall { - return self.makeAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doExchange.path, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [] - ) - } - - internal func makeDoActionCall( - _ request: Arrow_Flight_Protocol_Action, - callOptions: CallOptions? = nil - ) -> GRPCAsyncServerStreamingCall { - return self.makeAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doAction.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoActionInterceptors() ?? [] - ) - } - - internal func makeListActionsCall( - _ request: Arrow_Flight_Protocol_Empty, - callOptions: CallOptions? = nil - ) -> GRPCAsyncServerStreamingCall { - return self.makeAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listActions.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListActionsInterceptors() ?? [] - ) - } -} - -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -extension Arrow_Flight_Protocol_FlightServiceAsyncClientProtocol { - internal func handshake( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: Sequence, RequestStream.Element == Arrow_Flight_Protocol_HandshakeRequest { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.handshake.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [] - ) - } - - internal func handshake( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Arrow_Flight_Protocol_HandshakeRequest { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.handshake.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [] - ) - } - - internal func listFlights( - _ request: Arrow_Flight_Protocol_Criteria, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream { - return self.performAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listFlights.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListFlightsInterceptors() ?? [] - ) - } - - internal func getFlightInfo( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) async throws -> Arrow_Flight_Protocol_FlightInfo { - return try await self.performAsyncUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getFlightInfo.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetFlightInfoInterceptors() ?? [] - ) - } - - internal func getSchema( - _ request: Arrow_Flight_Protocol_FlightDescriptor, - callOptions: CallOptions? = nil - ) async throws -> Arrow_Flight_Protocol_SchemaResult { - return try await self.performAsyncUnaryCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getSchema.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetSchemaInterceptors() ?? [] - ) - } - - internal func doGet( - _ request: Arrow_Flight_Protocol_Ticket, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream { - return self.performAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doGet.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoGetInterceptors() ?? [] - ) - } - - internal func doPut( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: Sequence, RequestStream.Element == Arrow_Flight_Protocol_FlightData { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doPut.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [] - ) - } - - internal func doPut( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Arrow_Flight_Protocol_FlightData { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doPut.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [] - ) - } - - internal func doExchange( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: Sequence, RequestStream.Element == Arrow_Flight_Protocol_FlightData { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doExchange.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [] - ) - } - - internal func doExchange( - _ requests: RequestStream, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Arrow_Flight_Protocol_FlightData { - return self.performAsyncBidirectionalStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doExchange.path, - requests: requests, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [] - ) - } - - internal func doAction( - _ request: Arrow_Flight_Protocol_Action, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream { - return self.performAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doAction.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeDoActionInterceptors() ?? [] - ) - } - - internal func listActions( - _ request: Arrow_Flight_Protocol_Empty, - callOptions: CallOptions? = nil - ) -> GRPCAsyncResponseStream { - return self.performAsyncServerStreamingCall( - path: Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listActions.path, - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeListActionsInterceptors() ?? [] - ) - } -} - -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -internal struct Arrow_Flight_Protocol_FlightServiceAsyncClient: Arrow_Flight_Protocol_FlightServiceAsyncClientProtocol { - internal var channel: GRPCChannel - internal var defaultCallOptions: CallOptions - internal var interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? - - internal init( - channel: GRPCChannel, - defaultCallOptions: CallOptions = CallOptions(), - interceptors: Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol? = nil - ) { - self.channel = channel - self.defaultCallOptions = defaultCallOptions - self.interceptors = interceptors - } -} - -internal protocol Arrow_Flight_Protocol_FlightServiceClientInterceptorFactoryProtocol: Sendable { - - /// - Returns: Interceptors to use when invoking 'handshake'. - func makeHandshakeInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'listFlights'. - func makeListFlightsInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getFlightInfo'. - func makeGetFlightInfoInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getSchema'. - func makeGetSchemaInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'doGet'. - func makeDoGetInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'doPut'. - func makeDoPutInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'doExchange'. - func makeDoExchangeInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'doAction'. - func makeDoActionInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'listActions'. - func makeListActionsInterceptors() -> [ClientInterceptor] -} - -internal enum Arrow_Flight_Protocol_FlightServiceClientMetadata { - internal static let serviceDescriptor = GRPCServiceDescriptor( - name: "FlightService", - fullName: "arrow.flight.protocol.FlightService", - methods: [ - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.handshake, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listFlights, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getFlightInfo, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.getSchema, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doGet, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doPut, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doExchange, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.doAction, - Arrow_Flight_Protocol_FlightServiceClientMetadata.Methods.listActions, - ] - ) - - internal enum Methods { - internal static let handshake = GRPCMethodDescriptor( - name: "Handshake", - path: "/arrow.flight.protocol.FlightService/Handshake", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let listFlights = GRPCMethodDescriptor( - name: "ListFlights", - path: "/arrow.flight.protocol.FlightService/ListFlights", - type: GRPCCallType.serverStreaming - ) - - internal static let getFlightInfo = GRPCMethodDescriptor( - name: "GetFlightInfo", - path: "/arrow.flight.protocol.FlightService/GetFlightInfo", - type: GRPCCallType.unary - ) - - internal static let getSchema = GRPCMethodDescriptor( - name: "GetSchema", - path: "/arrow.flight.protocol.FlightService/GetSchema", - type: GRPCCallType.unary - ) - - internal static let doGet = GRPCMethodDescriptor( - name: "DoGet", - path: "/arrow.flight.protocol.FlightService/DoGet", - type: GRPCCallType.serverStreaming - ) - - internal static let doPut = GRPCMethodDescriptor( - name: "DoPut", - path: "/arrow.flight.protocol.FlightService/DoPut", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let doExchange = GRPCMethodDescriptor( - name: "DoExchange", - path: "/arrow.flight.protocol.FlightService/DoExchange", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let doAction = GRPCMethodDescriptor( - name: "DoAction", - path: "/arrow.flight.protocol.FlightService/DoAction", - type: GRPCCallType.serverStreaming - ) - - internal static let listActions = GRPCMethodDescriptor( - name: "ListActions", - path: "/arrow.flight.protocol.FlightService/ListActions", - type: GRPCCallType.serverStreaming - ) - } -} - -/// -/// A flight service is an endpoint for retrieving or storing Arrow data. A -/// flight service can expose one or more predefined endpoints that can be -/// accessed using the Arrow Flight Protocol. Additionally, a flight service -/// can expose a set of actions that are available. -/// -/// To build a server, implement a class that conforms to this protocol. -internal protocol Arrow_Flight_Protocol_FlightServiceProvider: CallHandlerProvider { - var interceptors: Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { get } - - /// - /// Handshake between client and server. Depending on the server, the - /// handshake may be required to determine the token that should be used for - /// future operations. Both request and response are streams to allow multiple - /// round-trips depending on auth mechanism. - func handshake(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> - - /// - /// Get a list of available streams given a particular criteria. Most flight - /// services will expose one or more streams that are readily available for - /// retrieval. This api allows listing the streams available for - /// consumption. A user can also provide a criteria. The criteria can limit - /// the subset of streams that can be listed via this interface. Each flight - /// service allows its own definition of how to consume criteria. - func listFlights(request: Arrow_Flight_Protocol_Criteria, context: StreamingResponseCallContext) -> EventLoopFuture - - /// - /// For a given FlightDescriptor, get information about how the flight can be - /// consumed. This is a useful interface if the consumer of the interface - /// already can identify the specific flight to consume. This interface can - /// also allow a consumer to generate a flight stream through a specified - /// descriptor. For example, a flight descriptor might be something that - /// includes a SQL statement or a Pickled Python operation that will be - /// executed. In those cases, the descriptor will not be previously available - /// within the list of available streams provided by ListFlights but will be - /// available for consumption for the duration defined by the specific flight - /// service. - func getFlightInfo(request: Arrow_Flight_Protocol_FlightDescriptor, context: StatusOnlyCallContext) -> EventLoopFuture - - /// - /// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema - /// This is used when a consumer needs the Schema of flight stream. Similar to - /// GetFlightInfo this interface may generate a new flight that was not previously - /// available in ListFlights. - func getSchema(request: Arrow_Flight_Protocol_FlightDescriptor, context: StatusOnlyCallContext) -> EventLoopFuture - - /// - /// Retrieve a single stream associated with a particular descriptor - /// associated with the referenced ticket. A Flight can be composed of one or - /// more streams where each stream can be retrieved using a separate opaque - /// ticket that the flight service uses for managing a collection of streams. - func doGet(request: Arrow_Flight_Protocol_Ticket, context: StreamingResponseCallContext) -> EventLoopFuture - - /// - /// Push a stream to the flight service associated with a particular - /// flight stream. This allows a client of a flight service to upload a stream - /// of data. Depending on the particular flight service, a client consumer - /// could be allowed to upload a single stream per descriptor or an unlimited - /// number. In the latter, the service might implement a 'seal' action that - /// can be applied to a descriptor once all streams are uploaded. - func doPut(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> - - /// - /// Open a bidirectional data channel for a given descriptor. This - /// allows clients to send and receive arbitrary Arrow data and - /// application-specific metadata in a single logical stream. In - /// contrast to DoGet/DoPut, this is more suited for clients - /// offloading computation (rather than storage) to a Flight service. - func doExchange(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> - - /// - /// Flight services can support an arbitrary number of simple actions in - /// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut - /// operations that are potentially available. DoAction allows a flight client - /// to do a specific action against a flight service. An action includes - /// opaque request and response objects that are specific to the type action - /// being undertaken. - func doAction(request: Arrow_Flight_Protocol_Action, context: StreamingResponseCallContext) -> EventLoopFuture - - /// - /// A flight service exposes all of the available action types that it has - /// along with descriptions. This allows different flight consumers to - /// understand the capabilities of the flight service. - func listActions(request: Arrow_Flight_Protocol_Empty, context: StreamingResponseCallContext) -> EventLoopFuture -} - -extension Arrow_Flight_Protocol_FlightServiceProvider { - internal var serviceName: Substring { - return Arrow_Flight_Protocol_FlightServiceServerMetadata.serviceDescriptor.fullName[...] - } - - /// Determines, calls and returns the appropriate request handler, depending on the request's method. - /// Returns nil for methods not handled by this service. - internal func handle( - method name: Substring, - context: CallHandlerContext - ) -> GRPCServerHandlerProtocol? { - switch name { - case "Handshake": - return BidirectionalStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [], - observerFactory: self.handshake(context:) - ) - - case "ListFlights": - return ServerStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeListFlightsInterceptors() ?? [], - userFunction: self.listFlights(request:context:) - ) - - case "GetFlightInfo": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetFlightInfoInterceptors() ?? [], - userFunction: self.getFlightInfo(request:context:) - ) - - case "GetSchema": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetSchemaInterceptors() ?? [], - userFunction: self.getSchema(request:context:) - ) - - case "DoGet": - return ServerStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoGetInterceptors() ?? [], - userFunction: self.doGet(request:context:) - ) - - case "DoPut": - return BidirectionalStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [], - observerFactory: self.doPut(context:) - ) - - case "DoExchange": - return BidirectionalStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [], - observerFactory: self.doExchange(context:) - ) - - case "DoAction": - return ServerStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoActionInterceptors() ?? [], - userFunction: self.doAction(request:context:) - ) - - case "ListActions": - return ServerStreamingServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeListActionsInterceptors() ?? [], - userFunction: self.listActions(request:context:) - ) - - default: - return nil - } - } -} - -/// -/// A flight service is an endpoint for retrieving or storing Arrow data. A -/// flight service can expose one or more predefined endpoints that can be -/// accessed using the Arrow Flight Protocol. Additionally, a flight service -/// can expose a set of actions that are available. -/// -/// To implement a server, implement an object which conforms to this protocol. -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -internal protocol Arrow_Flight_Protocol_FlightServiceAsyncProvider: CallHandlerProvider, Sendable { - static var serviceDescriptor: GRPCServiceDescriptor { get } - var interceptors: Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { get } - - /// - /// Handshake between client and server. Depending on the server, the - /// handshake may be required to determine the token that should be used for - /// future operations. Both request and response are streams to allow multiple - /// round-trips depending on auth mechanism. - func handshake( - requestStream: GRPCAsyncRequestStream, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// Get a list of available streams given a particular criteria. Most flight - /// services will expose one or more streams that are readily available for - /// retrieval. This api allows listing the streams available for - /// consumption. A user can also provide a criteria. The criteria can limit - /// the subset of streams that can be listed via this interface. Each flight - /// service allows its own definition of how to consume criteria. - func listFlights( - request: Arrow_Flight_Protocol_Criteria, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// For a given FlightDescriptor, get information about how the flight can be - /// consumed. This is a useful interface if the consumer of the interface - /// already can identify the specific flight to consume. This interface can - /// also allow a consumer to generate a flight stream through a specified - /// descriptor. For example, a flight descriptor might be something that - /// includes a SQL statement or a Pickled Python operation that will be - /// executed. In those cases, the descriptor will not be previously available - /// within the list of available streams provided by ListFlights but will be - /// available for consumption for the duration defined by the specific flight - /// service. - func getFlightInfo( - request: Arrow_Flight_Protocol_FlightDescriptor, - context: GRPCAsyncServerCallContext - ) async throws -> Arrow_Flight_Protocol_FlightInfo - - /// - /// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema - /// This is used when a consumer needs the Schema of flight stream. Similar to - /// GetFlightInfo this interface may generate a new flight that was not previously - /// available in ListFlights. - func getSchema( - request: Arrow_Flight_Protocol_FlightDescriptor, - context: GRPCAsyncServerCallContext - ) async throws -> Arrow_Flight_Protocol_SchemaResult - - /// - /// Retrieve a single stream associated with a particular descriptor - /// associated with the referenced ticket. A Flight can be composed of one or - /// more streams where each stream can be retrieved using a separate opaque - /// ticket that the flight service uses for managing a collection of streams. - func doGet( - request: Arrow_Flight_Protocol_Ticket, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// Push a stream to the flight service associated with a particular - /// flight stream. This allows a client of a flight service to upload a stream - /// of data. Depending on the particular flight service, a client consumer - /// could be allowed to upload a single stream per descriptor or an unlimited - /// number. In the latter, the service might implement a 'seal' action that - /// can be applied to a descriptor once all streams are uploaded. - func doPut( - requestStream: GRPCAsyncRequestStream, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// Open a bidirectional data channel for a given descriptor. This - /// allows clients to send and receive arbitrary Arrow data and - /// application-specific metadata in a single logical stream. In - /// contrast to DoGet/DoPut, this is more suited for clients - /// offloading computation (rather than storage) to a Flight service. - func doExchange( - requestStream: GRPCAsyncRequestStream, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// Flight services can support an arbitrary number of simple actions in - /// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut - /// operations that are potentially available. DoAction allows a flight client - /// to do a specific action against a flight service. An action includes - /// opaque request and response objects that are specific to the type action - /// being undertaken. - func doAction( - request: Arrow_Flight_Protocol_Action, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws - - /// - /// A flight service exposes all of the available action types that it has - /// along with descriptions. This allows different flight consumers to - /// understand the capabilities of the flight service. - func listActions( - request: Arrow_Flight_Protocol_Empty, - responseStream: GRPCAsyncResponseStreamWriter, - context: GRPCAsyncServerCallContext - ) async throws -} - -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -extension Arrow_Flight_Protocol_FlightServiceAsyncProvider { - internal static var serviceDescriptor: GRPCServiceDescriptor { - return Arrow_Flight_Protocol_FlightServiceServerMetadata.serviceDescriptor - } - - internal var serviceName: Substring { - return Arrow_Flight_Protocol_FlightServiceServerMetadata.serviceDescriptor.fullName[...] - } - - internal var interceptors: Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { - return nil - } - - internal func handle( - method name: Substring, - context: CallHandlerContext - ) -> GRPCServerHandlerProtocol? { - switch name { - case "Handshake": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeHandshakeInterceptors() ?? [], - wrapping: { try await self.handshake(requestStream: $0, responseStream: $1, context: $2) } - ) - - case "ListFlights": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeListFlightsInterceptors() ?? [], - wrapping: { try await self.listFlights(request: $0, responseStream: $1, context: $2) } - ) - - case "GetFlightInfo": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetFlightInfoInterceptors() ?? [], - wrapping: { try await self.getFlightInfo(request: $0, context: $1) } - ) - - case "GetSchema": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetSchemaInterceptors() ?? [], - wrapping: { try await self.getSchema(request: $0, context: $1) } - ) - - case "DoGet": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoGetInterceptors() ?? [], - wrapping: { try await self.doGet(request: $0, responseStream: $1, context: $2) } - ) - - case "DoPut": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoPutInterceptors() ?? [], - wrapping: { try await self.doPut(requestStream: $0, responseStream: $1, context: $2) } - ) - - case "DoExchange": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoExchangeInterceptors() ?? [], - wrapping: { try await self.doExchange(requestStream: $0, responseStream: $1, context: $2) } - ) - - case "DoAction": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeDoActionInterceptors() ?? [], - wrapping: { try await self.doAction(request: $0, responseStream: $1, context: $2) } - ) - - case "ListActions": - return GRPCAsyncServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeListActionsInterceptors() ?? [], - wrapping: { try await self.listActions(request: $0, responseStream: $1, context: $2) } - ) - - default: - return nil - } - } -} - -internal protocol Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol: Sendable { - - /// - Returns: Interceptors to use when handling 'handshake'. - /// Defaults to calling `self.makeInterceptors()`. - func makeHandshakeInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'listFlights'. - /// Defaults to calling `self.makeInterceptors()`. - func makeListFlightsInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getFlightInfo'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetFlightInfoInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getSchema'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetSchemaInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'doGet'. - /// Defaults to calling `self.makeInterceptors()`. - func makeDoGetInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'doPut'. - /// Defaults to calling `self.makeInterceptors()`. - func makeDoPutInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'doExchange'. - /// Defaults to calling `self.makeInterceptors()`. - func makeDoExchangeInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'doAction'. - /// Defaults to calling `self.makeInterceptors()`. - func makeDoActionInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'listActions'. - /// Defaults to calling `self.makeInterceptors()`. - func makeListActionsInterceptors() -> [ServerInterceptor] -} - -internal enum Arrow_Flight_Protocol_FlightServiceServerMetadata { - internal static let serviceDescriptor = GRPCServiceDescriptor( - name: "FlightService", - fullName: "arrow.flight.protocol.FlightService", - methods: [ - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.handshake, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.listFlights, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.getFlightInfo, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.getSchema, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.doGet, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.doPut, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.doExchange, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.doAction, - Arrow_Flight_Protocol_FlightServiceServerMetadata.Methods.listActions, - ] - ) - - internal enum Methods { - internal static let handshake = GRPCMethodDescriptor( - name: "Handshake", - path: "/arrow.flight.protocol.FlightService/Handshake", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let listFlights = GRPCMethodDescriptor( - name: "ListFlights", - path: "/arrow.flight.protocol.FlightService/ListFlights", - type: GRPCCallType.serverStreaming - ) - - internal static let getFlightInfo = GRPCMethodDescriptor( - name: "GetFlightInfo", - path: "/arrow.flight.protocol.FlightService/GetFlightInfo", - type: GRPCCallType.unary - ) - - internal static let getSchema = GRPCMethodDescriptor( - name: "GetSchema", - path: "/arrow.flight.protocol.FlightService/GetSchema", - type: GRPCCallType.unary - ) - - internal static let doGet = GRPCMethodDescriptor( - name: "DoGet", - path: "/arrow.flight.protocol.FlightService/DoGet", - type: GRPCCallType.serverStreaming - ) - - internal static let doPut = GRPCMethodDescriptor( - name: "DoPut", - path: "/arrow.flight.protocol.FlightService/DoPut", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let doExchange = GRPCMethodDescriptor( - name: "DoExchange", - path: "/arrow.flight.protocol.FlightService/DoExchange", - type: GRPCCallType.bidirectionalStreaming - ) - - internal static let doAction = GRPCMethodDescriptor( - name: "DoAction", - path: "/arrow.flight.protocol.FlightService/DoAction", - type: GRPCCallType.serverStreaming - ) - - internal static let listActions = GRPCMethodDescriptor( - name: "ListActions", - path: "/arrow.flight.protocol.FlightService/ListActions", - type: GRPCCallType.serverStreaming - ) - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/Flight.pb.swift b/swift/ArrowFlight/Sources/ArrowFlight/Flight.pb.swift deleted file mode 100644 index b50d4062529..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/Flight.pb.swift +++ /dev/null @@ -1,1366 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: Flight.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -// -// 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 Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// -/// The result of a cancel operation. -/// -/// This is used by CancelFlightInfoResult.status. -enum Arrow_Flight_Protocol_CancelStatus: SwiftProtobuf.Enum { - typealias RawValue = Int - - /// The cancellation status is unknown. Servers should avoid using - /// this value (send a NOT_FOUND error if the requested query is - /// not known). Clients can retry the request. - case unspecified // = 0 - - /// The cancellation request is complete. Subsequent requests with - /// the same payload may return CANCELLED or a NOT_FOUND error. - case cancelled // = 1 - - /// The cancellation request is in progress. The client may retry - /// the cancellation request. - case cancelling // = 2 - - /// The query is not cancellable. The client should not retry the - /// cancellation request. - case notCancellable // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .unspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .cancelled - case 2: self = .cancelling - case 3: self = .notCancellable - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .unspecified: return 0 - case .cancelled: return 1 - case .cancelling: return 2 - case .notCancellable: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_CancelStatus: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_CancelStatus] = [ - .unspecified, - .cancelled, - .cancelling, - .notCancellable, - ] -} - -#endif // swift(>=4.2) - -/// -/// The request that a client provides to a server on handshake. -struct Arrow_Flight_Protocol_HandshakeRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// A defined protocol version - var protocolVersion: UInt64 = 0 - - /// - /// Arbitrary auth/handshake info. - var payload: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Arrow_Flight_Protocol_HandshakeResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// A defined protocol version - var protocolVersion: UInt64 = 0 - - /// - /// Arbitrary auth/handshake info. - var payload: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// A message for doing simple auth. -struct Arrow_Flight_Protocol_BasicAuth { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var username: String = String() - - var password: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Arrow_Flight_Protocol_Empty { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Describes an available action, including both the name used for execution -/// along with a short description of the purpose of the action. -struct Arrow_Flight_Protocol_ActionType { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var type: String = String() - - var description_p: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// A service specific expression that can be used to return a limited set -/// of available Arrow Flight streams. -struct Arrow_Flight_Protocol_Criteria { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var expression: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// An opaque action specific for the service. -struct Arrow_Flight_Protocol_Action { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var type: String = String() - - var body: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The request of the CancelFlightInfo action. -/// -/// The request should be stored in Action.body. -struct Arrow_Flight_Protocol_CancelFlightInfoRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var info: Arrow_Flight_Protocol_FlightInfo { - get {return _info ?? Arrow_Flight_Protocol_FlightInfo()} - set {_info = newValue} - } - /// Returns true if `info` has been explicitly set. - var hasInfo: Bool {return self._info != nil} - /// Clears the value of `info`. Subsequent reads from it will return its default value. - mutating func clearInfo() {self._info = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _info: Arrow_Flight_Protocol_FlightInfo? = nil -} - -/// -/// The request of the RenewFlightEndpoint action. -/// -/// The request should be stored in Action.body. -struct Arrow_Flight_Protocol_RenewFlightEndpointRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var endpoint: Arrow_Flight_Protocol_FlightEndpoint { - get {return _endpoint ?? Arrow_Flight_Protocol_FlightEndpoint()} - set {_endpoint = newValue} - } - /// Returns true if `endpoint` has been explicitly set. - var hasEndpoint: Bool {return self._endpoint != nil} - /// Clears the value of `endpoint`. Subsequent reads from it will return its default value. - mutating func clearEndpoint() {self._endpoint = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _endpoint: Arrow_Flight_Protocol_FlightEndpoint? = nil -} - -/// -/// An opaque result returned after executing an action. -struct Arrow_Flight_Protocol_Result { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var body: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The result of the CancelFlightInfo action. -/// -/// The result should be stored in Result.body. -struct Arrow_Flight_Protocol_CancelFlightInfoResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var status: Arrow_Flight_Protocol_CancelStatus = .unspecified - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Wrap the result of a getSchema call -struct Arrow_Flight_Protocol_SchemaResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The schema of the dataset in its IPC form: - /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix - /// 4 bytes - the byte length of the payload - /// a flatbuffer Message whose header is the Schema - var schema: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The name or tag for a Flight. May be used as a way to retrieve or generate -/// a flight or be used to expose a set of previously defined flights. -struct Arrow_Flight_Protocol_FlightDescriptor { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var type: Arrow_Flight_Protocol_FlightDescriptor.DescriptorType = .unknown - - /// - /// Opaque value used to express a command. Should only be defined when - /// type = CMD. - var cmd: Data = Data() - - /// - /// List of strings identifying a particular dataset. Should only be defined - /// when type = PATH. - var path: [String] = [] - - var unknownFields = SwiftProtobuf.UnknownStorage() - - /// - /// Describes what type of descriptor is defined. - enum DescriptorType: SwiftProtobuf.Enum { - typealias RawValue = Int - - /// Protobuf pattern, not used. - case unknown // = 0 - - /// - /// A named path that identifies a dataset. A path is composed of a string - /// or list of strings describing a particular dataset. This is conceptually - /// similar to a path inside a filesystem. - case path // = 1 - - /// - /// An opaque command to generate a dataset. - case cmd // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .unknown - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .unknown - case 1: self = .path - case 2: self = .cmd - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .unknown: return 0 - case .path: return 1 - case .cmd: return 2 - case .UNRECOGNIZED(let i): return i - } - } - - } - - init() {} -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_FlightDescriptor.DescriptorType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_FlightDescriptor.DescriptorType] = [ - .unknown, - .path, - .cmd, - ] -} - -#endif // swift(>=4.2) - -/// -/// The access coordinates for retrieval of a dataset. With a FlightInfo, a -/// consumer is able to determine how to retrieve a dataset. -struct Arrow_Flight_Protocol_FlightInfo { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The schema of the dataset in its IPC form: - /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix - /// 4 bytes - the byte length of the payload - /// a flatbuffer Message whose header is the Schema - var schema: Data = Data() - - /// - /// The descriptor associated with this info. - var flightDescriptor: Arrow_Flight_Protocol_FlightDescriptor { - get {return _flightDescriptor ?? Arrow_Flight_Protocol_FlightDescriptor()} - set {_flightDescriptor = newValue} - } - /// Returns true if `flightDescriptor` has been explicitly set. - var hasFlightDescriptor: Bool {return self._flightDescriptor != nil} - /// Clears the value of `flightDescriptor`. Subsequent reads from it will return its default value. - mutating func clearFlightDescriptor() {self._flightDescriptor = nil} - - /// - /// A list of endpoints associated with the flight. To consume the - /// whole flight, all endpoints (and hence all Tickets) must be - /// consumed. Endpoints can be consumed in any order. - /// - /// In other words, an application can use multiple endpoints to - /// represent partitioned data. - /// - /// If the returned data has an ordering, an application can use - /// "FlightInfo.ordered = true" or should return the all data in a - /// single endpoint. Otherwise, there is no ordering defined on - /// endpoints or the data within. - /// - /// A client can read ordered data by reading data from returned - /// endpoints, in order, from front to back. - /// - /// Note that a client may ignore "FlightInfo.ordered = true". If an - /// ordering is important for an application, an application must - /// choose one of them: - /// - /// * An application requires that all clients must read data in - /// returned endpoints order. - /// * An application must return the all data in a single endpoint. - var endpoint: [Arrow_Flight_Protocol_FlightEndpoint] = [] - - /// Set these to -1 if unknown. - var totalRecords: Int64 = 0 - - var totalBytes: Int64 = 0 - - /// - /// FlightEndpoints are in the same order as the data. - var ordered: Bool = false - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _flightDescriptor: Arrow_Flight_Protocol_FlightDescriptor? = nil -} - -/// -/// A particular stream or split associated with a flight. -struct Arrow_Flight_Protocol_FlightEndpoint { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Token used to retrieve this stream. - var ticket: Arrow_Flight_Protocol_Ticket { - get {return _ticket ?? Arrow_Flight_Protocol_Ticket()} - set {_ticket = newValue} - } - /// Returns true if `ticket` has been explicitly set. - var hasTicket: Bool {return self._ticket != nil} - /// Clears the value of `ticket`. Subsequent reads from it will return its default value. - mutating func clearTicket() {self._ticket = nil} - - /// - /// A list of URIs where this ticket can be redeemed via DoGet(). - /// - /// If the list is empty, the expectation is that the ticket can only - /// be redeemed on the current service where the ticket was - /// generated. - /// - /// If the list is not empty, the expectation is that the ticket can - /// be redeemed at any of the locations, and that the data returned - /// will be equivalent. In this case, the ticket may only be redeemed - /// at one of the given locations, and not (necessarily) on the - /// current service. - /// - /// In other words, an application can use multiple locations to - /// represent redundant and/or load balanced services. - var location: [Arrow_Flight_Protocol_Location] = [] - - /// - /// Expiration time of this stream. If present, clients may assume - /// they can retry DoGet requests. Otherwise, it is - /// application-defined whether DoGet requests may be retried. - var expirationTime: SwiftProtobuf.Google_Protobuf_Timestamp { - get {return _expirationTime ?? SwiftProtobuf.Google_Protobuf_Timestamp()} - set {_expirationTime = newValue} - } - /// Returns true if `expirationTime` has been explicitly set. - var hasExpirationTime: Bool {return self._expirationTime != nil} - /// Clears the value of `expirationTime`. Subsequent reads from it will return its default value. - mutating func clearExpirationTime() {self._expirationTime = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _ticket: Arrow_Flight_Protocol_Ticket? = nil - fileprivate var _expirationTime: SwiftProtobuf.Google_Protobuf_Timestamp? = nil -} - -/// -/// A location where a Flight service will accept retrieval of a particular -/// stream given a ticket. -struct Arrow_Flight_Protocol_Location { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var uri: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// An opaque identifier that the service can use to retrieve a particular -/// portion of a stream. -/// -/// Tickets are meant to be single use. It is an error/application-defined -/// behavior to reuse a ticket. -struct Arrow_Flight_Protocol_Ticket { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var ticket: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// A batch of Arrow data as part of a stream of batches. -struct Arrow_Flight_Protocol_FlightData { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// The descriptor of the data. This is only relevant when a client is - /// starting a new DoPut stream. - var flightDescriptor: Arrow_Flight_Protocol_FlightDescriptor { - get {return _flightDescriptor ?? Arrow_Flight_Protocol_FlightDescriptor()} - set {_flightDescriptor = newValue} - } - /// Returns true if `flightDescriptor` has been explicitly set. - var hasFlightDescriptor: Bool {return self._flightDescriptor != nil} - /// Clears the value of `flightDescriptor`. Subsequent reads from it will return its default value. - mutating func clearFlightDescriptor() {self._flightDescriptor = nil} - - /// - /// Header for message data as described in Message.fbs::Message. - var dataHeader: Data = Data() - - /// - /// Application-defined metadata. - var appMetadata: Data = Data() - - /// - /// The actual batch of Arrow data. Preferably handled with minimal-copies - /// coming last in the definition to help with sidecar patterns (it is - /// expected that some implementations will fetch this field off the wire - /// with specialized code to avoid extra memory copies). - var dataBody: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _flightDescriptor: Arrow_Flight_Protocol_FlightDescriptor? = nil -} - -///* -/// The response message associated with the submission of a DoPut. -struct Arrow_Flight_Protocol_PutResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var appMetadata: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -#if swift(>=5.5) && canImport(_Concurrency) -extension Arrow_Flight_Protocol_CancelStatus: @unchecked Sendable {} -extension Arrow_Flight_Protocol_HandshakeRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_HandshakeResponse: @unchecked Sendable {} -extension Arrow_Flight_Protocol_BasicAuth: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Empty: @unchecked Sendable {} -extension Arrow_Flight_Protocol_ActionType: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Criteria: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Action: @unchecked Sendable {} -extension Arrow_Flight_Protocol_CancelFlightInfoRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_RenewFlightEndpointRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Result: @unchecked Sendable {} -extension Arrow_Flight_Protocol_CancelFlightInfoResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_SchemaResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_FlightDescriptor: @unchecked Sendable {} -extension Arrow_Flight_Protocol_FlightDescriptor.DescriptorType: @unchecked Sendable {} -extension Arrow_Flight_Protocol_FlightInfo: @unchecked Sendable {} -extension Arrow_Flight_Protocol_FlightEndpoint: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Location: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Ticket: @unchecked Sendable {} -extension Arrow_Flight_Protocol_FlightData: @unchecked Sendable {} -extension Arrow_Flight_Protocol_PutResult: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "arrow.flight.protocol" - -extension Arrow_Flight_Protocol_CancelStatus: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "CANCEL_STATUS_UNSPECIFIED"), - 1: .same(proto: "CANCEL_STATUS_CANCELLED"), - 2: .same(proto: "CANCEL_STATUS_CANCELLING"), - 3: .same(proto: "CANCEL_STATUS_NOT_CANCELLABLE"), - ] -} - -extension Arrow_Flight_Protocol_HandshakeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".HandshakeRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "protocol_version"), - 2: .same(proto: "payload"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.protocolVersion) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.payload) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.protocolVersion != 0 { - try visitor.visitSingularUInt64Field(value: self.protocolVersion, fieldNumber: 1) - } - if !self.payload.isEmpty { - try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_HandshakeRequest, rhs: Arrow_Flight_Protocol_HandshakeRequest) -> Bool { - if lhs.protocolVersion != rhs.protocolVersion {return false} - if lhs.payload != rhs.payload {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_HandshakeResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".HandshakeResponse" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "protocol_version"), - 2: .same(proto: "payload"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.protocolVersion) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.payload) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.protocolVersion != 0 { - try visitor.visitSingularUInt64Field(value: self.protocolVersion, fieldNumber: 1) - } - if !self.payload.isEmpty { - try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_HandshakeResponse, rhs: Arrow_Flight_Protocol_HandshakeResponse) -> Bool { - if lhs.protocolVersion != rhs.protocolVersion {return false} - if lhs.payload != rhs.payload {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_BasicAuth: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".BasicAuth" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 2: .same(proto: "username"), - 3: .same(proto: "password"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 2: try { try decoder.decodeSingularStringField(value: &self.username) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.password) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.username.isEmpty { - try visitor.visitSingularStringField(value: self.username, fieldNumber: 2) - } - if !self.password.isEmpty { - try visitor.visitSingularStringField(value: self.password, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_BasicAuth, rhs: Arrow_Flight_Protocol_BasicAuth) -> Bool { - if lhs.username != rhs.username {return false} - if lhs.password != rhs.password {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Empty: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Empty" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Empty, rhs: Arrow_Flight_Protocol_Empty) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_ActionType: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionType" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .same(proto: "description"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.description_p) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if !self.description_p.isEmpty { - try visitor.visitSingularStringField(value: self.description_p, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_ActionType, rhs: Arrow_Flight_Protocol_ActionType) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.description_p != rhs.description_p {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Criteria: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Criteria" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "expression"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.expression) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.expression.isEmpty { - try visitor.visitSingularBytesField(value: self.expression, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Criteria, rhs: Arrow_Flight_Protocol_Criteria) -> Bool { - if lhs.expression != rhs.expression {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Action: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Action" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .same(proto: "body"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.body) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if !self.body.isEmpty { - try visitor.visitSingularBytesField(value: self.body, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Action, rhs: Arrow_Flight_Protocol_Action) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.body != rhs.body {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_CancelFlightInfoRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CancelFlightInfoRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "info"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._info) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._info { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_CancelFlightInfoRequest, rhs: Arrow_Flight_Protocol_CancelFlightInfoRequest) -> Bool { - if lhs._info != rhs._info {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_RenewFlightEndpointRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RenewFlightEndpointRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "endpoint"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._endpoint) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._endpoint { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_RenewFlightEndpointRequest, rhs: Arrow_Flight_Protocol_RenewFlightEndpointRequest) -> Bool { - if lhs._endpoint != rhs._endpoint {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Result" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "body"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.body) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.body.isEmpty { - try visitor.visitSingularBytesField(value: self.body, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Result, rhs: Arrow_Flight_Protocol_Result) -> Bool { - if lhs.body != rhs.body {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_CancelFlightInfoResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CancelFlightInfoResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.status != .unspecified { - try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_CancelFlightInfoResult, rhs: Arrow_Flight_Protocol_CancelFlightInfoResult) -> Bool { - if lhs.status != rhs.status {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_SchemaResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SchemaResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "schema"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.schema) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.schema.isEmpty { - try visitor.visitSingularBytesField(value: self.schema, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_SchemaResult, rhs: Arrow_Flight_Protocol_SchemaResult) -> Bool { - if lhs.schema != rhs.schema {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_FlightDescriptor: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".FlightDescriptor" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .same(proto: "cmd"), - 3: .same(proto: "path"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.type) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.cmd) }() - case 3: try { try decoder.decodeRepeatedStringField(value: &self.path) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.type != .unknown { - try visitor.visitSingularEnumField(value: self.type, fieldNumber: 1) - } - if !self.cmd.isEmpty { - try visitor.visitSingularBytesField(value: self.cmd, fieldNumber: 2) - } - if !self.path.isEmpty { - try visitor.visitRepeatedStringField(value: self.path, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_FlightDescriptor, rhs: Arrow_Flight_Protocol_FlightDescriptor) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.cmd != rhs.cmd {return false} - if lhs.path != rhs.path {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_FlightDescriptor.DescriptorType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "UNKNOWN"), - 1: .same(proto: "PATH"), - 2: .same(proto: "CMD"), - ] -} - -extension Arrow_Flight_Protocol_FlightInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".FlightInfo" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "schema"), - 2: .standard(proto: "flight_descriptor"), - 3: .same(proto: "endpoint"), - 4: .standard(proto: "total_records"), - 5: .standard(proto: "total_bytes"), - 6: .same(proto: "ordered"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.schema) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._flightDescriptor) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.endpoint) }() - case 4: try { try decoder.decodeSingularInt64Field(value: &self.totalRecords) }() - case 5: try { try decoder.decodeSingularInt64Field(value: &self.totalBytes) }() - case 6: try { try decoder.decodeSingularBoolField(value: &self.ordered) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.schema.isEmpty { - try visitor.visitSingularBytesField(value: self.schema, fieldNumber: 1) - } - try { if let v = self._flightDescriptor { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !self.endpoint.isEmpty { - try visitor.visitRepeatedMessageField(value: self.endpoint, fieldNumber: 3) - } - if self.totalRecords != 0 { - try visitor.visitSingularInt64Field(value: self.totalRecords, fieldNumber: 4) - } - if self.totalBytes != 0 { - try visitor.visitSingularInt64Field(value: self.totalBytes, fieldNumber: 5) - } - if self.ordered != false { - try visitor.visitSingularBoolField(value: self.ordered, fieldNumber: 6) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_FlightInfo, rhs: Arrow_Flight_Protocol_FlightInfo) -> Bool { - if lhs.schema != rhs.schema {return false} - if lhs._flightDescriptor != rhs._flightDescriptor {return false} - if lhs.endpoint != rhs.endpoint {return false} - if lhs.totalRecords != rhs.totalRecords {return false} - if lhs.totalBytes != rhs.totalBytes {return false} - if lhs.ordered != rhs.ordered {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_FlightEndpoint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".FlightEndpoint" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "ticket"), - 2: .same(proto: "location"), - 3: .standard(proto: "expiration_time"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._ticket) }() - case 2: try { try decoder.decodeRepeatedMessageField(value: &self.location) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._expirationTime) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._ticket { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - if !self.location.isEmpty { - try visitor.visitRepeatedMessageField(value: self.location, fieldNumber: 2) - } - try { if let v = self._expirationTime { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_FlightEndpoint, rhs: Arrow_Flight_Protocol_FlightEndpoint) -> Bool { - if lhs._ticket != rhs._ticket {return false} - if lhs.location != rhs.location {return false} - if lhs._expirationTime != rhs._expirationTime {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Location" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "uri"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.uri) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.uri.isEmpty { - try visitor.visitSingularStringField(value: self.uri, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Location, rhs: Arrow_Flight_Protocol_Location) -> Bool { - if lhs.uri != rhs.uri {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Ticket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Ticket" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "ticket"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.ticket) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.ticket.isEmpty { - try visitor.visitSingularBytesField(value: self.ticket, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Ticket, rhs: Arrow_Flight_Protocol_Ticket) -> Bool { - if lhs.ticket != rhs.ticket {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_FlightData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".FlightData" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "flight_descriptor"), - 2: .standard(proto: "data_header"), - 3: .standard(proto: "app_metadata"), - 1000: .standard(proto: "data_body"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._flightDescriptor) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.dataHeader) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.appMetadata) }() - case 1000: try { try decoder.decodeSingularBytesField(value: &self.dataBody) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._flightDescriptor { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - if !self.dataHeader.isEmpty { - try visitor.visitSingularBytesField(value: self.dataHeader, fieldNumber: 2) - } - if !self.appMetadata.isEmpty { - try visitor.visitSingularBytesField(value: self.appMetadata, fieldNumber: 3) - } - if !self.dataBody.isEmpty { - try visitor.visitSingularBytesField(value: self.dataBody, fieldNumber: 1000) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_FlightData, rhs: Arrow_Flight_Protocol_FlightData) -> Bool { - if lhs._flightDescriptor != rhs._flightDescriptor {return false} - if lhs.dataHeader != rhs.dataHeader {return false} - if lhs.appMetadata != rhs.appMetadata {return false} - if lhs.dataBody != rhs.dataBody {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_PutResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".PutResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "app_metadata"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.appMetadata) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.appMetadata.isEmpty { - try visitor.visitSingularBytesField(value: self.appMetadata, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_PutResult, rhs: Arrow_Flight_Protocol_PutResult) -> Bool { - if lhs.appMetadata != rhs.appMetadata {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightAction.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightAction.swift deleted file mode 100644 index 8db12aaa99f..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightAction.swift +++ /dev/null @@ -1,39 +0,0 @@ -// 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 Foundation - -public class FlightAction { - public let type: String - public let body: Data - init(_ action: Arrow_Flight_Protocol_Action) { - self.type = action.type - self.body = action.body - } - - public init(_ type: String, body: Data = Data()) { - self.type = type - self.body = body - } - - func toProtocol() -> Arrow_Flight_Protocol_Action { - var flightAction = Arrow_Flight_Protocol_Action() - flightAction.type = self.type - flightAction.body = self.body - return flightAction - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightActionType.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightActionType.swift deleted file mode 100644 index 0b4778c6864..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightActionType.swift +++ /dev/null @@ -1,38 +0,0 @@ -// 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 Foundation -public class FlightActionType { - public let type: String - public let description: String - init(_ actionType: Arrow_Flight_Protocol_ActionType) { - self.type = actionType.type - self.description = actionType.description_p - - } - public init(_ type: String, description: String) { - self.type = type - self.description = description - } - - func toProtocol() -> Arrow_Flight_Protocol_ActionType { - var actionType = Arrow_Flight_Protocol_ActionType() - actionType.type = self.type - actionType.description_p = self.description - return actionType - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightClient.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightClient.swift deleted file mode 100644 index ef3e4fa239e..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightClient.swift +++ /dev/null @@ -1,187 +0,0 @@ -// 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 struct Foundation.Data -import struct Foundation.URL -import GRPC -import NIOCore -import NIOPosix -import Arrow - -public class FlightClient { - let client: Arrow_Flight_Protocol_FlightServiceAsyncClient - let allowReadingUnalignedBuffers: Bool - - public init(channel: GRPCChannel, allowReadingUnalignedBuffers: Bool = false ) { - client = Arrow_Flight_Protocol_FlightServiceAsyncClient(channel: channel) - self.allowReadingUnalignedBuffers = allowReadingUnalignedBuffers - } - - private func readMessages( - _ responseStream: GRPCAsyncResponseStream - ) async throws -> ArrowReader.ArrowReaderResult { - let reader = ArrowReader() - let arrowResult = ArrowReader.makeArrowReaderResult() - for try await data in responseStream { - switch reader.fromMessage( - data.dataHeader, - dataBody: data.dataBody, - result: arrowResult, - useUnalignedBuffers: allowReadingUnalignedBuffers) { - case .success: - continue - case .failure(let error): - throw error - } - } - - return arrowResult - } - - private func writeBatches( - _ requestStream: GRPCAsyncRequestStreamWriter, - descriptor: FlightDescriptor, - recordBatches: [RecordBatch] - ) async throws { - let writer = ArrowWriter() - switch writer.toMessage(recordBatches[0].schema) { - case .success(let schemaData): - try await requestStream.send( - FlightData( - schemaData, - dataBody: Data(), - flightDescriptor: descriptor).toProtocol()) - for recordBatch in recordBatches { - switch writer.toMessage(recordBatch) { - case .success(let data): - try await requestStream.send( - FlightData( - data[0], - dataBody: data[1], - flightDescriptor: descriptor).toProtocol()) - case .failure(let error): - throw error - } - } - requestStream.finish() - case .failure(let error): - throw error - } - } - - public func listActions(_ closure: (FlightActionType) -> Void) async throws { - let listActions = client.makeListActionsCall(Arrow_Flight_Protocol_Empty()) - for try await data in listActions.responseStream { - closure(FlightActionType(data)) - } - } - - public func listFlights( - _ criteria: FlightCriteria, - closure: (FlightInfo) throws -> Void) async throws { - let listFlights = client.makeListFlightsCall(criteria.toProtocol()) - for try await data in listFlights.responseStream { - try closure(FlightInfo(data)) - } - } - - public func doAction(_ action: FlightAction, closure: (FlightResult) throws -> Void) async throws { - let actionResponse = client.makeDoActionCall(action.toProtocol()) - for try await data in actionResponse.responseStream { - try closure(FlightResult(data)) - } - } - - public func getSchema(_ descriptor: FlightDescriptor) async throws -> FlightSchemaResult { - let schemaResultResponse = client.makeGetSchemaCall(descriptor.toProtocol()) - return FlightSchemaResult(try await schemaResultResponse.response) - } - - public func doGet( - _ ticket: FlightTicket, - readerResultClosure: (ArrowReader.ArrowReaderResult) throws -> Void) async throws { - let getResult = client.makeDoGetCall(ticket.toProtocol()) - try readerResultClosure(try await readMessages(getResult.responseStream)) - } - - public func doGet( - _ ticket: FlightTicket, - flightDataClosure: (FlightData) throws -> Void) async throws { - let getResult = client.makeDoGetCall(ticket.toProtocol()) - for try await data in getResult.responseStream { - try flightDataClosure(FlightData(data)) - } - } - - public func doPut( - _ descriptor: FlightDescriptor, - recordBatches: [RecordBatch], - closure: (FlightPutResult) throws -> Void) async throws { - if recordBatches.isEmpty { - throw ArrowFlightError.emptyCollection - } - - let putCall = client.makeDoPutCall() - try await writeBatches(putCall.requestStream, descriptor: descriptor, recordBatches: recordBatches) - var closureCalled = false - for try await response in putCall.responseStream { - try closure(FlightPutResult(response)) - closureCalled = true - } - - if !closureCalled { - try closure(FlightPutResult()) - } - } - - public func doPut(_ flightData: FlightData, closure: (FlightPutResult) throws -> Void) async throws { - let putCall = client.makeDoPutCall() - try await putCall.requestStream.send(flightData.toProtocol()) - putCall.requestStream.finish() - var closureCalled = false - for try await response in putCall.responseStream { - try closure(FlightPutResult(response)) - closureCalled = true - } - - if !closureCalled { - try closure(FlightPutResult()) - } - } - - public func doExchange( - _ descriptor: FlightDescriptor, - recordBatches: [RecordBatch], - closure: (ArrowReader.ArrowReaderResult) throws -> Void) async throws { - if recordBatches.isEmpty { - throw ArrowFlightError.emptyCollection - } - - let exchangeCall = client.makeDoExchangeCall() - try await writeBatches(exchangeCall.requestStream, descriptor: descriptor, recordBatches: recordBatches) - try closure(try await readMessages(exchangeCall.responseStream)) - } - - public func doExchange(flightData: FlightData, closure: (FlightData) throws -> Void) async throws { - let exchangeCall = client.makeDoExchangeCall() - try await exchangeCall.requestStream.send(flightData.toProtocol()) - exchangeCall.requestStream.finish() - for try await response in exchangeCall.responseStream { - try closure(FlightData(response)) - } - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightCriteria.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightCriteria.swift deleted file mode 100644 index 2d02959998c..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightCriteria.swift +++ /dev/null @@ -1,37 +0,0 @@ -// 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 Foundation - -public class FlightCriteria { - let criteria: Arrow_Flight_Protocol_Criteria - - public var expression: Data { criteria.expression } - public init(_ expression: Data = Data()) { - criteria = Arrow_Flight_Protocol_Criteria.with { - $0.expression = expression - } - } - - init(_ criteria: Arrow_Flight_Protocol_Criteria) { - self.criteria = criteria - } - - func toProtocol() -> Arrow_Flight_Protocol_Criteria { - return criteria - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightData.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightData.swift deleted file mode 100644 index 84db8c57183..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightData.swift +++ /dev/null @@ -1,49 +0,0 @@ -// 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 Foundation - -public class FlightData { - let flightData: Arrow_Flight_Protocol_FlightData - public var flightDescriptor: FlightDescriptor? { - return flightData.hasFlightDescriptor ? FlightDescriptor(flightData.flightDescriptor) : nil - } - - public var dataHeader: Data { flightData.dataHeader } - - public var dataBody: Data { flightData.dataBody } - - init(_ flightData: Arrow_Flight_Protocol_FlightData) { - self.flightData = flightData - } - - public init(_ dataHeader: Data, dataBody: Data, flightDescriptor: FlightDescriptor? = nil) { - if flightDescriptor != nil { - self.flightData = Arrow_Flight_Protocol_FlightData.with { - $0.dataHeader = dataHeader - $0.dataBody = dataBody - $0.flightDescriptor = flightDescriptor!.toProtocol() - } - } else { - self.flightData = Arrow_Flight_Protocol_FlightData.with { - $0.dataBody = dataBody - } - } - } - - func toProtocol() -> Arrow_Flight_Protocol_FlightData { self.flightData } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightDescriptor.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightDescriptor.swift deleted file mode 100644 index 02712aaa099..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightDescriptor.swift +++ /dev/null @@ -1,56 +0,0 @@ -// 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 Foundation - -public class FlightDescriptor { - public enum DescriptorType { - case unknown - case path - case cmd - } - - public let type: FlightDescriptor.DescriptorType - public let cmd: Data - public let paths: [String] - - init(_ descriptor: Arrow_Flight_Protocol_FlightDescriptor) { - self.type = descriptor.type == .cmd ? .cmd : .path - self.cmd = descriptor.cmd - self.paths = descriptor.path - } - - public init(cmd: Data) { - self.type = .cmd - self.cmd = cmd - self.paths = [String]() - } - - public init(paths: [String]) { - self.type = .path - self.cmd = Data() - self.paths = paths - } - - func toProtocol() -> Arrow_Flight_Protocol_FlightDescriptor { - var descriptor = Arrow_Flight_Protocol_FlightDescriptor() - descriptor.type = self.type == .cmd ? .cmd : .path - descriptor.cmd = self.cmd - descriptor.path = self.paths - return descriptor - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightEndpoint.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightEndpoint.swift deleted file mode 100644 index 0493772781a..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightEndpoint.swift +++ /dev/null @@ -1,38 +0,0 @@ -// 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 Foundation -public class FlightEndpoint { - let ticket: FlightTicket - let locations: [FlightLocation] - init(_ endpoint: Arrow_Flight_Protocol_FlightEndpoint) { - self.ticket = FlightTicket(endpoint.ticket.ticket) - self.locations = endpoint.location.map {return FlightLocation($0)} - } - - public init(_ ticket: FlightTicket, locations: [FlightLocation]) { - self.ticket = ticket - self.locations = locations - } - - func toProtocol() -> Arrow_Flight_Protocol_FlightEndpoint { - var endpoint = Arrow_Flight_Protocol_FlightEndpoint() - endpoint.ticket = self.ticket.toProtocol() - endpoint.location = self.locations.map { $0.toProtocol() } - return endpoint - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightInfo.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightInfo.swift deleted file mode 100644 index eb43aa34caf..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightInfo.swift +++ /dev/null @@ -1,57 +0,0 @@ -// 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 Foundation -import Arrow - -public class FlightInfo { - let flightInfo: Arrow_Flight_Protocol_FlightInfo - public var flightDescriptor: FlightDescriptor? { - return flightInfo.hasFlightDescriptor ? FlightDescriptor(flightInfo.flightDescriptor) : nil - } - - public var endpoints: [FlightEndpoint] { - return self.flightInfo.endpoint.map { FlightEndpoint($0) } - } - public var schema: ArrowSchema? { - return schemaFromMessage(self.flightInfo.schema) - } - - var endpoint: [Arrow_Flight_Protocol_FlightEndpoint] = [] - init(_ flightInfo: Arrow_Flight_Protocol_FlightInfo) { - self.flightInfo = flightInfo - } - - public init(_ schema: Data, endpoints: [FlightEndpoint] = [FlightEndpoint](), descriptor: FlightDescriptor? = nil) { - if let localDescriptor = descriptor { - self.flightInfo = Arrow_Flight_Protocol_FlightInfo.with { - $0.schema = schema - $0.flightDescriptor = localDescriptor.toProtocol() - $0.endpoint = endpoints.map { $0.toProtocol() } - } - } else { - self.flightInfo = Arrow_Flight_Protocol_FlightInfo.with { - $0.schema = schema - $0.endpoint = endpoints.map { $0.toProtocol() } - } - } - } - - func toProtocol() -> Arrow_Flight_Protocol_FlightInfo { - return self.flightInfo - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightLocation.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightLocation.swift deleted file mode 100644 index 9c89d100336..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightLocation.swift +++ /dev/null @@ -1,36 +0,0 @@ -// 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 Foundation - -public class FlightLocation { - public let uri: String - - init(_ location: Arrow_Flight_Protocol_Location) { - self.uri = location.uri - } - - public init(_ uri: String) { - self.uri = uri - } - - func toProtocol() -> Arrow_Flight_Protocol_Location { - var location = Arrow_Flight_Protocol_Location() - location.uri = uri - return location - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightPutResult.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightPutResult.swift deleted file mode 100644 index 3b22f8f0baf..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightPutResult.swift +++ /dev/null @@ -1,35 +0,0 @@ -// 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 Foundation - -public class FlightPutResult { - public let appMetadata: Data - public init(_ appMetadata: Data = Data()) { - self.appMetadata = appMetadata - } - - init(_ putResult: Arrow_Flight_Protocol_PutResult) { - self.appMetadata = putResult.appMetadata - } - - func toProtocol() -> Arrow_Flight_Protocol_PutResult { - var putResult = Arrow_Flight_Protocol_PutResult() - putResult.appMetadata = self.appMetadata - return putResult - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightResult.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightResult.swift deleted file mode 100644 index d7cf828b963..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightResult.swift +++ /dev/null @@ -1,35 +0,0 @@ -// 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 Foundation - -public class FlightResult { - public let body: Data - init(_ result: Arrow_Flight_Protocol_Result) { - self.body = result.body - } - - public init(_ body: Data) { - self.body = body - } - - func toProtocol() -> Arrow_Flight_Protocol_Result { - var result = Arrow_Flight_Protocol_Result() - result.body = self.body - return result - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightSchemaResult.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightSchemaResult.swift deleted file mode 100644 index 7dea98a9988..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightSchemaResult.swift +++ /dev/null @@ -1,41 +0,0 @@ -// 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 Foundation -import Arrow - -public class FlightSchemaResult { - let schemaResult: Arrow_Flight_Protocol_SchemaResult - - public var schema: ArrowSchema? { - return schemaFromMessage(self.schemaResult.schema) - } - - public init(_ schema: Data) { - self.schemaResult = Arrow_Flight_Protocol_SchemaResult.with { - $0.schema = schema - } - } - - init(_ schemaResult: Arrow_Flight_Protocol_SchemaResult) { - self.schemaResult = schemaResult - } - - func toProtocol() -> Arrow_Flight_Protocol_SchemaResult { - return schemaResult - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightServer.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightServer.swift deleted file mode 100644 index 19644d632e9..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightServer.swift +++ /dev/null @@ -1,194 +0,0 @@ -// 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 Foundation -import GRPC -import NIO -import NIOConcurrencyHelpers -import SwiftProtobuf -import Arrow - -public enum ArrowFlightError: Error { - case unknown(String?) - case notImplemented(String? = nil) - case emptyCollection - case ioError(String? = nil) -} - -public func schemaToMessage(_ schema: ArrowSchema) throws -> Data { - let arrowWriter = ArrowWriter() - switch arrowWriter.toMessage(schema) { - case .success(let result): - var outputResult = Data() - withUnsafeBytes(of: Int32(0).littleEndian) {outputResult.append(Data($0))} - withUnsafeBytes(of: Int32(result.count).littleEndian) {outputResult.append(Data($0))} - outputResult.append(result) - return outputResult - case .failure(let error): - throw error - } -} - -public func schemaFromMessage(_ schemaData: Data) -> ArrowSchema? { - let messageLength = schemaData.withUnsafeBytes { rawBuffer in - rawBuffer.loadUnaligned(fromByteOffset: 4, as: Int32.self) - } - - let startIndex = schemaData.count - Int(messageLength) - let schema = schemaData[startIndex...] - - let reader = ArrowReader() - let result = ArrowReader.makeArrowReaderResult() - switch reader.fromMessage(schema, dataBody: Data(), result: result) { - case .success: - return result.schema! - case .failure: - // TODO: add handling of error swiftlint:disable:this todo - return nil - } -} - -public protocol ArrowFlightServer: Sendable { - var allowReadingUnalignedBuffers: Bool { get } - func listFlights(_ criteria: FlightCriteria, writer: FlightInfoStreamWriter) async throws - func getFlightInfo(_ request: FlightDescriptor) async throws -> FlightInfo - func getSchema(_ request: FlightDescriptor) async throws -> ArrowFlight.FlightSchemaResult - func listActions(_ writer: ActionTypeStreamWriter) async throws - func doAction(_ action: FlightAction, writer: ResultStreamWriter) async throws - func doGet(_ ticket: FlightTicket, writer: RecordBatchStreamWriter) async throws - func doPut(_ reader: RecordBatchStreamReader, writer: PutResultDataStreamWriter) async throws - func doExchange(_ reader: RecordBatchStreamReader, writer: RecordBatchStreamWriter) async throws -} - -extension ArrowFlightServer { - var allowReadingUnalignedBuffers: Bool { - return false - } -} - -public func makeFlightServer(_ handler: ArrowFlightServer) -> CallHandlerProvider { - return InternalFlightServer(handler) -} - -internal final class InternalFlightServer: Arrow_Flight_Protocol_FlightServiceAsyncProvider { - let arrowFlightServer: ArrowFlightServer? - - init(_ arrowFlightServer: ArrowFlightServer?) { - self.arrowFlightServer = arrowFlightServer - } - - func handshake(requestStream: GRPC.GRPCAsyncRequestStream, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - throw ArrowFlightError.notImplemented() - } - - func listFlights(request: Arrow_Flight_Protocol_Criteria, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - let writer = FlightInfoStreamWriter(responseStream) - try await server.listFlights(FlightCriteria(request), writer: writer) - return - } - - throw ArrowFlightError.notImplemented() - } - - func getFlightInfo(request: Arrow_Flight_Protocol_FlightDescriptor, - context: GRPC.GRPCAsyncServerCallContext) async throws -> Arrow_Flight_Protocol_FlightInfo { - if let server = arrowFlightServer { - return try await server.getFlightInfo(FlightDescriptor(request)).toProtocol() - } - - throw ArrowFlightError.notImplemented() - } - - func getSchema(request: Arrow_Flight_Protocol_FlightDescriptor, - context: GRPC.GRPCAsyncServerCallContext) async throws -> Arrow_Flight_Protocol_SchemaResult { - if let server = arrowFlightServer { - return try await server.getSchema(FlightDescriptor(request)).toProtocol() - } - - throw ArrowFlightError.notImplemented() - } - - func doGet(request: Arrow_Flight_Protocol_Ticket, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - let writer = RecordBatchStreamWriter(responseStream) - let ticket = FlightTicket(request) - try await server.doGet(ticket, writer: writer) - return - } - - throw ArrowFlightError.notImplemented() - } - - func doPut(requestStream: GRPC.GRPCAsyncRequestStream, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - let reader = RecordBatchStreamReader(requestStream) - let writer = PutResultDataStreamWriter(responseStream) - try await server.doPut(reader, writer: writer) - return - } - - throw ArrowFlightError.notImplemented() - } - - func doExchange(requestStream: GRPC.GRPCAsyncRequestStream, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - let reader = RecordBatchStreamReader(requestStream) - let writer = RecordBatchStreamWriter(responseStream) - try await server.doExchange(reader, writer: writer) - return - } - - throw ArrowFlightError.notImplemented() - } - - func doAction(request: Arrow_Flight_Protocol_Action, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - try await server.doAction(FlightAction(request), writer: ResultStreamWriter(responseStream)) - return - } - - throw ArrowFlightError.notImplemented() - } - - func listActions(request: Arrow_Flight_Protocol_Empty, - responseStream: GRPC.GRPCAsyncResponseStreamWriter, - context: GRPC.GRPCAsyncServerCallContext) async throws { - if let server = arrowFlightServer { - let writer = ActionTypeStreamWriter(responseStream) - try await server.listActions(writer) - return - } - - throw ArrowFlightError.notImplemented() - } - - internal var interceptors: Arrow_Flight_Protocol_FlightServiceServerInterceptorFactoryProtocol? { return nil } - -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightSql.pb.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightSql.pb.swift deleted file mode 100644 index 18b839fcbc0..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightSql.pb.swift +++ /dev/null @@ -1,5145 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: FlightSql.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -// -// 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 Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -/// Options for CommandGetSqlInfo. -enum Arrow_Flight_Protocol_Sql_SqlInfo: SwiftProtobuf.Enum { - typealias RawValue = Int - - /// Retrieves a UTF-8 string with the name of the Flight SQL Server. - case flightSqlServerName // = 0 - - /// Retrieves a UTF-8 string with the native version of the Flight SQL Server. - case flightSqlServerVersion // = 1 - - /// Retrieves a UTF-8 string with the Arrow format version of the Flight SQL Server. - case flightSqlServerArrowVersion // = 2 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server is read only. - /// - /// Returns: - /// - false: if read-write - /// - true: if read only - case flightSqlServerReadOnly // = 3 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server supports executing - /// SQL queries. - /// - /// Note that the absence of this info (as opposed to a false value) does not necessarily - /// mean that SQL is not supported, as this property was not originally defined. - case flightSqlServerSql // = 4 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server supports executing - /// Substrait plans. - case flightSqlServerSubstrait // = 5 - - /// - /// Retrieves a string value indicating the minimum supported Substrait version, or null - /// if Substrait is not supported. - case flightSqlServerSubstraitMinVersion // = 6 - - /// - /// Retrieves a string value indicating the maximum supported Substrait version, or null - /// if Substrait is not supported. - case flightSqlServerSubstraitMaxVersion // = 7 - - /// - /// Retrieves an int32 indicating whether the Flight SQL Server supports the - /// BeginTransaction/EndTransaction/BeginSavepoint/EndSavepoint actions. - /// - /// Even if this is not supported, the database may still support explicit "BEGIN - /// TRANSACTION"/"COMMIT" SQL statements (see SQL_TRANSACTIONS_SUPPORTED); this property - /// is only about whether the server implements the Flight SQL API endpoints. - /// - /// The possible values are listed in `SqlSupportedTransaction`. - case flightSqlServerTransaction // = 8 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server supports explicit - /// query cancellation (the CancelQuery action). - case flightSqlServerCancel // = 9 - - /// - /// Retrieves an int32 indicating the timeout (in milliseconds) for prepared statement handles. - /// - /// If 0, there is no timeout. Servers should reset the timeout when the handle is used in a command. - case flightSqlServerStatementTimeout // = 100 - - /// - /// Retrieves an int32 indicating the timeout (in milliseconds) for transactions, since transactions are not tied to a connection. - /// - /// If 0, there is no timeout. Servers should reset the timeout when the handle is used in a command. - case flightSqlServerTransactionTimeout // = 101 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server supports CREATE and DROP of catalogs. - /// - /// Returns: - /// - false: if it doesn't support CREATE and DROP of catalogs. - /// - true: if it supports CREATE and DROP of catalogs. - case sqlDdlCatalog // = 500 - - /// - /// Retrieves a boolean value indicating whether the Flight SQL Server supports CREATE and DROP of schemas. - /// - /// Returns: - /// - false: if it doesn't support CREATE and DROP of schemas. - /// - true: if it supports CREATE and DROP of schemas. - case sqlDdlSchema // = 501 - - /// - /// Indicates whether the Flight SQL Server supports CREATE and DROP of tables. - /// - /// Returns: - /// - false: if it doesn't support CREATE and DROP of tables. - /// - true: if it supports CREATE and DROP of tables. - case sqlDdlTable // = 502 - - /// - /// Retrieves a int32 ordinal representing the case sensitivity of catalog, table, schema and table names. - /// - /// The possible values are listed in `arrow.flight.protocol.sql.SqlSupportedCaseSensitivity`. - case sqlIdentifierCase // = 503 - - /// Retrieves a UTF-8 string with the supported character(s) used to surround a delimited identifier. - case sqlIdentifierQuoteChar // = 504 - - /// - /// Retrieves a int32 describing the case sensitivity of quoted identifiers. - /// - /// The possible values are listed in `arrow.flight.protocol.sql.SqlSupportedCaseSensitivity`. - case sqlQuotedIdentifierCase // = 505 - - /// - /// Retrieves a boolean value indicating whether all tables are selectable. - /// - /// Returns: - /// - false: if not all tables are selectable or if none are; - /// - true: if all tables are selectable. - case sqlAllTablesAreSelectable // = 506 - - /// - /// Retrieves the null ordering. - /// - /// Returns a int32 ordinal for the null ordering being used, as described in - /// `arrow.flight.protocol.sql.SqlNullOrdering`. - case sqlNullOrdering // = 507 - - /// Retrieves a UTF-8 string list with values of the supported keywords. - case sqlKeywords // = 508 - - /// Retrieves a UTF-8 string list with values of the supported numeric functions. - case sqlNumericFunctions // = 509 - - /// Retrieves a UTF-8 string list with values of the supported string functions. - case sqlStringFunctions // = 510 - - /// Retrieves a UTF-8 string list with values of the supported system functions. - case sqlSystemFunctions // = 511 - - /// Retrieves a UTF-8 string list with values of the supported datetime functions. - case sqlDatetimeFunctions // = 512 - - /// - /// Retrieves the UTF-8 string that can be used to escape wildcard characters. - /// This is the string that can be used to escape '_' or '%' in the catalog search parameters that are a pattern - /// (and therefore use one of the wildcard characters). - /// The '_' character represents any single character; the '%' character represents any sequence of zero or more - /// characters. - case sqlSearchStringEscape // = 513 - - /// - /// Retrieves a UTF-8 string with all the "extra" characters that can be used in unquoted identifier names - /// (those beyond a-z, A-Z, 0-9 and _). - case sqlExtraNameCharacters // = 514 - - /// - /// Retrieves a boolean value indicating whether column aliasing is supported. - /// If so, the SQL AS clause can be used to provide names for computed columns or to provide alias names for columns - /// as required. - /// - /// Returns: - /// - false: if column aliasing is unsupported; - /// - true: if column aliasing is supported. - case sqlSupportsColumnAliasing // = 515 - - /// - /// Retrieves a boolean value indicating whether concatenations between null and non-null values being - /// null are supported. - /// - /// - Returns: - /// - false: if concatenations between null and non-null values being null are unsupported; - /// - true: if concatenations between null and non-null values being null are supported. - case sqlNullPlusNullIsNull // = 516 - - /// - /// Retrieves a map where the key is the type to convert from and the value is a list with the types to convert to, - /// indicating the supported conversions. Each key and each item on the list value is a value to a predefined type on - /// SqlSupportsConvert enum. - /// The returned map will be: map> - case sqlSupportsConvert // = 517 - - /// - /// Retrieves a boolean value indicating whether, when table correlation names are supported, - /// they are restricted to being different from the names of the tables. - /// - /// Returns: - /// - false: if table correlation names are unsupported; - /// - true: if table correlation names are supported. - case sqlSupportsTableCorrelationNames // = 518 - - /// - /// Retrieves a boolean value indicating whether, when table correlation names are supported, - /// they are restricted to being different from the names of the tables. - /// - /// Returns: - /// - false: if different table correlation names are unsupported; - /// - true: if different table correlation names are supported - case sqlSupportsDifferentTableCorrelationNames // = 519 - - /// - /// Retrieves a boolean value indicating whether expressions in ORDER BY lists are supported. - /// - /// Returns: - /// - false: if expressions in ORDER BY are unsupported; - /// - true: if expressions in ORDER BY are supported; - case sqlSupportsExpressionsInOrderBy // = 520 - - /// - /// Retrieves a boolean value indicating whether using a column that is not in the SELECT statement in a GROUP BY - /// clause is supported. - /// - /// Returns: - /// - false: if using a column that is not in the SELECT statement in a GROUP BY clause is unsupported; - /// - true: if using a column that is not in the SELECT statement in a GROUP BY clause is supported. - case sqlSupportsOrderByUnrelated // = 521 - - /// - /// Retrieves the supported GROUP BY commands; - /// - /// Returns an int32 bitmask value representing the supported commands. - /// The returned bitmask should be parsed in order to retrieve the supported commands. - /// - /// For instance: - /// - return 0 (\b0) => [] (GROUP BY is unsupported); - /// - return 1 (\b1) => [SQL_GROUP_BY_UNRELATED]; - /// - return 2 (\b10) => [SQL_GROUP_BY_BEYOND_SELECT]; - /// - return 3 (\b11) => [SQL_GROUP_BY_UNRELATED, SQL_GROUP_BY_BEYOND_SELECT]. - /// Valid GROUP BY types are described under `arrow.flight.protocol.sql.SqlSupportedGroupBy`. - case sqlSupportedGroupBy // = 522 - - /// - /// Retrieves a boolean value indicating whether specifying a LIKE escape clause is supported. - /// - /// Returns: - /// - false: if specifying a LIKE escape clause is unsupported; - /// - true: if specifying a LIKE escape clause is supported. - case sqlSupportsLikeEscapeClause // = 523 - - /// - /// Retrieves a boolean value indicating whether columns may be defined as non-nullable. - /// - /// Returns: - /// - false: if columns cannot be defined as non-nullable; - /// - true: if columns may be defined as non-nullable. - case sqlSupportsNonNullableColumns // = 524 - - /// - /// Retrieves the supported SQL grammar level as per the ODBC specification. - /// - /// Returns an int32 bitmask value representing the supported SQL grammar level. - /// The returned bitmask should be parsed in order to retrieve the supported grammar levels. - /// - /// For instance: - /// - return 0 (\b0) => [] (SQL grammar is unsupported); - /// - return 1 (\b1) => [SQL_MINIMUM_GRAMMAR]; - /// - return 2 (\b10) => [SQL_CORE_GRAMMAR]; - /// - return 3 (\b11) => [SQL_MINIMUM_GRAMMAR, SQL_CORE_GRAMMAR]; - /// - return 4 (\b100) => [SQL_EXTENDED_GRAMMAR]; - /// - return 5 (\b101) => [SQL_MINIMUM_GRAMMAR, SQL_EXTENDED_GRAMMAR]; - /// - return 6 (\b110) => [SQL_CORE_GRAMMAR, SQL_EXTENDED_GRAMMAR]; - /// - return 7 (\b111) => [SQL_MINIMUM_GRAMMAR, SQL_CORE_GRAMMAR, SQL_EXTENDED_GRAMMAR]. - /// Valid SQL grammar levels are described under `arrow.flight.protocol.sql.SupportedSqlGrammar`. - case sqlSupportedGrammar // = 525 - - /// - /// Retrieves the supported ANSI92 SQL grammar level. - /// - /// Returns an int32 bitmask value representing the supported ANSI92 SQL grammar level. - /// The returned bitmask should be parsed in order to retrieve the supported commands. - /// - /// For instance: - /// - return 0 (\b0) => [] (ANSI92 SQL grammar is unsupported); - /// - return 1 (\b1) => [ANSI92_ENTRY_SQL]; - /// - return 2 (\b10) => [ANSI92_INTERMEDIATE_SQL]; - /// - return 3 (\b11) => [ANSI92_ENTRY_SQL, ANSI92_INTERMEDIATE_SQL]; - /// - return 4 (\b100) => [ANSI92_FULL_SQL]; - /// - return 5 (\b101) => [ANSI92_ENTRY_SQL, ANSI92_FULL_SQL]; - /// - return 6 (\b110) => [ANSI92_INTERMEDIATE_SQL, ANSI92_FULL_SQL]; - /// - return 7 (\b111) => [ANSI92_ENTRY_SQL, ANSI92_INTERMEDIATE_SQL, ANSI92_FULL_SQL]. - /// Valid ANSI92 SQL grammar levels are described under `arrow.flight.protocol.sql.SupportedAnsi92SqlGrammarLevel`. - case sqlAnsi92SupportedLevel // = 526 - - /// - /// Retrieves a boolean value indicating whether the SQL Integrity Enhancement Facility is supported. - /// - /// Returns: - /// - false: if the SQL Integrity Enhancement Facility is supported; - /// - true: if the SQL Integrity Enhancement Facility is supported. - case sqlSupportsIntegrityEnhancementFacility // = 527 - - /// - /// Retrieves the support level for SQL OUTER JOINs. - /// - /// Returns a int32 ordinal for the SQL ordering being used, as described in - /// `arrow.flight.protocol.sql.SqlOuterJoinsSupportLevel`. - case sqlOuterJoinsSupportLevel // = 528 - - /// Retrieves a UTF-8 string with the preferred term for "schema". - case sqlSchemaTerm // = 529 - - /// Retrieves a UTF-8 string with the preferred term for "procedure". - case sqlProcedureTerm // = 530 - - /// - /// Retrieves a UTF-8 string with the preferred term for "catalog". - /// If a empty string is returned its assumed that the server does NOT supports catalogs. - case sqlCatalogTerm // = 531 - - /// - /// Retrieves a boolean value indicating whether a catalog appears at the start of a fully qualified table name. - /// - /// - false: if a catalog does not appear at the start of a fully qualified table name; - /// - true: if a catalog appears at the start of a fully qualified table name. - case sqlCatalogAtStart // = 532 - - /// - /// Retrieves the supported actions for a SQL schema. - /// - /// Returns an int32 bitmask value representing the supported actions for a SQL schema. - /// The returned bitmask should be parsed in order to retrieve the supported actions for a SQL schema. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported actions for SQL schema); - /// - return 1 (\b1) => [SQL_ELEMENT_IN_PROCEDURE_CALLS]; - /// - return 2 (\b10) => [SQL_ELEMENT_IN_INDEX_DEFINITIONS]; - /// - return 3 (\b11) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_INDEX_DEFINITIONS]; - /// - return 4 (\b100) => [SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 5 (\b101) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 6 (\b110) => [SQL_ELEMENT_IN_INDEX_DEFINITIONS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 7 (\b111) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_INDEX_DEFINITIONS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]. - /// Valid actions for a SQL schema described under `arrow.flight.protocol.sql.SqlSupportedElementActions`. - case sqlSchemasSupportedActions // = 533 - - /// - /// Retrieves the supported actions for a SQL schema. - /// - /// Returns an int32 bitmask value representing the supported actions for a SQL catalog. - /// The returned bitmask should be parsed in order to retrieve the supported actions for a SQL catalog. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported actions for SQL catalog); - /// - return 1 (\b1) => [SQL_ELEMENT_IN_PROCEDURE_CALLS]; - /// - return 2 (\b10) => [SQL_ELEMENT_IN_INDEX_DEFINITIONS]; - /// - return 3 (\b11) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_INDEX_DEFINITIONS]; - /// - return 4 (\b100) => [SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 5 (\b101) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 6 (\b110) => [SQL_ELEMENT_IN_INDEX_DEFINITIONS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]; - /// - return 7 (\b111) => [SQL_ELEMENT_IN_PROCEDURE_CALLS, SQL_ELEMENT_IN_INDEX_DEFINITIONS, SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS]. - /// Valid actions for a SQL catalog are described under `arrow.flight.protocol.sql.SqlSupportedElementActions`. - case sqlCatalogsSupportedActions // = 534 - - /// - /// Retrieves the supported SQL positioned commands. - /// - /// Returns an int32 bitmask value representing the supported SQL positioned commands. - /// The returned bitmask should be parsed in order to retrieve the supported SQL positioned commands. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported SQL positioned commands); - /// - return 1 (\b1) => [SQL_POSITIONED_DELETE]; - /// - return 2 (\b10) => [SQL_POSITIONED_UPDATE]; - /// - return 3 (\b11) => [SQL_POSITIONED_DELETE, SQL_POSITIONED_UPDATE]. - /// Valid SQL positioned commands are described under `arrow.flight.protocol.sql.SqlSupportedPositionedCommands`. - case sqlSupportedPositionedCommands // = 535 - - /// - /// Retrieves a boolean value indicating whether SELECT FOR UPDATE statements are supported. - /// - /// Returns: - /// - false: if SELECT FOR UPDATE statements are unsupported; - /// - true: if SELECT FOR UPDATE statements are supported. - case sqlSelectForUpdateSupported // = 536 - - /// - /// Retrieves a boolean value indicating whether stored procedure calls that use the stored procedure escape syntax - /// are supported. - /// - /// Returns: - /// - false: if stored procedure calls that use the stored procedure escape syntax are unsupported; - /// - true: if stored procedure calls that use the stored procedure escape syntax are supported. - case sqlStoredProceduresSupported // = 537 - - /// - /// Retrieves the supported SQL subqueries. - /// - /// Returns an int32 bitmask value representing the supported SQL subqueries. - /// The returned bitmask should be parsed in order to retrieve the supported SQL subqueries. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported SQL subqueries); - /// - return 1 (\b1) => [SQL_SUBQUERIES_IN_COMPARISONS]; - /// - return 2 (\b10) => [SQL_SUBQUERIES_IN_EXISTS]; - /// - return 3 (\b11) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_EXISTS]; - /// - return 4 (\b100) => [SQL_SUBQUERIES_IN_INS]; - /// - return 5 (\b101) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_INS]; - /// - return 6 (\b110) => [SQL_SUBQUERIES_IN_INS, SQL_SUBQUERIES_IN_EXISTS]; - /// - return 7 (\b111) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_EXISTS, SQL_SUBQUERIES_IN_INS]; - /// - return 8 (\b1000) => [SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 9 (\b1001) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 10 (\b1010) => [SQL_SUBQUERIES_IN_EXISTS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 11 (\b1011) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_EXISTS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 12 (\b1100) => [SQL_SUBQUERIES_IN_INS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 13 (\b1101) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_INS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 14 (\b1110) => [SQL_SUBQUERIES_IN_EXISTS, SQL_SUBQUERIES_IN_INS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - return 15 (\b1111) => [SQL_SUBQUERIES_IN_COMPARISONS, SQL_SUBQUERIES_IN_EXISTS, SQL_SUBQUERIES_IN_INS, SQL_SUBQUERIES_IN_QUANTIFIEDS]; - /// - ... - /// Valid SQL subqueries are described under `arrow.flight.protocol.sql.SqlSupportedSubqueries`. - case sqlSupportedSubqueries // = 538 - - /// - /// Retrieves a boolean value indicating whether correlated subqueries are supported. - /// - /// Returns: - /// - false: if correlated subqueries are unsupported; - /// - true: if correlated subqueries are supported. - case sqlCorrelatedSubqueriesSupported // = 539 - - /// - /// Retrieves the supported SQL UNIONs. - /// - /// Returns an int32 bitmask value representing the supported SQL UNIONs. - /// The returned bitmask should be parsed in order to retrieve the supported SQL UNIONs. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported SQL positioned commands); - /// - return 1 (\b1) => [SQL_UNION]; - /// - return 2 (\b10) => [SQL_UNION_ALL]; - /// - return 3 (\b11) => [SQL_UNION, SQL_UNION_ALL]. - /// Valid SQL positioned commands are described under `arrow.flight.protocol.sql.SqlSupportedUnions`. - case sqlSupportedUnions // = 540 - - /// Retrieves a int64 value representing the maximum number of hex characters allowed in an inline binary literal. - case sqlMaxBinaryLiteralLength // = 541 - - /// Retrieves a int64 value representing the maximum number of characters allowed for a character literal. - case sqlMaxCharLiteralLength // = 542 - - /// Retrieves a int64 value representing the maximum number of characters allowed for a column name. - case sqlMaxColumnNameLength // = 543 - - /// Retrieves a int64 value representing the maximum number of columns allowed in a GROUP BY clause. - case sqlMaxColumnsInGroupBy // = 544 - - /// Retrieves a int64 value representing the maximum number of columns allowed in an index. - case sqlMaxColumnsInIndex // = 545 - - /// Retrieves a int64 value representing the maximum number of columns allowed in an ORDER BY clause. - case sqlMaxColumnsInOrderBy // = 546 - - /// Retrieves a int64 value representing the maximum number of columns allowed in a SELECT list. - case sqlMaxColumnsInSelect // = 547 - - /// Retrieves a int64 value representing the maximum number of columns allowed in a table. - case sqlMaxColumnsInTable // = 548 - - /// Retrieves a int64 value representing the maximum number of concurrent connections possible. - case sqlMaxConnections // = 549 - - /// Retrieves a int64 value the maximum number of characters allowed in a cursor name. - case sqlMaxCursorNameLength // = 550 - - /// - /// Retrieves a int64 value representing the maximum number of bytes allowed for an index, - /// including all of the parts of the index. - case sqlMaxIndexLength // = 551 - - /// Retrieves a int64 value representing the maximum number of characters allowed in a schema name. - case sqlDbSchemaNameLength // = 552 - - /// Retrieves a int64 value representing the maximum number of characters allowed in a procedure name. - case sqlMaxProcedureNameLength // = 553 - - /// Retrieves a int64 value representing the maximum number of characters allowed in a catalog name. - case sqlMaxCatalogNameLength // = 554 - - /// Retrieves a int64 value representing the maximum number of bytes allowed in a single row. - case sqlMaxRowSize // = 555 - - /// - /// Retrieves a boolean indicating whether the return value for the JDBC method getMaxRowSize includes the SQL - /// data types LONGVARCHAR and LONGVARBINARY. - /// - /// Returns: - /// - false: if return value for the JDBC method getMaxRowSize does - /// not include the SQL data types LONGVARCHAR and LONGVARBINARY; - /// - true: if return value for the JDBC method getMaxRowSize includes - /// the SQL data types LONGVARCHAR and LONGVARBINARY. - case sqlMaxRowSizeIncludesBlobs // = 556 - - /// - /// Retrieves a int64 value representing the maximum number of characters allowed for an SQL statement; - /// a result of 0 (zero) means that there is no limit or the limit is not known. - case sqlMaxStatementLength // = 557 - - /// Retrieves a int64 value representing the maximum number of active statements that can be open at the same time. - case sqlMaxStatements // = 558 - - /// Retrieves a int64 value representing the maximum number of characters allowed in a table name. - case sqlMaxTableNameLength // = 559 - - /// Retrieves a int64 value representing the maximum number of tables allowed in a SELECT statement. - case sqlMaxTablesInSelect // = 560 - - /// Retrieves a int64 value representing the maximum number of characters allowed in a user name. - case sqlMaxUsernameLength // = 561 - - /// - /// Retrieves this database's default transaction isolation level as described in - /// `arrow.flight.protocol.sql.SqlTransactionIsolationLevel`. - /// - /// Returns a int32 ordinal for the SQL transaction isolation level. - case sqlDefaultTransactionIsolation // = 562 - - /// - /// Retrieves a boolean value indicating whether transactions are supported. If not, invoking the method commit is a - /// noop, and the isolation level is `arrow.flight.protocol.sql.SqlTransactionIsolationLevel.TRANSACTION_NONE`. - /// - /// Returns: - /// - false: if transactions are unsupported; - /// - true: if transactions are supported. - case sqlTransactionsSupported // = 563 - - /// - /// Retrieves the supported transactions isolation levels. - /// - /// Returns an int32 bitmask value representing the supported transactions isolation levels. - /// The returned bitmask should be parsed in order to retrieve the supported transactions isolation levels. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported SQL transactions isolation levels); - /// - return 1 (\b1) => [SQL_TRANSACTION_NONE]; - /// - return 2 (\b10) => [SQL_TRANSACTION_READ_UNCOMMITTED]; - /// - return 3 (\b11) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_READ_UNCOMMITTED]; - /// - return 4 (\b100) => [SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 5 (\b101) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 6 (\b110) => [SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 7 (\b111) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 8 (\b1000) => [SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 9 (\b1001) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 10 (\b1010) => [SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 11 (\b1011) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 12 (\b1100) => [SQL_TRANSACTION_REPEATABLE_READ, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 13 (\b1101) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_REPEATABLE_READ, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 14 (\b1110) => [SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 15 (\b1111) => [SQL_TRANSACTION_NONE, SQL_TRANSACTION_READ_UNCOMMITTED, SQL_TRANSACTION_REPEATABLE_READ, SQL_TRANSACTION_REPEATABLE_READ]; - /// - return 16 (\b10000) => [SQL_TRANSACTION_SERIALIZABLE]; - /// - ... - /// Valid SQL positioned commands are described under `arrow.flight.protocol.sql.SqlTransactionIsolationLevel`. - case sqlSupportedTransactionsIsolationLevels // = 564 - - /// - /// Retrieves a boolean value indicating whether a data definition statement within a transaction forces - /// the transaction to commit. - /// - /// Returns: - /// - false: if a data definition statement within a transaction does not force the transaction to commit; - /// - true: if a data definition statement within a transaction forces the transaction to commit. - case sqlDataDefinitionCausesTransactionCommit // = 565 - - /// - /// Retrieves a boolean value indicating whether a data definition statement within a transaction is ignored. - /// - /// Returns: - /// - false: if a data definition statement within a transaction is taken into account; - /// - true: a data definition statement within a transaction is ignored. - case sqlDataDefinitionsInTransactionsIgnored // = 566 - - /// - /// Retrieves an int32 bitmask value representing the supported result set types. - /// The returned bitmask should be parsed in order to retrieve the supported result set types. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported result set types); - /// - return 1 (\b1) => [SQL_RESULT_SET_TYPE_UNSPECIFIED]; - /// - return 2 (\b10) => [SQL_RESULT_SET_TYPE_FORWARD_ONLY]; - /// - return 3 (\b11) => [SQL_RESULT_SET_TYPE_UNSPECIFIED, SQL_RESULT_SET_TYPE_FORWARD_ONLY]; - /// - return 4 (\b100) => [SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE]; - /// - return 5 (\b101) => [SQL_RESULT_SET_TYPE_UNSPECIFIED, SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE]; - /// - return 6 (\b110) => [SQL_RESULT_SET_TYPE_FORWARD_ONLY, SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE]; - /// - return 7 (\b111) => [SQL_RESULT_SET_TYPE_UNSPECIFIED, SQL_RESULT_SET_TYPE_FORWARD_ONLY, SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE]; - /// - return 8 (\b1000) => [SQL_RESULT_SET_TYPE_SCROLL_SENSITIVE]; - /// - ... - /// Valid result set types are described under `arrow.flight.protocol.sql.SqlSupportedResultSetType`. - case sqlSupportedResultSetTypes // = 567 - - /// - /// Returns an int32 bitmask value concurrency types supported for - /// `arrow.flight.protocol.sql.SqlSupportedResultSetType.SQL_RESULT_SET_TYPE_UNSPECIFIED`. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported concurrency types for this result set type) - /// - return 1 (\b1) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED] - /// - return 2 (\b10) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 3 (\b11) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 4 (\b100) => [SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 5 (\b101) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 6 (\b110) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 7 (\b111) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// Valid result set types are described under `arrow.flight.protocol.sql.SqlSupportedResultSetConcurrency`. - case sqlSupportedConcurrenciesForResultSetUnspecified // = 568 - - /// - /// Returns an int32 bitmask value concurrency types supported for - /// `arrow.flight.protocol.sql.SqlSupportedResultSetType.SQL_RESULT_SET_TYPE_FORWARD_ONLY`. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported concurrency types for this result set type) - /// - return 1 (\b1) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED] - /// - return 2 (\b10) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 3 (\b11) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 4 (\b100) => [SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 5 (\b101) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 6 (\b110) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 7 (\b111) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// Valid result set types are described under `arrow.flight.protocol.sql.SqlSupportedResultSetConcurrency`. - case sqlSupportedConcurrenciesForResultSetForwardOnly // = 569 - - /// - /// Returns an int32 bitmask value concurrency types supported for - /// `arrow.flight.protocol.sql.SqlSupportedResultSetType.SQL_RESULT_SET_TYPE_SCROLL_SENSITIVE`. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported concurrency types for this result set type) - /// - return 1 (\b1) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED] - /// - return 2 (\b10) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 3 (\b11) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 4 (\b100) => [SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 5 (\b101) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 6 (\b110) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 7 (\b111) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// Valid result set types are described under `arrow.flight.protocol.sql.SqlSupportedResultSetConcurrency`. - case sqlSupportedConcurrenciesForResultSetScrollSensitive // = 570 - - /// - /// Returns an int32 bitmask value concurrency types supported for - /// `arrow.flight.protocol.sql.SqlSupportedResultSetType.SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE`. - /// - /// For instance: - /// - return 0 (\b0) => [] (no supported concurrency types for this result set type) - /// - return 1 (\b1) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED] - /// - return 2 (\b10) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 3 (\b11) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY] - /// - return 4 (\b100) => [SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 5 (\b101) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 6 (\b110) => [SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// - return 7 (\b111) => [SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED, SQL_RESULT_SET_CONCURRENCY_READ_ONLY, SQL_RESULT_SET_CONCURRENCY_UPDATABLE] - /// Valid result set types are described under `arrow.flight.protocol.sql.SqlSupportedResultSetConcurrency`. - case sqlSupportedConcurrenciesForResultSetScrollInsensitive // = 571 - - /// - /// Retrieves a boolean value indicating whether this database supports batch updates. - /// - /// - false: if this database does not support batch updates; - /// - true: if this database supports batch updates. - case sqlBatchUpdatesSupported // = 572 - - /// - /// Retrieves a boolean value indicating whether this database supports savepoints. - /// - /// Returns: - /// - false: if this database does not support savepoints; - /// - true: if this database supports savepoints. - case sqlSavepointsSupported // = 573 - - /// - /// Retrieves a boolean value indicating whether named parameters are supported in callable statements. - /// - /// Returns: - /// - false: if named parameters in callable statements are unsupported; - /// - true: if named parameters in callable statements are supported. - case sqlNamedParametersSupported // = 574 - - /// - /// Retrieves a boolean value indicating whether updates made to a LOB are made on a copy or directly to the LOB. - /// - /// Returns: - /// - false: if updates made to a LOB are made directly to the LOB; - /// - true: if updates made to a LOB are made on a copy. - case sqlLocatorsUpdateCopy // = 575 - - /// - /// Retrieves a boolean value indicating whether invoking user-defined or vendor functions - /// using the stored procedure escape syntax is supported. - /// - /// Returns: - /// - false: if invoking user-defined or vendor functions using the stored procedure escape syntax is unsupported; - /// - true: if invoking user-defined or vendor functions using the stored procedure escape syntax is supported. - case sqlStoredFunctionsUsingCallSyntaxSupported // = 576 - case UNRECOGNIZED(Int) - - init() { - self = .flightSqlServerName - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .flightSqlServerName - case 1: self = .flightSqlServerVersion - case 2: self = .flightSqlServerArrowVersion - case 3: self = .flightSqlServerReadOnly - case 4: self = .flightSqlServerSql - case 5: self = .flightSqlServerSubstrait - case 6: self = .flightSqlServerSubstraitMinVersion - case 7: self = .flightSqlServerSubstraitMaxVersion - case 8: self = .flightSqlServerTransaction - case 9: self = .flightSqlServerCancel - case 100: self = .flightSqlServerStatementTimeout - case 101: self = .flightSqlServerTransactionTimeout - case 500: self = .sqlDdlCatalog - case 501: self = .sqlDdlSchema - case 502: self = .sqlDdlTable - case 503: self = .sqlIdentifierCase - case 504: self = .sqlIdentifierQuoteChar - case 505: self = .sqlQuotedIdentifierCase - case 506: self = .sqlAllTablesAreSelectable - case 507: self = .sqlNullOrdering - case 508: self = .sqlKeywords - case 509: self = .sqlNumericFunctions - case 510: self = .sqlStringFunctions - case 511: self = .sqlSystemFunctions - case 512: self = .sqlDatetimeFunctions - case 513: self = .sqlSearchStringEscape - case 514: self = .sqlExtraNameCharacters - case 515: self = .sqlSupportsColumnAliasing - case 516: self = .sqlNullPlusNullIsNull - case 517: self = .sqlSupportsConvert - case 518: self = .sqlSupportsTableCorrelationNames - case 519: self = .sqlSupportsDifferentTableCorrelationNames - case 520: self = .sqlSupportsExpressionsInOrderBy - case 521: self = .sqlSupportsOrderByUnrelated - case 522: self = .sqlSupportedGroupBy - case 523: self = .sqlSupportsLikeEscapeClause - case 524: self = .sqlSupportsNonNullableColumns - case 525: self = .sqlSupportedGrammar - case 526: self = .sqlAnsi92SupportedLevel - case 527: self = .sqlSupportsIntegrityEnhancementFacility - case 528: self = .sqlOuterJoinsSupportLevel - case 529: self = .sqlSchemaTerm - case 530: self = .sqlProcedureTerm - case 531: self = .sqlCatalogTerm - case 532: self = .sqlCatalogAtStart - case 533: self = .sqlSchemasSupportedActions - case 534: self = .sqlCatalogsSupportedActions - case 535: self = .sqlSupportedPositionedCommands - case 536: self = .sqlSelectForUpdateSupported - case 537: self = .sqlStoredProceduresSupported - case 538: self = .sqlSupportedSubqueries - case 539: self = .sqlCorrelatedSubqueriesSupported - case 540: self = .sqlSupportedUnions - case 541: self = .sqlMaxBinaryLiteralLength - case 542: self = .sqlMaxCharLiteralLength - case 543: self = .sqlMaxColumnNameLength - case 544: self = .sqlMaxColumnsInGroupBy - case 545: self = .sqlMaxColumnsInIndex - case 546: self = .sqlMaxColumnsInOrderBy - case 547: self = .sqlMaxColumnsInSelect - case 548: self = .sqlMaxColumnsInTable - case 549: self = .sqlMaxConnections - case 550: self = .sqlMaxCursorNameLength - case 551: self = .sqlMaxIndexLength - case 552: self = .sqlDbSchemaNameLength - case 553: self = .sqlMaxProcedureNameLength - case 554: self = .sqlMaxCatalogNameLength - case 555: self = .sqlMaxRowSize - case 556: self = .sqlMaxRowSizeIncludesBlobs - case 557: self = .sqlMaxStatementLength - case 558: self = .sqlMaxStatements - case 559: self = .sqlMaxTableNameLength - case 560: self = .sqlMaxTablesInSelect - case 561: self = .sqlMaxUsernameLength - case 562: self = .sqlDefaultTransactionIsolation - case 563: self = .sqlTransactionsSupported - case 564: self = .sqlSupportedTransactionsIsolationLevels - case 565: self = .sqlDataDefinitionCausesTransactionCommit - case 566: self = .sqlDataDefinitionsInTransactionsIgnored - case 567: self = .sqlSupportedResultSetTypes - case 568: self = .sqlSupportedConcurrenciesForResultSetUnspecified - case 569: self = .sqlSupportedConcurrenciesForResultSetForwardOnly - case 570: self = .sqlSupportedConcurrenciesForResultSetScrollSensitive - case 571: self = .sqlSupportedConcurrenciesForResultSetScrollInsensitive - case 572: self = .sqlBatchUpdatesSupported - case 573: self = .sqlSavepointsSupported - case 574: self = .sqlNamedParametersSupported - case 575: self = .sqlLocatorsUpdateCopy - case 576: self = .sqlStoredFunctionsUsingCallSyntaxSupported - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .flightSqlServerName: return 0 - case .flightSqlServerVersion: return 1 - case .flightSqlServerArrowVersion: return 2 - case .flightSqlServerReadOnly: return 3 - case .flightSqlServerSql: return 4 - case .flightSqlServerSubstrait: return 5 - case .flightSqlServerSubstraitMinVersion: return 6 - case .flightSqlServerSubstraitMaxVersion: return 7 - case .flightSqlServerTransaction: return 8 - case .flightSqlServerCancel: return 9 - case .flightSqlServerStatementTimeout: return 100 - case .flightSqlServerTransactionTimeout: return 101 - case .sqlDdlCatalog: return 500 - case .sqlDdlSchema: return 501 - case .sqlDdlTable: return 502 - case .sqlIdentifierCase: return 503 - case .sqlIdentifierQuoteChar: return 504 - case .sqlQuotedIdentifierCase: return 505 - case .sqlAllTablesAreSelectable: return 506 - case .sqlNullOrdering: return 507 - case .sqlKeywords: return 508 - case .sqlNumericFunctions: return 509 - case .sqlStringFunctions: return 510 - case .sqlSystemFunctions: return 511 - case .sqlDatetimeFunctions: return 512 - case .sqlSearchStringEscape: return 513 - case .sqlExtraNameCharacters: return 514 - case .sqlSupportsColumnAliasing: return 515 - case .sqlNullPlusNullIsNull: return 516 - case .sqlSupportsConvert: return 517 - case .sqlSupportsTableCorrelationNames: return 518 - case .sqlSupportsDifferentTableCorrelationNames: return 519 - case .sqlSupportsExpressionsInOrderBy: return 520 - case .sqlSupportsOrderByUnrelated: return 521 - case .sqlSupportedGroupBy: return 522 - case .sqlSupportsLikeEscapeClause: return 523 - case .sqlSupportsNonNullableColumns: return 524 - case .sqlSupportedGrammar: return 525 - case .sqlAnsi92SupportedLevel: return 526 - case .sqlSupportsIntegrityEnhancementFacility: return 527 - case .sqlOuterJoinsSupportLevel: return 528 - case .sqlSchemaTerm: return 529 - case .sqlProcedureTerm: return 530 - case .sqlCatalogTerm: return 531 - case .sqlCatalogAtStart: return 532 - case .sqlSchemasSupportedActions: return 533 - case .sqlCatalogsSupportedActions: return 534 - case .sqlSupportedPositionedCommands: return 535 - case .sqlSelectForUpdateSupported: return 536 - case .sqlStoredProceduresSupported: return 537 - case .sqlSupportedSubqueries: return 538 - case .sqlCorrelatedSubqueriesSupported: return 539 - case .sqlSupportedUnions: return 540 - case .sqlMaxBinaryLiteralLength: return 541 - case .sqlMaxCharLiteralLength: return 542 - case .sqlMaxColumnNameLength: return 543 - case .sqlMaxColumnsInGroupBy: return 544 - case .sqlMaxColumnsInIndex: return 545 - case .sqlMaxColumnsInOrderBy: return 546 - case .sqlMaxColumnsInSelect: return 547 - case .sqlMaxColumnsInTable: return 548 - case .sqlMaxConnections: return 549 - case .sqlMaxCursorNameLength: return 550 - case .sqlMaxIndexLength: return 551 - case .sqlDbSchemaNameLength: return 552 - case .sqlMaxProcedureNameLength: return 553 - case .sqlMaxCatalogNameLength: return 554 - case .sqlMaxRowSize: return 555 - case .sqlMaxRowSizeIncludesBlobs: return 556 - case .sqlMaxStatementLength: return 557 - case .sqlMaxStatements: return 558 - case .sqlMaxTableNameLength: return 559 - case .sqlMaxTablesInSelect: return 560 - case .sqlMaxUsernameLength: return 561 - case .sqlDefaultTransactionIsolation: return 562 - case .sqlTransactionsSupported: return 563 - case .sqlSupportedTransactionsIsolationLevels: return 564 - case .sqlDataDefinitionCausesTransactionCommit: return 565 - case .sqlDataDefinitionsInTransactionsIgnored: return 566 - case .sqlSupportedResultSetTypes: return 567 - case .sqlSupportedConcurrenciesForResultSetUnspecified: return 568 - case .sqlSupportedConcurrenciesForResultSetForwardOnly: return 569 - case .sqlSupportedConcurrenciesForResultSetScrollSensitive: return 570 - case .sqlSupportedConcurrenciesForResultSetScrollInsensitive: return 571 - case .sqlBatchUpdatesSupported: return 572 - case .sqlSavepointsSupported: return 573 - case .sqlNamedParametersSupported: return 574 - case .sqlLocatorsUpdateCopy: return 575 - case .sqlStoredFunctionsUsingCallSyntaxSupported: return 576 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlInfo: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlInfo] = [ - .flightSqlServerName, - .flightSqlServerVersion, - .flightSqlServerArrowVersion, - .flightSqlServerReadOnly, - .flightSqlServerSql, - .flightSqlServerSubstrait, - .flightSqlServerSubstraitMinVersion, - .flightSqlServerSubstraitMaxVersion, - .flightSqlServerTransaction, - .flightSqlServerCancel, - .flightSqlServerStatementTimeout, - .flightSqlServerTransactionTimeout, - .sqlDdlCatalog, - .sqlDdlSchema, - .sqlDdlTable, - .sqlIdentifierCase, - .sqlIdentifierQuoteChar, - .sqlQuotedIdentifierCase, - .sqlAllTablesAreSelectable, - .sqlNullOrdering, - .sqlKeywords, - .sqlNumericFunctions, - .sqlStringFunctions, - .sqlSystemFunctions, - .sqlDatetimeFunctions, - .sqlSearchStringEscape, - .sqlExtraNameCharacters, - .sqlSupportsColumnAliasing, - .sqlNullPlusNullIsNull, - .sqlSupportsConvert, - .sqlSupportsTableCorrelationNames, - .sqlSupportsDifferentTableCorrelationNames, - .sqlSupportsExpressionsInOrderBy, - .sqlSupportsOrderByUnrelated, - .sqlSupportedGroupBy, - .sqlSupportsLikeEscapeClause, - .sqlSupportsNonNullableColumns, - .sqlSupportedGrammar, - .sqlAnsi92SupportedLevel, - .sqlSupportsIntegrityEnhancementFacility, - .sqlOuterJoinsSupportLevel, - .sqlSchemaTerm, - .sqlProcedureTerm, - .sqlCatalogTerm, - .sqlCatalogAtStart, - .sqlSchemasSupportedActions, - .sqlCatalogsSupportedActions, - .sqlSupportedPositionedCommands, - .sqlSelectForUpdateSupported, - .sqlStoredProceduresSupported, - .sqlSupportedSubqueries, - .sqlCorrelatedSubqueriesSupported, - .sqlSupportedUnions, - .sqlMaxBinaryLiteralLength, - .sqlMaxCharLiteralLength, - .sqlMaxColumnNameLength, - .sqlMaxColumnsInGroupBy, - .sqlMaxColumnsInIndex, - .sqlMaxColumnsInOrderBy, - .sqlMaxColumnsInSelect, - .sqlMaxColumnsInTable, - .sqlMaxConnections, - .sqlMaxCursorNameLength, - .sqlMaxIndexLength, - .sqlDbSchemaNameLength, - .sqlMaxProcedureNameLength, - .sqlMaxCatalogNameLength, - .sqlMaxRowSize, - .sqlMaxRowSizeIncludesBlobs, - .sqlMaxStatementLength, - .sqlMaxStatements, - .sqlMaxTableNameLength, - .sqlMaxTablesInSelect, - .sqlMaxUsernameLength, - .sqlDefaultTransactionIsolation, - .sqlTransactionsSupported, - .sqlSupportedTransactionsIsolationLevels, - .sqlDataDefinitionCausesTransactionCommit, - .sqlDataDefinitionsInTransactionsIgnored, - .sqlSupportedResultSetTypes, - .sqlSupportedConcurrenciesForResultSetUnspecified, - .sqlSupportedConcurrenciesForResultSetForwardOnly, - .sqlSupportedConcurrenciesForResultSetScrollSensitive, - .sqlSupportedConcurrenciesForResultSetScrollInsensitive, - .sqlBatchUpdatesSupported, - .sqlSavepointsSupported, - .sqlNamedParametersSupported, - .sqlLocatorsUpdateCopy, - .sqlStoredFunctionsUsingCallSyntaxSupported, - ] -} - -#endif // swift(>=4.2) - -/// The level of support for Flight SQL transaction RPCs. -enum Arrow_Flight_Protocol_Sql_SqlSupportedTransaction: SwiftProtobuf.Enum { - typealias RawValue = Int - - /// Unknown/not indicated/no support - case none // = 0 - - /// Transactions, but not savepoints. - /// A savepoint is a mark within a transaction that can be individually - /// rolled back to. Not all databases support savepoints. - case transaction // = 1 - - /// Transactions and savepoints - case savepoint // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .none - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .none - case 1: self = .transaction - case 2: self = .savepoint - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .none: return 0 - case .transaction: return 1 - case .savepoint: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransaction: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedTransaction] = [ - .none, - .transaction, - .savepoint, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedCaseSensitivity: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlCaseSensitivityUnknown // = 0 - case sqlCaseSensitivityCaseInsensitive // = 1 - case sqlCaseSensitivityUppercase // = 2 - case sqlCaseSensitivityLowercase // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .sqlCaseSensitivityUnknown - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlCaseSensitivityUnknown - case 1: self = .sqlCaseSensitivityCaseInsensitive - case 2: self = .sqlCaseSensitivityUppercase - case 3: self = .sqlCaseSensitivityLowercase - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlCaseSensitivityUnknown: return 0 - case .sqlCaseSensitivityCaseInsensitive: return 1 - case .sqlCaseSensitivityUppercase: return 2 - case .sqlCaseSensitivityLowercase: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedCaseSensitivity: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedCaseSensitivity] = [ - .sqlCaseSensitivityUnknown, - .sqlCaseSensitivityCaseInsensitive, - .sqlCaseSensitivityUppercase, - .sqlCaseSensitivityLowercase, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlNullOrdering: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlNullsSortedHigh // = 0 - case sqlNullsSortedLow // = 1 - case sqlNullsSortedAtStart // = 2 - case sqlNullsSortedAtEnd // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .sqlNullsSortedHigh - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlNullsSortedHigh - case 1: self = .sqlNullsSortedLow - case 2: self = .sqlNullsSortedAtStart - case 3: self = .sqlNullsSortedAtEnd - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlNullsSortedHigh: return 0 - case .sqlNullsSortedLow: return 1 - case .sqlNullsSortedAtStart: return 2 - case .sqlNullsSortedAtEnd: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlNullOrdering: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlNullOrdering] = [ - .sqlNullsSortedHigh, - .sqlNullsSortedLow, - .sqlNullsSortedAtStart, - .sqlNullsSortedAtEnd, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SupportedSqlGrammar: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlMinimumGrammar // = 0 - case sqlCoreGrammar // = 1 - case sqlExtendedGrammar // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .sqlMinimumGrammar - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlMinimumGrammar - case 1: self = .sqlCoreGrammar - case 2: self = .sqlExtendedGrammar - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlMinimumGrammar: return 0 - case .sqlCoreGrammar: return 1 - case .sqlExtendedGrammar: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SupportedSqlGrammar: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SupportedSqlGrammar] = [ - .sqlMinimumGrammar, - .sqlCoreGrammar, - .sqlExtendedGrammar, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SupportedAnsi92SqlGrammarLevel: SwiftProtobuf.Enum { - typealias RawValue = Int - case ansi92EntrySql // = 0 - case ansi92IntermediateSql // = 1 - case ansi92FullSql // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .ansi92EntrySql - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .ansi92EntrySql - case 1: self = .ansi92IntermediateSql - case 2: self = .ansi92FullSql - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .ansi92EntrySql: return 0 - case .ansi92IntermediateSql: return 1 - case .ansi92FullSql: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SupportedAnsi92SqlGrammarLevel: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SupportedAnsi92SqlGrammarLevel] = [ - .ansi92EntrySql, - .ansi92IntermediateSql, - .ansi92FullSql, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlOuterJoinsSupportLevel: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlJoinsUnsupported // = 0 - case sqlLimitedOuterJoins // = 1 - case sqlFullOuterJoins // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .sqlJoinsUnsupported - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlJoinsUnsupported - case 1: self = .sqlLimitedOuterJoins - case 2: self = .sqlFullOuterJoins - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlJoinsUnsupported: return 0 - case .sqlLimitedOuterJoins: return 1 - case .sqlFullOuterJoins: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlOuterJoinsSupportLevel: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlOuterJoinsSupportLevel] = [ - .sqlJoinsUnsupported, - .sqlLimitedOuterJoins, - .sqlFullOuterJoins, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedGroupBy: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlGroupByUnrelated // = 0 - case sqlGroupByBeyondSelect // = 1 - case UNRECOGNIZED(Int) - - init() { - self = .sqlGroupByUnrelated - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlGroupByUnrelated - case 1: self = .sqlGroupByBeyondSelect - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlGroupByUnrelated: return 0 - case .sqlGroupByBeyondSelect: return 1 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedGroupBy: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedGroupBy] = [ - .sqlGroupByUnrelated, - .sqlGroupByBeyondSelect, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedElementActions: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlElementInProcedureCalls // = 0 - case sqlElementInIndexDefinitions // = 1 - case sqlElementInPrivilegeDefinitions // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .sqlElementInProcedureCalls - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlElementInProcedureCalls - case 1: self = .sqlElementInIndexDefinitions - case 2: self = .sqlElementInPrivilegeDefinitions - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlElementInProcedureCalls: return 0 - case .sqlElementInIndexDefinitions: return 1 - case .sqlElementInPrivilegeDefinitions: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedElementActions: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedElementActions] = [ - .sqlElementInProcedureCalls, - .sqlElementInIndexDefinitions, - .sqlElementInPrivilegeDefinitions, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedPositionedCommands: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlPositionedDelete // = 0 - case sqlPositionedUpdate // = 1 - case UNRECOGNIZED(Int) - - init() { - self = .sqlPositionedDelete - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlPositionedDelete - case 1: self = .sqlPositionedUpdate - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlPositionedDelete: return 0 - case .sqlPositionedUpdate: return 1 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedPositionedCommands: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedPositionedCommands] = [ - .sqlPositionedDelete, - .sqlPositionedUpdate, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedSubqueries: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlSubqueriesInComparisons // = 0 - case sqlSubqueriesInExists // = 1 - case sqlSubqueriesInIns // = 2 - case sqlSubqueriesInQuantifieds // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .sqlSubqueriesInComparisons - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlSubqueriesInComparisons - case 1: self = .sqlSubqueriesInExists - case 2: self = .sqlSubqueriesInIns - case 3: self = .sqlSubqueriesInQuantifieds - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlSubqueriesInComparisons: return 0 - case .sqlSubqueriesInExists: return 1 - case .sqlSubqueriesInIns: return 2 - case .sqlSubqueriesInQuantifieds: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedSubqueries: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedSubqueries] = [ - .sqlSubqueriesInComparisons, - .sqlSubqueriesInExists, - .sqlSubqueriesInIns, - .sqlSubqueriesInQuantifieds, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedUnions: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlUnion // = 0 - case sqlUnionAll // = 1 - case UNRECOGNIZED(Int) - - init() { - self = .sqlUnion - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlUnion - case 1: self = .sqlUnionAll - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlUnion: return 0 - case .sqlUnionAll: return 1 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedUnions: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedUnions] = [ - .sqlUnion, - .sqlUnionAll, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlTransactionIsolationLevel: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlTransactionNone // = 0 - case sqlTransactionReadUncommitted // = 1 - case sqlTransactionReadCommitted // = 2 - case sqlTransactionRepeatableRead // = 3 - case sqlTransactionSerializable // = 4 - case UNRECOGNIZED(Int) - - init() { - self = .sqlTransactionNone - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlTransactionNone - case 1: self = .sqlTransactionReadUncommitted - case 2: self = .sqlTransactionReadCommitted - case 3: self = .sqlTransactionRepeatableRead - case 4: self = .sqlTransactionSerializable - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlTransactionNone: return 0 - case .sqlTransactionReadUncommitted: return 1 - case .sqlTransactionReadCommitted: return 2 - case .sqlTransactionRepeatableRead: return 3 - case .sqlTransactionSerializable: return 4 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlTransactionIsolationLevel: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlTransactionIsolationLevel] = [ - .sqlTransactionNone, - .sqlTransactionReadUncommitted, - .sqlTransactionReadCommitted, - .sqlTransactionRepeatableRead, - .sqlTransactionSerializable, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedTransactions: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlTransactionUnspecified // = 0 - case sqlDataDefinitionTransactions // = 1 - case sqlDataManipulationTransactions // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .sqlTransactionUnspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlTransactionUnspecified - case 1: self = .sqlDataDefinitionTransactions - case 2: self = .sqlDataManipulationTransactions - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlTransactionUnspecified: return 0 - case .sqlDataDefinitionTransactions: return 1 - case .sqlDataManipulationTransactions: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransactions: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedTransactions] = [ - .sqlTransactionUnspecified, - .sqlDataDefinitionTransactions, - .sqlDataManipulationTransactions, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedResultSetType: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlResultSetTypeUnspecified // = 0 - case sqlResultSetTypeForwardOnly // = 1 - case sqlResultSetTypeScrollInsensitive // = 2 - case sqlResultSetTypeScrollSensitive // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .sqlResultSetTypeUnspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlResultSetTypeUnspecified - case 1: self = .sqlResultSetTypeForwardOnly - case 2: self = .sqlResultSetTypeScrollInsensitive - case 3: self = .sqlResultSetTypeScrollSensitive - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlResultSetTypeUnspecified: return 0 - case .sqlResultSetTypeForwardOnly: return 1 - case .sqlResultSetTypeScrollInsensitive: return 2 - case .sqlResultSetTypeScrollSensitive: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedResultSetType] = [ - .sqlResultSetTypeUnspecified, - .sqlResultSetTypeForwardOnly, - .sqlResultSetTypeScrollInsensitive, - .sqlResultSetTypeScrollSensitive, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportedResultSetConcurrency: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlResultSetConcurrencyUnspecified // = 0 - case sqlResultSetConcurrencyReadOnly // = 1 - case sqlResultSetConcurrencyUpdatable // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .sqlResultSetConcurrencyUnspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlResultSetConcurrencyUnspecified - case 1: self = .sqlResultSetConcurrencyReadOnly - case 2: self = .sqlResultSetConcurrencyUpdatable - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlResultSetConcurrencyUnspecified: return 0 - case .sqlResultSetConcurrencyReadOnly: return 1 - case .sqlResultSetConcurrencyUpdatable: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetConcurrency: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportedResultSetConcurrency] = [ - .sqlResultSetConcurrencyUnspecified, - .sqlResultSetConcurrencyReadOnly, - .sqlResultSetConcurrencyUpdatable, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_SqlSupportsConvert: SwiftProtobuf.Enum { - typealias RawValue = Int - case sqlConvertBigint // = 0 - case sqlConvertBinary // = 1 - case sqlConvertBit // = 2 - case sqlConvertChar // = 3 - case sqlConvertDate // = 4 - case sqlConvertDecimal // = 5 - case sqlConvertFloat // = 6 - case sqlConvertInteger // = 7 - case sqlConvertIntervalDayTime // = 8 - case sqlConvertIntervalYearMonth // = 9 - case sqlConvertLongvarbinary // = 10 - case sqlConvertLongvarchar // = 11 - case sqlConvertNumeric // = 12 - case sqlConvertReal // = 13 - case sqlConvertSmallint // = 14 - case sqlConvertTime // = 15 - case sqlConvertTimestamp // = 16 - case sqlConvertTinyint // = 17 - case sqlConvertVarbinary // = 18 - case sqlConvertVarchar // = 19 - case UNRECOGNIZED(Int) - - init() { - self = .sqlConvertBigint - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sqlConvertBigint - case 1: self = .sqlConvertBinary - case 2: self = .sqlConvertBit - case 3: self = .sqlConvertChar - case 4: self = .sqlConvertDate - case 5: self = .sqlConvertDecimal - case 6: self = .sqlConvertFloat - case 7: self = .sqlConvertInteger - case 8: self = .sqlConvertIntervalDayTime - case 9: self = .sqlConvertIntervalYearMonth - case 10: self = .sqlConvertLongvarbinary - case 11: self = .sqlConvertLongvarchar - case 12: self = .sqlConvertNumeric - case 13: self = .sqlConvertReal - case 14: self = .sqlConvertSmallint - case 15: self = .sqlConvertTime - case 16: self = .sqlConvertTimestamp - case 17: self = .sqlConvertTinyint - case 18: self = .sqlConvertVarbinary - case 19: self = .sqlConvertVarchar - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .sqlConvertBigint: return 0 - case .sqlConvertBinary: return 1 - case .sqlConvertBit: return 2 - case .sqlConvertChar: return 3 - case .sqlConvertDate: return 4 - case .sqlConvertDecimal: return 5 - case .sqlConvertFloat: return 6 - case .sqlConvertInteger: return 7 - case .sqlConvertIntervalDayTime: return 8 - case .sqlConvertIntervalYearMonth: return 9 - case .sqlConvertLongvarbinary: return 10 - case .sqlConvertLongvarchar: return 11 - case .sqlConvertNumeric: return 12 - case .sqlConvertReal: return 13 - case .sqlConvertSmallint: return 14 - case .sqlConvertTime: return 15 - case .sqlConvertTimestamp: return 16 - case .sqlConvertTinyint: return 17 - case .sqlConvertVarbinary: return 18 - case .sqlConvertVarchar: return 19 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_SqlSupportsConvert: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_SqlSupportsConvert] = [ - .sqlConvertBigint, - .sqlConvertBinary, - .sqlConvertBit, - .sqlConvertChar, - .sqlConvertDate, - .sqlConvertDecimal, - .sqlConvertFloat, - .sqlConvertInteger, - .sqlConvertIntervalDayTime, - .sqlConvertIntervalYearMonth, - .sqlConvertLongvarbinary, - .sqlConvertLongvarchar, - .sqlConvertNumeric, - .sqlConvertReal, - .sqlConvertSmallint, - .sqlConvertTime, - .sqlConvertTimestamp, - .sqlConvertTinyint, - .sqlConvertVarbinary, - .sqlConvertVarchar, - ] -} - -#endif // swift(>=4.2) - -///* -/// The JDBC/ODBC-defined type of any object. -/// All the values here are the same as in the JDBC and ODBC specs. -enum Arrow_Flight_Protocol_Sql_XdbcDataType: SwiftProtobuf.Enum { - typealias RawValue = Int - case xdbcUnknownType // = 0 - case xdbcChar // = 1 - case xdbcNumeric // = 2 - case xdbcDecimal // = 3 - case xdbcInteger // = 4 - case xdbcSmallint // = 5 - case xdbcFloat // = 6 - case xdbcReal // = 7 - case xdbcDouble // = 8 - case xdbcDatetime // = 9 - case xdbcInterval // = 10 - case xdbcVarchar // = 12 - case xdbcDate // = 91 - case xdbcTime // = 92 - case xdbcTimestamp // = 93 - case xdbcLongvarchar // = -1 - case xdbcBinary // = -2 - case xdbcVarbinary // = -3 - case xdbcLongvarbinary // = -4 - case xdbcBigint // = -5 - case xdbcTinyint // = -6 - case xdbcBit // = -7 - case xdbcWchar // = -8 - case xdbcWvarchar // = -9 - case UNRECOGNIZED(Int) - - init() { - self = .xdbcUnknownType - } - - init?(rawValue: Int) { - switch rawValue { - case -9: self = .xdbcWvarchar - case -8: self = .xdbcWchar - case -7: self = .xdbcBit - case -6: self = .xdbcTinyint - case -5: self = .xdbcBigint - case -4: self = .xdbcLongvarbinary - case -3: self = .xdbcVarbinary - case -2: self = .xdbcBinary - case -1: self = .xdbcLongvarchar - case 0: self = .xdbcUnknownType - case 1: self = .xdbcChar - case 2: self = .xdbcNumeric - case 3: self = .xdbcDecimal - case 4: self = .xdbcInteger - case 5: self = .xdbcSmallint - case 6: self = .xdbcFloat - case 7: self = .xdbcReal - case 8: self = .xdbcDouble - case 9: self = .xdbcDatetime - case 10: self = .xdbcInterval - case 12: self = .xdbcVarchar - case 91: self = .xdbcDate - case 92: self = .xdbcTime - case 93: self = .xdbcTimestamp - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .xdbcWvarchar: return -9 - case .xdbcWchar: return -8 - case .xdbcBit: return -7 - case .xdbcTinyint: return -6 - case .xdbcBigint: return -5 - case .xdbcLongvarbinary: return -4 - case .xdbcVarbinary: return -3 - case .xdbcBinary: return -2 - case .xdbcLongvarchar: return -1 - case .xdbcUnknownType: return 0 - case .xdbcChar: return 1 - case .xdbcNumeric: return 2 - case .xdbcDecimal: return 3 - case .xdbcInteger: return 4 - case .xdbcSmallint: return 5 - case .xdbcFloat: return 6 - case .xdbcReal: return 7 - case .xdbcDouble: return 8 - case .xdbcDatetime: return 9 - case .xdbcInterval: return 10 - case .xdbcVarchar: return 12 - case .xdbcDate: return 91 - case .xdbcTime: return 92 - case .xdbcTimestamp: return 93 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_XdbcDataType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_XdbcDataType] = [ - .xdbcUnknownType, - .xdbcChar, - .xdbcNumeric, - .xdbcDecimal, - .xdbcInteger, - .xdbcSmallint, - .xdbcFloat, - .xdbcReal, - .xdbcDouble, - .xdbcDatetime, - .xdbcInterval, - .xdbcVarchar, - .xdbcDate, - .xdbcTime, - .xdbcTimestamp, - .xdbcLongvarchar, - .xdbcBinary, - .xdbcVarbinary, - .xdbcLongvarbinary, - .xdbcBigint, - .xdbcTinyint, - .xdbcBit, - .xdbcWchar, - .xdbcWvarchar, - ] -} - -#endif // swift(>=4.2) - -///* -/// Detailed subtype information for XDBC_TYPE_DATETIME and XDBC_TYPE_INTERVAL. -enum Arrow_Flight_Protocol_Sql_XdbcDatetimeSubcode: SwiftProtobuf.Enum { - typealias RawValue = Int - case xdbcSubcodeUnknown // = 0 - case xdbcSubcodeYear // = 1 - static let xdbcSubcodeDate = xdbcSubcodeYear - case xdbcSubcodeTime // = 2 - static let xdbcSubcodeMonth = xdbcSubcodeTime - case xdbcSubcodeTimestamp // = 3 - static let xdbcSubcodeDay = xdbcSubcodeTimestamp - case xdbcSubcodeTimeWithTimezone // = 4 - static let xdbcSubcodeHour = xdbcSubcodeTimeWithTimezone - case xdbcSubcodeTimestampWithTimezone // = 5 - static let xdbcSubcodeMinute = xdbcSubcodeTimestampWithTimezone - case xdbcSubcodeSecond // = 6 - case xdbcSubcodeYearToMonth // = 7 - case xdbcSubcodeDayToHour // = 8 - case xdbcSubcodeDayToMinute // = 9 - case xdbcSubcodeDayToSecond // = 10 - case xdbcSubcodeHourToMinute // = 11 - case xdbcSubcodeHourToSecond // = 12 - case xdbcSubcodeMinuteToSecond // = 13 - case xdbcSubcodeIntervalYear // = 101 - case xdbcSubcodeIntervalMonth // = 102 - case xdbcSubcodeIntervalDay // = 103 - case xdbcSubcodeIntervalHour // = 104 - case xdbcSubcodeIntervalMinute // = 105 - case xdbcSubcodeIntervalSecond // = 106 - case xdbcSubcodeIntervalYearToMonth // = 107 - case xdbcSubcodeIntervalDayToHour // = 108 - case xdbcSubcodeIntervalDayToMinute // = 109 - case xdbcSubcodeIntervalDayToSecond // = 110 - case xdbcSubcodeIntervalHourToMinute // = 111 - case xdbcSubcodeIntervalHourToSecond // = 112 - case xdbcSubcodeIntervalMinuteToSecond // = 113 - case UNRECOGNIZED(Int) - - init() { - self = .xdbcSubcodeUnknown - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .xdbcSubcodeUnknown - case 1: self = .xdbcSubcodeYear - case 2: self = .xdbcSubcodeTime - case 3: self = .xdbcSubcodeTimestamp - case 4: self = .xdbcSubcodeTimeWithTimezone - case 5: self = .xdbcSubcodeTimestampWithTimezone - case 6: self = .xdbcSubcodeSecond - case 7: self = .xdbcSubcodeYearToMonth - case 8: self = .xdbcSubcodeDayToHour - case 9: self = .xdbcSubcodeDayToMinute - case 10: self = .xdbcSubcodeDayToSecond - case 11: self = .xdbcSubcodeHourToMinute - case 12: self = .xdbcSubcodeHourToSecond - case 13: self = .xdbcSubcodeMinuteToSecond - case 101: self = .xdbcSubcodeIntervalYear - case 102: self = .xdbcSubcodeIntervalMonth - case 103: self = .xdbcSubcodeIntervalDay - case 104: self = .xdbcSubcodeIntervalHour - case 105: self = .xdbcSubcodeIntervalMinute - case 106: self = .xdbcSubcodeIntervalSecond - case 107: self = .xdbcSubcodeIntervalYearToMonth - case 108: self = .xdbcSubcodeIntervalDayToHour - case 109: self = .xdbcSubcodeIntervalDayToMinute - case 110: self = .xdbcSubcodeIntervalDayToSecond - case 111: self = .xdbcSubcodeIntervalHourToMinute - case 112: self = .xdbcSubcodeIntervalHourToSecond - case 113: self = .xdbcSubcodeIntervalMinuteToSecond - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .xdbcSubcodeUnknown: return 0 - case .xdbcSubcodeYear: return 1 - case .xdbcSubcodeTime: return 2 - case .xdbcSubcodeTimestamp: return 3 - case .xdbcSubcodeTimeWithTimezone: return 4 - case .xdbcSubcodeTimestampWithTimezone: return 5 - case .xdbcSubcodeSecond: return 6 - case .xdbcSubcodeYearToMonth: return 7 - case .xdbcSubcodeDayToHour: return 8 - case .xdbcSubcodeDayToMinute: return 9 - case .xdbcSubcodeDayToSecond: return 10 - case .xdbcSubcodeHourToMinute: return 11 - case .xdbcSubcodeHourToSecond: return 12 - case .xdbcSubcodeMinuteToSecond: return 13 - case .xdbcSubcodeIntervalYear: return 101 - case .xdbcSubcodeIntervalMonth: return 102 - case .xdbcSubcodeIntervalDay: return 103 - case .xdbcSubcodeIntervalHour: return 104 - case .xdbcSubcodeIntervalMinute: return 105 - case .xdbcSubcodeIntervalSecond: return 106 - case .xdbcSubcodeIntervalYearToMonth: return 107 - case .xdbcSubcodeIntervalDayToHour: return 108 - case .xdbcSubcodeIntervalDayToMinute: return 109 - case .xdbcSubcodeIntervalDayToSecond: return 110 - case .xdbcSubcodeIntervalHourToMinute: return 111 - case .xdbcSubcodeIntervalHourToSecond: return 112 - case .xdbcSubcodeIntervalMinuteToSecond: return 113 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_XdbcDatetimeSubcode: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_XdbcDatetimeSubcode] = [ - .xdbcSubcodeUnknown, - .xdbcSubcodeYear, - .xdbcSubcodeTime, - .xdbcSubcodeTimestamp, - .xdbcSubcodeTimeWithTimezone, - .xdbcSubcodeTimestampWithTimezone, - .xdbcSubcodeSecond, - .xdbcSubcodeYearToMonth, - .xdbcSubcodeDayToHour, - .xdbcSubcodeDayToMinute, - .xdbcSubcodeDayToSecond, - .xdbcSubcodeHourToMinute, - .xdbcSubcodeHourToSecond, - .xdbcSubcodeMinuteToSecond, - .xdbcSubcodeIntervalYear, - .xdbcSubcodeIntervalMonth, - .xdbcSubcodeIntervalDay, - .xdbcSubcodeIntervalHour, - .xdbcSubcodeIntervalMinute, - .xdbcSubcodeIntervalSecond, - .xdbcSubcodeIntervalYearToMonth, - .xdbcSubcodeIntervalDayToHour, - .xdbcSubcodeIntervalDayToMinute, - .xdbcSubcodeIntervalDayToSecond, - .xdbcSubcodeIntervalHourToMinute, - .xdbcSubcodeIntervalHourToSecond, - .xdbcSubcodeIntervalMinuteToSecond, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_Nullable: SwiftProtobuf.Enum { - typealias RawValue = Int - - ///* - /// Indicates that the fields does not allow the use of null values. - case nullabilityNoNulls // = 0 - - ///* - /// Indicates that the fields allow the use of null values. - case nullabilityNullable // = 1 - - ///* - /// Indicates that nullability of the fields cannot be determined. - case nullabilityUnknown // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .nullabilityNoNulls - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .nullabilityNoNulls - case 1: self = .nullabilityNullable - case 2: self = .nullabilityUnknown - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .nullabilityNoNulls: return 0 - case .nullabilityNullable: return 1 - case .nullabilityUnknown: return 2 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_Nullable: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_Nullable] = [ - .nullabilityNoNulls, - .nullabilityNullable, - .nullabilityUnknown, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_Searchable: SwiftProtobuf.Enum { - typealias RawValue = Int - - ///* - /// Indicates that column cannot be used in a WHERE clause. - case none // = 0 - - ///* - /// Indicates that the column can be used in a WHERE clause if it is using a - /// LIKE operator. - case char // = 1 - - ///* - /// Indicates that the column can be used In a WHERE clause with any - /// operator other than LIKE. - /// - /// - Allowed operators: comparison, quantified comparison, BETWEEN, - /// DISTINCT, IN, MATCH, and UNIQUE. - case basic // = 2 - - ///* - /// Indicates that the column can be used in a WHERE clause using any operator. - case full // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .none - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .none - case 1: self = .char - case 2: self = .basic - case 3: self = .full - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .none: return 0 - case .char: return 1 - case .basic: return 2 - case .full: return 3 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_Searchable: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_Searchable] = [ - .none, - .char, - .basic, - .full, - ] -} - -#endif // swift(>=4.2) - -enum Arrow_Flight_Protocol_Sql_UpdateDeleteRules: SwiftProtobuf.Enum { - typealias RawValue = Int - case cascade // = 0 - case restrict // = 1 - case setNull // = 2 - case noAction // = 3 - case setDefault // = 4 - case UNRECOGNIZED(Int) - - init() { - self = .cascade - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .cascade - case 1: self = .restrict - case 2: self = .setNull - case 3: self = .noAction - case 4: self = .setDefault - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .cascade: return 0 - case .restrict: return 1 - case .setNull: return 2 - case .noAction: return 3 - case .setDefault: return 4 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_UpdateDeleteRules: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_UpdateDeleteRules] = [ - .cascade, - .restrict, - .setNull, - .noAction, - .setDefault, - ] -} - -#endif // swift(>=4.2) - -/// -/// Represents a metadata request. Used in the command member of FlightDescriptor -/// for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// info_name: uint32 not null, -/// value: dense_union< -/// string_value: utf8, -/// bool_value: bool, -/// bigint_value: int64, -/// int32_bitmask: int32, -/// string_list: list -/// int32_to_int32_list_map: map> -/// > -/// where there is one row per requested piece of metadata information. -struct Arrow_Flight_Protocol_Sql_CommandGetSqlInfo { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Values are modelled after ODBC's SQLGetInfo() function. This information is intended to provide - /// Flight SQL clients with basic, SQL syntax and SQL functions related information. - /// More information types can be added in future releases. - /// E.g. more SQL syntax support types, scalar functions support, type conversion support etc. - /// - /// Note that the set of metadata may expand. - /// - /// Initially, Flight SQL will support the following information types: - /// - Server Information - Range [0-500) - /// - Syntax Information - Range [500-1000) - /// Range [0-10,000) is reserved for defaults (see SqlInfo enum for default options). - /// Custom options should start at 10,000. - /// - /// If omitted, then all metadata will be retrieved. - /// Flight SQL Servers may choose to include additional metadata above and beyond the specified set, however they must - /// at least return the specified set. IDs ranging from 0 to 10,000 (exclusive) are reserved for future use. - /// If additional metadata is included, the metadata IDs should start from 10,000. - var info: [UInt32] = [] - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Represents a request to retrieve information about data type supported on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned schema will be: -/// < -/// type_name: utf8 not null (The name of the data type, for example: VARCHAR, INTEGER, etc), -/// data_type: int32 not null (The SQL data type), -/// column_size: int32 (The maximum size supported by that column. -/// In case of exact numeric types, this represents the maximum precision. -/// In case of string types, this represents the character length. -/// In case of datetime data types, this represents the length in characters of the string representation. -/// NULL is returned for data types where column size is not applicable.), -/// literal_prefix: utf8 (Character or characters used to prefix a literal, NULL is returned for -/// data types where a literal prefix is not applicable.), -/// literal_suffix: utf8 (Character or characters used to terminate a literal, -/// NULL is returned for data types where a literal suffix is not applicable.), -/// create_params: list -/// (A list of keywords corresponding to which parameters can be used when creating -/// a column for that specific type. -/// NULL is returned if there are no parameters for the data type definition.), -/// nullable: int32 not null (Shows if the data type accepts a NULL value. The possible values can be seen in the -/// Nullable enum.), -/// case_sensitive: bool not null (Shows if a character data type is case-sensitive in collations and comparisons), -/// searchable: int32 not null (Shows how the data type is used in a WHERE clause. The possible values can be seen in the -/// Searchable enum.), -/// unsigned_attribute: bool (Shows if the data type is unsigned. NULL is returned if the attribute is -/// not applicable to the data type or the data type is not numeric.), -/// fixed_prec_scale: bool not null (Shows if the data type has predefined fixed precision and scale.), -/// auto_increment: bool (Shows if the data type is auto incremental. NULL is returned if the attribute -/// is not applicable to the data type or the data type is not numeric.), -/// local_type_name: utf8 (Localized version of the data source-dependent name of the data type. NULL -/// is returned if a localized name is not supported by the data source), -/// minimum_scale: int32 (The minimum scale of the data type on the data source. -/// If a data type has a fixed scale, the MINIMUM_SCALE and MAXIMUM_SCALE -/// columns both contain this value. NULL is returned if scale is not applicable.), -/// maximum_scale: int32 (The maximum scale of the data type on the data source. -/// NULL is returned if scale is not applicable.), -/// sql_data_type: int32 not null (The value of the SQL DATA TYPE which has the same values -/// as data_type value. Except for interval and datetime, which -/// uses generic values. More info about those types can be -/// obtained through datetime_subcode. The possible values can be seen -/// in the XdbcDataType enum.), -/// datetime_subcode: int32 (Only used when the SQL DATA TYPE is interval or datetime. It contains -/// its sub types. For type different from interval and datetime, this value -/// is NULL. The possible values can be seen in the XdbcDatetimeSubcode enum.), -/// num_prec_radix: int32 (If the data type is an approximate numeric type, this column contains -/// the value 2 to indicate that COLUMN_SIZE specifies a number of bits. For -/// exact numeric types, this column contains the value 10 to indicate that -/// column size specifies a number of decimal digits. Otherwise, this column is NULL.), -/// interval_precision: int32 (If the data type is an interval data type, then this column contains the value -/// of the interval leading precision. Otherwise, this column is NULL. This fields -/// is only relevant to be used by ODBC). -/// > -/// The returned data should be ordered by data_type and then by type_name. -struct Arrow_Flight_Protocol_Sql_CommandGetXdbcTypeInfo { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the data type to search for the info. - var dataType: Int32 { - get {return _dataType ?? 0} - set {_dataType = newValue} - } - /// Returns true if `dataType` has been explicitly set. - var hasDataType: Bool {return self._dataType != nil} - /// Clears the value of `dataType`. Subsequent reads from it will return its default value. - mutating func clearDataType() {self._dataType = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _dataType: Int32? = nil -} - -/// -/// Represents a request to retrieve the list of catalogs on a Flight SQL enabled backend. -/// The definition of a catalog depends on vendor/implementation. It is usually the database itself -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// catalog_name: utf8 not null -/// > -/// The returned data should be ordered by catalog_name. -struct Arrow_Flight_Protocol_Sql_CommandGetCatalogs { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Represents a request to retrieve the list of database schemas on a Flight SQL enabled backend. -/// The definition of a database schema depends on vendor/implementation. It is usually a collection of tables. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// catalog_name: utf8, -/// db_schema_name: utf8 not null -/// > -/// The returned data should be ordered by catalog_name, then db_schema_name. -struct Arrow_Flight_Protocol_Sql_CommandGetDbSchemas { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the Catalog to search for the tables. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var catalog: String { - get {return _catalog ?? String()} - set {_catalog = newValue} - } - /// Returns true if `catalog` has been explicitly set. - var hasCatalog: Bool {return self._catalog != nil} - /// Clears the value of `catalog`. Subsequent reads from it will return its default value. - mutating func clearCatalog() {self._catalog = nil} - - /// - /// Specifies a filter pattern for schemas to search for. - /// When no db_schema_filter_pattern is provided, the pattern will not be used to narrow the search. - /// In the pattern string, two special characters can be used to denote matching rules: - /// - "%" means to match any substring with 0 or more characters. - /// - "_" means to match any one character. - var dbSchemaFilterPattern: String { - get {return _dbSchemaFilterPattern ?? String()} - set {_dbSchemaFilterPattern = newValue} - } - /// Returns true if `dbSchemaFilterPattern` has been explicitly set. - var hasDbSchemaFilterPattern: Bool {return self._dbSchemaFilterPattern != nil} - /// Clears the value of `dbSchemaFilterPattern`. Subsequent reads from it will return its default value. - mutating func clearDbSchemaFilterPattern() {self._dbSchemaFilterPattern = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _catalog: String? = nil - fileprivate var _dbSchemaFilterPattern: String? = nil -} - -/// -/// Represents a request to retrieve the list of tables, and optionally their schemas, on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// catalog_name: utf8, -/// db_schema_name: utf8, -/// table_name: utf8 not null, -/// table_type: utf8 not null, -/// [optional] table_schema: bytes not null (schema of the table as described in Schema.fbs::Schema, -/// it is serialized as an IPC message.) -/// > -/// Fields on table_schema may contain the following metadata: -/// - ARROW:FLIGHT:SQL:CATALOG_NAME - Table's catalog name -/// - ARROW:FLIGHT:SQL:DB_SCHEMA_NAME - Database schema name -/// - ARROW:FLIGHT:SQL:TABLE_NAME - Table name -/// - ARROW:FLIGHT:SQL:TYPE_NAME - The data source-specific name for the data type of the column. -/// - ARROW:FLIGHT:SQL:PRECISION - Column precision/size -/// - ARROW:FLIGHT:SQL:SCALE - Column scale/decimal digits if applicable -/// - ARROW:FLIGHT:SQL:IS_AUTO_INCREMENT - "1" indicates if the column is auto incremented, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. -/// The returned data should be ordered by catalog_name, db_schema_name, table_name, then table_type, followed by table_schema if requested. -struct Arrow_Flight_Protocol_Sql_CommandGetTables { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the Catalog to search for the tables. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var catalog: String { - get {return _catalog ?? String()} - set {_catalog = newValue} - } - /// Returns true if `catalog` has been explicitly set. - var hasCatalog: Bool {return self._catalog != nil} - /// Clears the value of `catalog`. Subsequent reads from it will return its default value. - mutating func clearCatalog() {self._catalog = nil} - - /// - /// Specifies a filter pattern for schemas to search for. - /// When no db_schema_filter_pattern is provided, all schemas matching other filters are searched. - /// In the pattern string, two special characters can be used to denote matching rules: - /// - "%" means to match any substring with 0 or more characters. - /// - "_" means to match any one character. - var dbSchemaFilterPattern: String { - get {return _dbSchemaFilterPattern ?? String()} - set {_dbSchemaFilterPattern = newValue} - } - /// Returns true if `dbSchemaFilterPattern` has been explicitly set. - var hasDbSchemaFilterPattern: Bool {return self._dbSchemaFilterPattern != nil} - /// Clears the value of `dbSchemaFilterPattern`. Subsequent reads from it will return its default value. - mutating func clearDbSchemaFilterPattern() {self._dbSchemaFilterPattern = nil} - - /// - /// Specifies a filter pattern for tables to search for. - /// When no table_name_filter_pattern is provided, all tables matching other filters are searched. - /// In the pattern string, two special characters can be used to denote matching rules: - /// - "%" means to match any substring with 0 or more characters. - /// - "_" means to match any one character. - var tableNameFilterPattern: String { - get {return _tableNameFilterPattern ?? String()} - set {_tableNameFilterPattern = newValue} - } - /// Returns true if `tableNameFilterPattern` has been explicitly set. - var hasTableNameFilterPattern: Bool {return self._tableNameFilterPattern != nil} - /// Clears the value of `tableNameFilterPattern`. Subsequent reads from it will return its default value. - mutating func clearTableNameFilterPattern() {self._tableNameFilterPattern = nil} - - /// - /// Specifies a filter of table types which must match. - /// The table types depend on vendor/implementation. It is usually used to separate tables from views or system tables. - /// TABLE, VIEW, and SYSTEM TABLE are commonly supported. - var tableTypes: [String] = [] - - /// Specifies if the Arrow schema should be returned for found tables. - var includeSchema: Bool = false - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _catalog: String? = nil - fileprivate var _dbSchemaFilterPattern: String? = nil - fileprivate var _tableNameFilterPattern: String? = nil -} - -/// -/// Represents a request to retrieve the list of table types on a Flight SQL enabled backend. -/// The table types depend on vendor/implementation. It is usually used to separate tables from views or system tables. -/// TABLE, VIEW, and SYSTEM TABLE are commonly supported. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// table_type: utf8 not null -/// > -/// The returned data should be ordered by table_type. -struct Arrow_Flight_Protocol_Sql_CommandGetTableTypes { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Represents a request to retrieve the primary keys of a table on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// catalog_name: utf8, -/// db_schema_name: utf8, -/// table_name: utf8 not null, -/// column_name: utf8 not null, -/// key_name: utf8, -/// key_sequence: int32 not null -/// > -/// The returned data should be ordered by catalog_name, db_schema_name, table_name, key_name, then key_sequence. -struct Arrow_Flight_Protocol_Sql_CommandGetPrimaryKeys { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the catalog to search for the table. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var catalog: String { - get {return _catalog ?? String()} - set {_catalog = newValue} - } - /// Returns true if `catalog` has been explicitly set. - var hasCatalog: Bool {return self._catalog != nil} - /// Clears the value of `catalog`. Subsequent reads from it will return its default value. - mutating func clearCatalog() {self._catalog = nil} - - /// - /// Specifies the schema to search for the table. - /// An empty string retrieves those without a schema. - /// If omitted the schema name should not be used to narrow the search. - var dbSchema: String { - get {return _dbSchema ?? String()} - set {_dbSchema = newValue} - } - /// Returns true if `dbSchema` has been explicitly set. - var hasDbSchema: Bool {return self._dbSchema != nil} - /// Clears the value of `dbSchema`. Subsequent reads from it will return its default value. - mutating func clearDbSchema() {self._dbSchema = nil} - - /// Specifies the table to get the primary keys for. - var table: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _catalog: String? = nil - fileprivate var _dbSchema: String? = nil -} - -/// -/// Represents a request to retrieve a description of the foreign key columns that reference the given table's -/// primary key columns (the foreign keys exported by a table) of a table on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// pk_catalog_name: utf8, -/// pk_db_schema_name: utf8, -/// pk_table_name: utf8 not null, -/// pk_column_name: utf8 not null, -/// fk_catalog_name: utf8, -/// fk_db_schema_name: utf8, -/// fk_table_name: utf8 not null, -/// fk_column_name: utf8 not null, -/// key_sequence: int32 not null, -/// fk_key_name: utf8, -/// pk_key_name: utf8, -/// update_rule: uint8 not null, -/// delete_rule: uint8 not null -/// > -/// The returned data should be ordered by fk_catalog_name, fk_db_schema_name, fk_table_name, fk_key_name, then key_sequence. -/// update_rule and delete_rule returns a byte that is equivalent to actions declared on UpdateDeleteRules enum. -struct Arrow_Flight_Protocol_Sql_CommandGetExportedKeys { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the catalog to search for the foreign key table. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var catalog: String { - get {return _catalog ?? String()} - set {_catalog = newValue} - } - /// Returns true if `catalog` has been explicitly set. - var hasCatalog: Bool {return self._catalog != nil} - /// Clears the value of `catalog`. Subsequent reads from it will return its default value. - mutating func clearCatalog() {self._catalog = nil} - - /// - /// Specifies the schema to search for the foreign key table. - /// An empty string retrieves those without a schema. - /// If omitted the schema name should not be used to narrow the search. - var dbSchema: String { - get {return _dbSchema ?? String()} - set {_dbSchema = newValue} - } - /// Returns true if `dbSchema` has been explicitly set. - var hasDbSchema: Bool {return self._dbSchema != nil} - /// Clears the value of `dbSchema`. Subsequent reads from it will return its default value. - mutating func clearDbSchema() {self._dbSchema = nil} - - /// Specifies the foreign key table to get the foreign keys for. - var table: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _catalog: String? = nil - fileprivate var _dbSchema: String? = nil -} - -/// -/// Represents a request to retrieve the foreign keys of a table on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// pk_catalog_name: utf8, -/// pk_db_schema_name: utf8, -/// pk_table_name: utf8 not null, -/// pk_column_name: utf8 not null, -/// fk_catalog_name: utf8, -/// fk_db_schema_name: utf8, -/// fk_table_name: utf8 not null, -/// fk_column_name: utf8 not null, -/// key_sequence: int32 not null, -/// fk_key_name: utf8, -/// pk_key_name: utf8, -/// update_rule: uint8 not null, -/// delete_rule: uint8 not null -/// > -/// The returned data should be ordered by pk_catalog_name, pk_db_schema_name, pk_table_name, pk_key_name, then key_sequence. -/// update_rule and delete_rule returns a byte that is equivalent to actions: -/// - 0 = CASCADE -/// - 1 = RESTRICT -/// - 2 = SET NULL -/// - 3 = NO ACTION -/// - 4 = SET DEFAULT -struct Arrow_Flight_Protocol_Sql_CommandGetImportedKeys { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// Specifies the catalog to search for the primary key table. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var catalog: String { - get {return _catalog ?? String()} - set {_catalog = newValue} - } - /// Returns true if `catalog` has been explicitly set. - var hasCatalog: Bool {return self._catalog != nil} - /// Clears the value of `catalog`. Subsequent reads from it will return its default value. - mutating func clearCatalog() {self._catalog = nil} - - /// - /// Specifies the schema to search for the primary key table. - /// An empty string retrieves those without a schema. - /// If omitted the schema name should not be used to narrow the search. - var dbSchema: String { - get {return _dbSchema ?? String()} - set {_dbSchema = newValue} - } - /// Returns true if `dbSchema` has been explicitly set. - var hasDbSchema: Bool {return self._dbSchema != nil} - /// Clears the value of `dbSchema`. Subsequent reads from it will return its default value. - mutating func clearDbSchema() {self._dbSchema = nil} - - /// Specifies the primary key table to get the foreign keys for. - var table: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _catalog: String? = nil - fileprivate var _dbSchema: String? = nil -} - -/// -/// Represents a request to retrieve a description of the foreign key columns in the given foreign key table that -/// reference the primary key or the columns representing a unique constraint of the parent table (could be the same -/// or a different table) on a Flight SQL enabled backend. -/// Used in the command member of FlightDescriptor for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// - GetFlightInfo: execute the catalog metadata request. -/// -/// The returned Arrow schema will be: -/// < -/// pk_catalog_name: utf8, -/// pk_db_schema_name: utf8, -/// pk_table_name: utf8 not null, -/// pk_column_name: utf8 not null, -/// fk_catalog_name: utf8, -/// fk_db_schema_name: utf8, -/// fk_table_name: utf8 not null, -/// fk_column_name: utf8 not null, -/// key_sequence: int32 not null, -/// fk_key_name: utf8, -/// pk_key_name: utf8, -/// update_rule: uint8 not null, -/// delete_rule: uint8 not null -/// > -/// The returned data should be ordered by pk_catalog_name, pk_db_schema_name, pk_table_name, pk_key_name, then key_sequence. -/// update_rule and delete_rule returns a byte that is equivalent to actions: -/// - 0 = CASCADE -/// - 1 = RESTRICT -/// - 2 = SET NULL -/// - 3 = NO ACTION -/// - 4 = SET DEFAULT -struct Arrow_Flight_Protocol_Sql_CommandGetCrossReference { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - ///* - /// The catalog name where the parent table is. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var pkCatalog: String { - get {return _pkCatalog ?? String()} - set {_pkCatalog = newValue} - } - /// Returns true if `pkCatalog` has been explicitly set. - var hasPkCatalog: Bool {return self._pkCatalog != nil} - /// Clears the value of `pkCatalog`. Subsequent reads from it will return its default value. - mutating func clearPkCatalog() {self._pkCatalog = nil} - - ///* - /// The Schema name where the parent table is. - /// An empty string retrieves those without a schema. - /// If omitted the schema name should not be used to narrow the search. - var pkDbSchema: String { - get {return _pkDbSchema ?? String()} - set {_pkDbSchema = newValue} - } - /// Returns true if `pkDbSchema` has been explicitly set. - var hasPkDbSchema: Bool {return self._pkDbSchema != nil} - /// Clears the value of `pkDbSchema`. Subsequent reads from it will return its default value. - mutating func clearPkDbSchema() {self._pkDbSchema = nil} - - ///* - /// The parent table name. It cannot be null. - var pkTable: String = String() - - ///* - /// The catalog name where the foreign table is. - /// An empty string retrieves those without a catalog. - /// If omitted the catalog name should not be used to narrow the search. - var fkCatalog: String { - get {return _fkCatalog ?? String()} - set {_fkCatalog = newValue} - } - /// Returns true if `fkCatalog` has been explicitly set. - var hasFkCatalog: Bool {return self._fkCatalog != nil} - /// Clears the value of `fkCatalog`. Subsequent reads from it will return its default value. - mutating func clearFkCatalog() {self._fkCatalog = nil} - - ///* - /// The schema name where the foreign table is. - /// An empty string retrieves those without a schema. - /// If omitted the schema name should not be used to narrow the search. - var fkDbSchema: String { - get {return _fkDbSchema ?? String()} - set {_fkDbSchema = newValue} - } - /// Returns true if `fkDbSchema` has been explicitly set. - var hasFkDbSchema: Bool {return self._fkDbSchema != nil} - /// Clears the value of `fkDbSchema`. Subsequent reads from it will return its default value. - mutating func clearFkDbSchema() {self._fkDbSchema = nil} - - ///* - /// The foreign table name. It cannot be null. - var fkTable: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _pkCatalog: String? = nil - fileprivate var _pkDbSchema: String? = nil - fileprivate var _fkCatalog: String? = nil - fileprivate var _fkDbSchema: String? = nil -} - -/// -/// Request message for the "CreatePreparedStatement" action on a Flight SQL enabled backend. -struct Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The valid SQL string to create a prepared statement for. - var query: String = String() - - /// Create/execute the prepared statement as part of this transaction (if - /// unset, executions of the prepared statement will be auto-committed). - var transactionID: Data { - get {return _transactionID ?? Data()} - set {_transactionID = newValue} - } - /// Returns true if `transactionID` has been explicitly set. - var hasTransactionID: Bool {return self._transactionID != nil} - /// Clears the value of `transactionID`. Subsequent reads from it will return its default value. - mutating func clearTransactionID() {self._transactionID = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _transactionID: Data? = nil -} - -/// -/// An embedded message describing a Substrait plan to execute. -struct Arrow_Flight_Protocol_Sql_SubstraitPlan { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The serialized substrait.Plan to create a prepared statement for. - /// XXX(ARROW-16902): this is bytes instead of an embedded message - /// because Protobuf does not really support one DLL using Protobuf - /// definitions from another DLL. - var plan: Data = Data() - - /// The Substrait release, e.g. "0.12.0". This information is not - /// tracked in the plan itself, so this is the only way for consumers - /// to potentially know if they can handle the plan. - var version: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "CreatePreparedSubstraitPlan" action on a Flight SQL enabled backend. -struct Arrow_Flight_Protocol_Sql_ActionCreatePreparedSubstraitPlanRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The serialized substrait.Plan to create a prepared statement for. - var plan: Arrow_Flight_Protocol_Sql_SubstraitPlan { - get {return _plan ?? Arrow_Flight_Protocol_Sql_SubstraitPlan()} - set {_plan = newValue} - } - /// Returns true if `plan` has been explicitly set. - var hasPlan: Bool {return self._plan != nil} - /// Clears the value of `plan`. Subsequent reads from it will return its default value. - mutating func clearPlan() {self._plan = nil} - - /// Create/execute the prepared statement as part of this transaction (if - /// unset, executions of the prepared statement will be auto-committed). - var transactionID: Data { - get {return _transactionID ?? Data()} - set {_transactionID = newValue} - } - /// Returns true if `transactionID` has been explicitly set. - var hasTransactionID: Bool {return self._transactionID != nil} - /// Clears the value of `transactionID`. Subsequent reads from it will return its default value. - mutating func clearTransactionID() {self._transactionID = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _plan: Arrow_Flight_Protocol_Sql_SubstraitPlan? = nil - fileprivate var _transactionID: Data? = nil -} - -/// -/// Wrap the result of a "CreatePreparedStatement" or "CreatePreparedSubstraitPlan" action. -/// -/// The resultant PreparedStatement can be closed either: -/// - Manually, through the "ClosePreparedStatement" action; -/// - Automatically, by a server timeout. -/// -/// The result should be wrapped in a google.protobuf.Any message. -struct Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the prepared statement on the server. - var preparedStatementHandle: Data = Data() - - /// If a result set generating query was provided, dataset_schema contains the - /// schema of the dataset as described in Schema.fbs::Schema, it is serialized as an IPC message. - var datasetSchema: Data = Data() - - /// If the query provided contained parameters, parameter_schema contains the - /// schema of the expected parameters as described in Schema.fbs::Schema, it is serialized as an IPC message. - var parameterSchema: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "ClosePreparedStatement" action on a Flight SQL enabled backend. -/// Closes server resources associated with the prepared statement handle. -struct Arrow_Flight_Protocol_Sql_ActionClosePreparedStatementRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the prepared statement on the server. - var preparedStatementHandle: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "BeginTransaction" action. -/// Begins a transaction. -struct Arrow_Flight_Protocol_Sql_ActionBeginTransactionRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "BeginSavepoint" action. -/// Creates a savepoint within a transaction. -/// -/// Only supported if FLIGHT_SQL_TRANSACTION is -/// FLIGHT_SQL_TRANSACTION_SUPPORT_SAVEPOINT. -struct Arrow_Flight_Protocol_Sql_ActionBeginSavepointRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The transaction to which a savepoint belongs. - var transactionID: Data = Data() - - /// Name for the savepoint. - var name: String = String() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The result of a "BeginTransaction" action. -/// -/// The transaction can be manipulated with the "EndTransaction" action, or -/// automatically via server timeout. If the transaction times out, then it is -/// automatically rolled back. -/// -/// The result should be wrapped in a google.protobuf.Any message. -struct Arrow_Flight_Protocol_Sql_ActionBeginTransactionResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the transaction on the server. - var transactionID: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The result of a "BeginSavepoint" action. -/// -/// The transaction can be manipulated with the "EndSavepoint" action. -/// If the associated transaction is committed, rolled back, or times -/// out, then the savepoint is also invalidated. -/// -/// The result should be wrapped in a google.protobuf.Any message. -struct Arrow_Flight_Protocol_Sql_ActionBeginSavepointResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the savepoint on the server. - var savepointID: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "EndTransaction" action. -/// -/// Commit (COMMIT) or rollback (ROLLBACK) the transaction. -/// -/// If the action completes successfully, the transaction handle is -/// invalidated, as are all associated savepoints. -struct Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the transaction on the server. - var transactionID: Data = Data() - - /// Whether to commit/rollback the given transaction. - var action: Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest.EndTransaction = .unspecified - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum EndTransaction: SwiftProtobuf.Enum { - typealias RawValue = Int - case unspecified // = 0 - - /// Commit the transaction. - case commit // = 1 - - /// Roll back the transaction. - case rollback // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .unspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .commit - case 2: self = .rollback - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .unspecified: return 0 - case .commit: return 1 - case .rollback: return 2 - case .UNRECOGNIZED(let i): return i - } - } - - } - - init() {} -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest.EndTransaction: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest.EndTransaction] = [ - .unspecified, - .commit, - .rollback, - ] -} - -#endif // swift(>=4.2) - -/// -/// Request message for the "EndSavepoint" action. -/// -/// Release (RELEASE) the savepoint or rollback (ROLLBACK) to the -/// savepoint. -/// -/// Releasing a savepoint invalidates that savepoint. Rolling back to -/// a savepoint does not invalidate the savepoint, but invalidates all -/// savepoints created after the current savepoint. -struct Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the savepoint on the server. - var savepointID: Data = Data() - - /// Whether to rollback/release the given savepoint. - var action: Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest.EndSavepoint = .unspecified - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum EndSavepoint: SwiftProtobuf.Enum { - typealias RawValue = Int - case unspecified // = 0 - - /// Release the savepoint. - case release // = 1 - - /// Roll back to a savepoint. - case rollback // = 2 - case UNRECOGNIZED(Int) - - init() { - self = .unspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .release - case 2: self = .rollback - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .unspecified: return 0 - case .release: return 1 - case .rollback: return 2 - case .UNRECOGNIZED(let i): return i - } - } - - } - - init() {} -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest.EndSavepoint: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest.EndSavepoint] = [ - .unspecified, - .release, - .rollback, - ] -} - -#endif // swift(>=4.2) - -/// -/// Represents a SQL query. Used in the command member of FlightDescriptor -/// for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// Fields on this schema may contain the following metadata: -/// - ARROW:FLIGHT:SQL:CATALOG_NAME - Table's catalog name -/// - ARROW:FLIGHT:SQL:DB_SCHEMA_NAME - Database schema name -/// - ARROW:FLIGHT:SQL:TABLE_NAME - Table name -/// - ARROW:FLIGHT:SQL:TYPE_NAME - The data source-specific name for the data type of the column. -/// - ARROW:FLIGHT:SQL:PRECISION - Column precision/size -/// - ARROW:FLIGHT:SQL:SCALE - Column scale/decimal digits if applicable -/// - ARROW:FLIGHT:SQL:IS_AUTO_INCREMENT - "1" indicates if the column is auto incremented, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. -/// - GetFlightInfo: execute the query. -struct Arrow_Flight_Protocol_Sql_CommandStatementQuery { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The SQL syntax. - var query: String = String() - - /// Include the query as part of this transaction (if unset, the query is auto-committed). - var transactionID: Data { - get {return _transactionID ?? Data()} - set {_transactionID = newValue} - } - /// Returns true if `transactionID` has been explicitly set. - var hasTransactionID: Bool {return self._transactionID != nil} - /// Clears the value of `transactionID`. Subsequent reads from it will return its default value. - mutating func clearTransactionID() {self._transactionID = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _transactionID: Data? = nil -} - -/// -/// Represents a Substrait plan. Used in the command member of FlightDescriptor -/// for the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// Fields on this schema may contain the following metadata: -/// - ARROW:FLIGHT:SQL:CATALOG_NAME - Table's catalog name -/// - ARROW:FLIGHT:SQL:DB_SCHEMA_NAME - Database schema name -/// - ARROW:FLIGHT:SQL:TABLE_NAME - Table name -/// - ARROW:FLIGHT:SQL:TYPE_NAME - The data source-specific name for the data type of the column. -/// - ARROW:FLIGHT:SQL:PRECISION - Column precision/size -/// - ARROW:FLIGHT:SQL:SCALE - Column scale/decimal digits if applicable -/// - ARROW:FLIGHT:SQL:IS_AUTO_INCREMENT - "1" indicates if the column is auto incremented, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. -/// - GetFlightInfo: execute the query. -/// - DoPut: execute the query. -struct Arrow_Flight_Protocol_Sql_CommandStatementSubstraitPlan { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// A serialized substrait.Plan - var plan: Arrow_Flight_Protocol_Sql_SubstraitPlan { - get {return _plan ?? Arrow_Flight_Protocol_Sql_SubstraitPlan()} - set {_plan = newValue} - } - /// Returns true if `plan` has been explicitly set. - var hasPlan: Bool {return self._plan != nil} - /// Clears the value of `plan`. Subsequent reads from it will return its default value. - mutating func clearPlan() {self._plan = nil} - - /// Include the query as part of this transaction (if unset, the query is auto-committed). - var transactionID: Data { - get {return _transactionID ?? Data()} - set {_transactionID = newValue} - } - /// Returns true if `transactionID` has been explicitly set. - var hasTransactionID: Bool {return self._transactionID != nil} - /// Clears the value of `transactionID`. Subsequent reads from it will return its default value. - mutating func clearTransactionID() {self._transactionID = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _plan: Arrow_Flight_Protocol_Sql_SubstraitPlan? = nil - fileprivate var _transactionID: Data? = nil -} - -///* -/// Represents a ticket resulting from GetFlightInfo with a CommandStatementQuery. -/// This should be used only once and treated as an opaque value, that is, clients should not attempt to parse this. -struct Arrow_Flight_Protocol_Sql_TicketStatementQuery { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Unique identifier for the instance of the statement to execute. - var statementHandle: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Represents an instance of executing a prepared statement. Used in the command member of FlightDescriptor for -/// the following RPC calls: -/// - GetSchema: return the Arrow schema of the query. -/// Fields on this schema may contain the following metadata: -/// - ARROW:FLIGHT:SQL:CATALOG_NAME - Table's catalog name -/// - ARROW:FLIGHT:SQL:DB_SCHEMA_NAME - Database schema name -/// - ARROW:FLIGHT:SQL:TABLE_NAME - Table name -/// - ARROW:FLIGHT:SQL:TYPE_NAME - The data source-specific name for the data type of the column. -/// - ARROW:FLIGHT:SQL:PRECISION - Column precision/size -/// - ARROW:FLIGHT:SQL:SCALE - Column scale/decimal digits if applicable -/// - ARROW:FLIGHT:SQL:IS_AUTO_INCREMENT - "1" indicates if the column is auto incremented, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. -/// - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. -/// - DoPut: bind parameter values. All of the bound parameter sets will be executed as a single atomic execution. -/// - GetFlightInfo: execute the prepared statement instance. -struct Arrow_Flight_Protocol_Sql_CommandPreparedStatementQuery { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the prepared statement on the server. - var preparedStatementHandle: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Represents a SQL update query. Used in the command member of FlightDescriptor -/// for the RPC call DoPut to cause the server to execute the included SQL update. -struct Arrow_Flight_Protocol_Sql_CommandStatementUpdate { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The SQL syntax. - var query: String = String() - - /// Include the query as part of this transaction (if unset, the query is auto-committed). - var transactionID: Data { - get {return _transactionID ?? Data()} - set {_transactionID = newValue} - } - /// Returns true if `transactionID` has been explicitly set. - var hasTransactionID: Bool {return self._transactionID != nil} - /// Clears the value of `transactionID`. Subsequent reads from it will return its default value. - mutating func clearTransactionID() {self._transactionID = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _transactionID: Data? = nil -} - -/// -/// Represents a SQL update query. Used in the command member of FlightDescriptor -/// for the RPC call DoPut to cause the server to execute the included -/// prepared statement handle as an update. -struct Arrow_Flight_Protocol_Sql_CommandPreparedStatementUpdate { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// Opaque handle for the prepared statement on the server. - var preparedStatementHandle: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Returned from the RPC call DoPut when a CommandStatementUpdate -/// CommandPreparedStatementUpdate was in the request, containing -/// results from the update. -struct Arrow_Flight_Protocol_Sql_DoPutUpdateResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The number of records updated. A return value of -1 represents - /// an unknown updated record count. - var recordCount: Int64 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// Request message for the "CancelQuery" action. -/// -/// Explicitly cancel a running query. -/// -/// This lets a single client explicitly cancel work, no matter how many clients -/// are involved/whether the query is distributed or not, given server support. -/// The transaction/statement is not rolled back; it is the application's job to -/// commit or rollback as appropriate. This only indicates the client no longer -/// wishes to read the remainder of the query results or continue submitting -/// data. -/// -/// This command is idempotent. -/// -/// This command is deprecated since 13.0.0. Use the "CancelFlightInfo" -/// action with DoAction instead. -struct Arrow_Flight_Protocol_Sql_ActionCancelQueryRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// The result of the GetFlightInfo RPC that initiated the query. - /// XXX(ARROW-16902): this must be a serialized FlightInfo, but is - /// rendered as bytes because Protobuf does not really support one - /// DLL using Protobuf definitions from another DLL. - var info: Data = Data() - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -/// -/// The result of cancelling a query. -/// -/// The result should be wrapped in a google.protobuf.Any message. -/// -/// This command is deprecated since 13.0.0. Use the "CancelFlightInfo" -/// action with DoAction instead. -struct Arrow_Flight_Protocol_Sql_ActionCancelQueryResult { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - var result: Arrow_Flight_Protocol_Sql_ActionCancelQueryResult.CancelResult = .unspecified - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum CancelResult: SwiftProtobuf.Enum { - typealias RawValue = Int - - /// The cancellation status is unknown. Servers should avoid using - /// this value (send a NOT_FOUND error if the requested query is - /// not known). Clients can retry the request. - case unspecified // = 0 - - /// The cancellation request is complete. Subsequent requests with - /// the same payload may return CANCELLED or a NOT_FOUND error. - case cancelled // = 1 - - /// The cancellation request is in progress. The client may retry - /// the cancellation request. - case cancelling // = 2 - - /// The query is not cancellable. The client should not retry the - /// cancellation request. - case notCancellable // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .unspecified - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .unspecified - case 1: self = .cancelled - case 2: self = .cancelling - case 3: self = .notCancellable - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .unspecified: return 0 - case .cancelled: return 1 - case .cancelling: return 2 - case .notCancellable: return 3 - case .UNRECOGNIZED(let i): return i - } - } - - } - - init() {} -} - -#if swift(>=4.2) - -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryResult.CancelResult: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Arrow_Flight_Protocol_Sql_ActionCancelQueryResult.CancelResult] = [ - .unspecified, - .cancelled, - .cancelling, - .notCancellable, - ] -} - -#endif // swift(>=4.2) - -#if swift(>=5.5) && canImport(_Concurrency) -extension Arrow_Flight_Protocol_Sql_SqlInfo: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransaction: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedCaseSensitivity: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlNullOrdering: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SupportedSqlGrammar: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SupportedAnsi92SqlGrammarLevel: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlOuterJoinsSupportLevel: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedGroupBy: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedElementActions: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedPositionedCommands: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedSubqueries: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedUnions: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlTransactionIsolationLevel: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransactions: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetType: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetConcurrency: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SqlSupportsConvert: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_XdbcDataType: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_XdbcDatetimeSubcode: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_Nullable: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_Searchable: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_UpdateDeleteRules: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetSqlInfo: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetXdbcTypeInfo: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetCatalogs: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetDbSchemas: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetTables: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetTableTypes: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetPrimaryKeys: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetExportedKeys: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetImportedKeys: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandGetCrossReference: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_SubstraitPlan: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedSubstraitPlanRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionClosePreparedStatementRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionBeginTransactionRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionBeginSavepointRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionBeginTransactionResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionBeginSavepointResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest.EndTransaction: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest.EndSavepoint: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandStatementQuery: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandStatementSubstraitPlan: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_TicketStatementQuery: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandPreparedStatementQuery: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandStatementUpdate: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_CommandPreparedStatementUpdate: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_DoPutUpdateResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryRequest: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryResult: @unchecked Sendable {} -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryResult.CancelResult: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - -// MARK: - Extension support defined in FlightSql.proto. - -// MARK: - Extension Properties - -// Swift Extensions on the extended Messages to add easy access to the declared -// extension fields. The names are based on the extension field name from the proto -// declaration. To avoid naming collisions, the names are prefixed with the name of -// the scope where the extend directive occurs. - -extension SwiftProtobuf.Google_Protobuf_MessageOptions { - - var Arrow_Flight_Protocol_Sql_experimental: Bool { - get {return getExtensionValue(ext: Arrow_Flight_Protocol_Sql_Extensions_experimental) ?? false} - set {setExtensionValue(ext: Arrow_Flight_Protocol_Sql_Extensions_experimental, value: newValue)} - } - /// Returns true if extension `Arrow_Flight_Protocol_Sql_Extensions_experimental` - /// has been explicitly set. - var hasArrow_Flight_Protocol_Sql_experimental: Bool { - return hasExtensionValue(ext: Arrow_Flight_Protocol_Sql_Extensions_experimental) - } - /// Clears the value of extension `Arrow_Flight_Protocol_Sql_Extensions_experimental`. - /// Subsequent reads from it will return its default value. - mutating func clearArrow_Flight_Protocol_Sql_experimental() { - clearExtensionValue(ext: Arrow_Flight_Protocol_Sql_Extensions_experimental) - } - -} - -// MARK: - File's ExtensionMap: Arrow_Flight_Protocol_Sql_FlightSql_Extensions - -/// A `SwiftProtobuf.SimpleExtensionMap` that includes all of the extensions defined by -/// this .proto file. It can be used any place an `SwiftProtobuf.ExtensionMap` is needed -/// in parsing, or it can be combined with other `SwiftProtobuf.SimpleExtensionMap`s to create -/// a larger `SwiftProtobuf.SimpleExtensionMap`. -let Arrow_Flight_Protocol_Sql_FlightSql_Extensions: SwiftProtobuf.SimpleExtensionMap = [ - Arrow_Flight_Protocol_Sql_Extensions_experimental -] - -// Extension Objects - The only reason these might be needed is when manually -// constructing a `SimpleExtensionMap`, otherwise, use the above _Extension Properties_ -// accessors for the extension fields on the messages directly. - -let Arrow_Flight_Protocol_Sql_Extensions_experimental = SwiftProtobuf.MessageExtension, SwiftProtobuf.Google_Protobuf_MessageOptions>( - _protobuf_fieldNumber: 1000, - fieldName: "arrow.flight.protocol.sql.experimental" -) - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "arrow.flight.protocol.sql" - -extension Arrow_Flight_Protocol_Sql_SqlInfo: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "FLIGHT_SQL_SERVER_NAME"), - 1: .same(proto: "FLIGHT_SQL_SERVER_VERSION"), - 2: .same(proto: "FLIGHT_SQL_SERVER_ARROW_VERSION"), - 3: .same(proto: "FLIGHT_SQL_SERVER_READ_ONLY"), - 4: .same(proto: "FLIGHT_SQL_SERVER_SQL"), - 5: .same(proto: "FLIGHT_SQL_SERVER_SUBSTRAIT"), - 6: .same(proto: "FLIGHT_SQL_SERVER_SUBSTRAIT_MIN_VERSION"), - 7: .same(proto: "FLIGHT_SQL_SERVER_SUBSTRAIT_MAX_VERSION"), - 8: .same(proto: "FLIGHT_SQL_SERVER_TRANSACTION"), - 9: .same(proto: "FLIGHT_SQL_SERVER_CANCEL"), - 100: .same(proto: "FLIGHT_SQL_SERVER_STATEMENT_TIMEOUT"), - 101: .same(proto: "FLIGHT_SQL_SERVER_TRANSACTION_TIMEOUT"), - 500: .same(proto: "SQL_DDL_CATALOG"), - 501: .same(proto: "SQL_DDL_SCHEMA"), - 502: .same(proto: "SQL_DDL_TABLE"), - 503: .same(proto: "SQL_IDENTIFIER_CASE"), - 504: .same(proto: "SQL_IDENTIFIER_QUOTE_CHAR"), - 505: .same(proto: "SQL_QUOTED_IDENTIFIER_CASE"), - 506: .same(proto: "SQL_ALL_TABLES_ARE_SELECTABLE"), - 507: .same(proto: "SQL_NULL_ORDERING"), - 508: .same(proto: "SQL_KEYWORDS"), - 509: .same(proto: "SQL_NUMERIC_FUNCTIONS"), - 510: .same(proto: "SQL_STRING_FUNCTIONS"), - 511: .same(proto: "SQL_SYSTEM_FUNCTIONS"), - 512: .same(proto: "SQL_DATETIME_FUNCTIONS"), - 513: .same(proto: "SQL_SEARCH_STRING_ESCAPE"), - 514: .same(proto: "SQL_EXTRA_NAME_CHARACTERS"), - 515: .same(proto: "SQL_SUPPORTS_COLUMN_ALIASING"), - 516: .same(proto: "SQL_NULL_PLUS_NULL_IS_NULL"), - 517: .same(proto: "SQL_SUPPORTS_CONVERT"), - 518: .same(proto: "SQL_SUPPORTS_TABLE_CORRELATION_NAMES"), - 519: .same(proto: "SQL_SUPPORTS_DIFFERENT_TABLE_CORRELATION_NAMES"), - 520: .same(proto: "SQL_SUPPORTS_EXPRESSIONS_IN_ORDER_BY"), - 521: .same(proto: "SQL_SUPPORTS_ORDER_BY_UNRELATED"), - 522: .same(proto: "SQL_SUPPORTED_GROUP_BY"), - 523: .same(proto: "SQL_SUPPORTS_LIKE_ESCAPE_CLAUSE"), - 524: .same(proto: "SQL_SUPPORTS_NON_NULLABLE_COLUMNS"), - 525: .same(proto: "SQL_SUPPORTED_GRAMMAR"), - 526: .same(proto: "SQL_ANSI92_SUPPORTED_LEVEL"), - 527: .same(proto: "SQL_SUPPORTS_INTEGRITY_ENHANCEMENT_FACILITY"), - 528: .same(proto: "SQL_OUTER_JOINS_SUPPORT_LEVEL"), - 529: .same(proto: "SQL_SCHEMA_TERM"), - 530: .same(proto: "SQL_PROCEDURE_TERM"), - 531: .same(proto: "SQL_CATALOG_TERM"), - 532: .same(proto: "SQL_CATALOG_AT_START"), - 533: .same(proto: "SQL_SCHEMAS_SUPPORTED_ACTIONS"), - 534: .same(proto: "SQL_CATALOGS_SUPPORTED_ACTIONS"), - 535: .same(proto: "SQL_SUPPORTED_POSITIONED_COMMANDS"), - 536: .same(proto: "SQL_SELECT_FOR_UPDATE_SUPPORTED"), - 537: .same(proto: "SQL_STORED_PROCEDURES_SUPPORTED"), - 538: .same(proto: "SQL_SUPPORTED_SUBQUERIES"), - 539: .same(proto: "SQL_CORRELATED_SUBQUERIES_SUPPORTED"), - 540: .same(proto: "SQL_SUPPORTED_UNIONS"), - 541: .same(proto: "SQL_MAX_BINARY_LITERAL_LENGTH"), - 542: .same(proto: "SQL_MAX_CHAR_LITERAL_LENGTH"), - 543: .same(proto: "SQL_MAX_COLUMN_NAME_LENGTH"), - 544: .same(proto: "SQL_MAX_COLUMNS_IN_GROUP_BY"), - 545: .same(proto: "SQL_MAX_COLUMNS_IN_INDEX"), - 546: .same(proto: "SQL_MAX_COLUMNS_IN_ORDER_BY"), - 547: .same(proto: "SQL_MAX_COLUMNS_IN_SELECT"), - 548: .same(proto: "SQL_MAX_COLUMNS_IN_TABLE"), - 549: .same(proto: "SQL_MAX_CONNECTIONS"), - 550: .same(proto: "SQL_MAX_CURSOR_NAME_LENGTH"), - 551: .same(proto: "SQL_MAX_INDEX_LENGTH"), - 552: .same(proto: "SQL_DB_SCHEMA_NAME_LENGTH"), - 553: .same(proto: "SQL_MAX_PROCEDURE_NAME_LENGTH"), - 554: .same(proto: "SQL_MAX_CATALOG_NAME_LENGTH"), - 555: .same(proto: "SQL_MAX_ROW_SIZE"), - 556: .same(proto: "SQL_MAX_ROW_SIZE_INCLUDES_BLOBS"), - 557: .same(proto: "SQL_MAX_STATEMENT_LENGTH"), - 558: .same(proto: "SQL_MAX_STATEMENTS"), - 559: .same(proto: "SQL_MAX_TABLE_NAME_LENGTH"), - 560: .same(proto: "SQL_MAX_TABLES_IN_SELECT"), - 561: .same(proto: "SQL_MAX_USERNAME_LENGTH"), - 562: .same(proto: "SQL_DEFAULT_TRANSACTION_ISOLATION"), - 563: .same(proto: "SQL_TRANSACTIONS_SUPPORTED"), - 564: .same(proto: "SQL_SUPPORTED_TRANSACTIONS_ISOLATION_LEVELS"), - 565: .same(proto: "SQL_DATA_DEFINITION_CAUSES_TRANSACTION_COMMIT"), - 566: .same(proto: "SQL_DATA_DEFINITIONS_IN_TRANSACTIONS_IGNORED"), - 567: .same(proto: "SQL_SUPPORTED_RESULT_SET_TYPES"), - 568: .same(proto: "SQL_SUPPORTED_CONCURRENCIES_FOR_RESULT_SET_UNSPECIFIED"), - 569: .same(proto: "SQL_SUPPORTED_CONCURRENCIES_FOR_RESULT_SET_FORWARD_ONLY"), - 570: .same(proto: "SQL_SUPPORTED_CONCURRENCIES_FOR_RESULT_SET_SCROLL_SENSITIVE"), - 571: .same(proto: "SQL_SUPPORTED_CONCURRENCIES_FOR_RESULT_SET_SCROLL_INSENSITIVE"), - 572: .same(proto: "SQL_BATCH_UPDATES_SUPPORTED"), - 573: .same(proto: "SQL_SAVEPOINTS_SUPPORTED"), - 574: .same(proto: "SQL_NAMED_PARAMETERS_SUPPORTED"), - 575: .same(proto: "SQL_LOCATORS_UPDATE_COPY"), - 576: .same(proto: "SQL_STORED_FUNCTIONS_USING_CALL_SYNTAX_SUPPORTED"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransaction: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_SUPPORTED_TRANSACTION_NONE"), - 1: .same(proto: "SQL_SUPPORTED_TRANSACTION_TRANSACTION"), - 2: .same(proto: "SQL_SUPPORTED_TRANSACTION_SAVEPOINT"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedCaseSensitivity: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_CASE_SENSITIVITY_UNKNOWN"), - 1: .same(proto: "SQL_CASE_SENSITIVITY_CASE_INSENSITIVE"), - 2: .same(proto: "SQL_CASE_SENSITIVITY_UPPERCASE"), - 3: .same(proto: "SQL_CASE_SENSITIVITY_LOWERCASE"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlNullOrdering: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_NULLS_SORTED_HIGH"), - 1: .same(proto: "SQL_NULLS_SORTED_LOW"), - 2: .same(proto: "SQL_NULLS_SORTED_AT_START"), - 3: .same(proto: "SQL_NULLS_SORTED_AT_END"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SupportedSqlGrammar: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_MINIMUM_GRAMMAR"), - 1: .same(proto: "SQL_CORE_GRAMMAR"), - 2: .same(proto: "SQL_EXTENDED_GRAMMAR"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SupportedAnsi92SqlGrammarLevel: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "ANSI92_ENTRY_SQL"), - 1: .same(proto: "ANSI92_INTERMEDIATE_SQL"), - 2: .same(proto: "ANSI92_FULL_SQL"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlOuterJoinsSupportLevel: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_JOINS_UNSUPPORTED"), - 1: .same(proto: "SQL_LIMITED_OUTER_JOINS"), - 2: .same(proto: "SQL_FULL_OUTER_JOINS"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedGroupBy: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_GROUP_BY_UNRELATED"), - 1: .same(proto: "SQL_GROUP_BY_BEYOND_SELECT"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedElementActions: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_ELEMENT_IN_PROCEDURE_CALLS"), - 1: .same(proto: "SQL_ELEMENT_IN_INDEX_DEFINITIONS"), - 2: .same(proto: "SQL_ELEMENT_IN_PRIVILEGE_DEFINITIONS"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedPositionedCommands: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_POSITIONED_DELETE"), - 1: .same(proto: "SQL_POSITIONED_UPDATE"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedSubqueries: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_SUBQUERIES_IN_COMPARISONS"), - 1: .same(proto: "SQL_SUBQUERIES_IN_EXISTS"), - 2: .same(proto: "SQL_SUBQUERIES_IN_INS"), - 3: .same(proto: "SQL_SUBQUERIES_IN_QUANTIFIEDS"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedUnions: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_UNION"), - 1: .same(proto: "SQL_UNION_ALL"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlTransactionIsolationLevel: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_TRANSACTION_NONE"), - 1: .same(proto: "SQL_TRANSACTION_READ_UNCOMMITTED"), - 2: .same(proto: "SQL_TRANSACTION_READ_COMMITTED"), - 3: .same(proto: "SQL_TRANSACTION_REPEATABLE_READ"), - 4: .same(proto: "SQL_TRANSACTION_SERIALIZABLE"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedTransactions: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_TRANSACTION_UNSPECIFIED"), - 1: .same(proto: "SQL_DATA_DEFINITION_TRANSACTIONS"), - 2: .same(proto: "SQL_DATA_MANIPULATION_TRANSACTIONS"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_RESULT_SET_TYPE_UNSPECIFIED"), - 1: .same(proto: "SQL_RESULT_SET_TYPE_FORWARD_ONLY"), - 2: .same(proto: "SQL_RESULT_SET_TYPE_SCROLL_INSENSITIVE"), - 3: .same(proto: "SQL_RESULT_SET_TYPE_SCROLL_SENSITIVE"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportedResultSetConcurrency: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_RESULT_SET_CONCURRENCY_UNSPECIFIED"), - 1: .same(proto: "SQL_RESULT_SET_CONCURRENCY_READ_ONLY"), - 2: .same(proto: "SQL_RESULT_SET_CONCURRENCY_UPDATABLE"), - ] -} - -extension Arrow_Flight_Protocol_Sql_SqlSupportsConvert: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SQL_CONVERT_BIGINT"), - 1: .same(proto: "SQL_CONVERT_BINARY"), - 2: .same(proto: "SQL_CONVERT_BIT"), - 3: .same(proto: "SQL_CONVERT_CHAR"), - 4: .same(proto: "SQL_CONVERT_DATE"), - 5: .same(proto: "SQL_CONVERT_DECIMAL"), - 6: .same(proto: "SQL_CONVERT_FLOAT"), - 7: .same(proto: "SQL_CONVERT_INTEGER"), - 8: .same(proto: "SQL_CONVERT_INTERVAL_DAY_TIME"), - 9: .same(proto: "SQL_CONVERT_INTERVAL_YEAR_MONTH"), - 10: .same(proto: "SQL_CONVERT_LONGVARBINARY"), - 11: .same(proto: "SQL_CONVERT_LONGVARCHAR"), - 12: .same(proto: "SQL_CONVERT_NUMERIC"), - 13: .same(proto: "SQL_CONVERT_REAL"), - 14: .same(proto: "SQL_CONVERT_SMALLINT"), - 15: .same(proto: "SQL_CONVERT_TIME"), - 16: .same(proto: "SQL_CONVERT_TIMESTAMP"), - 17: .same(proto: "SQL_CONVERT_TINYINT"), - 18: .same(proto: "SQL_CONVERT_VARBINARY"), - 19: .same(proto: "SQL_CONVERT_VARCHAR"), - ] -} - -extension Arrow_Flight_Protocol_Sql_XdbcDataType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - -9: .same(proto: "XDBC_WVARCHAR"), - -8: .same(proto: "XDBC_WCHAR"), - -7: .same(proto: "XDBC_BIT"), - -6: .same(proto: "XDBC_TINYINT"), - -5: .same(proto: "XDBC_BIGINT"), - -4: .same(proto: "XDBC_LONGVARBINARY"), - -3: .same(proto: "XDBC_VARBINARY"), - -2: .same(proto: "XDBC_BINARY"), - -1: .same(proto: "XDBC_LONGVARCHAR"), - 0: .same(proto: "XDBC_UNKNOWN_TYPE"), - 1: .same(proto: "XDBC_CHAR"), - 2: .same(proto: "XDBC_NUMERIC"), - 3: .same(proto: "XDBC_DECIMAL"), - 4: .same(proto: "XDBC_INTEGER"), - 5: .same(proto: "XDBC_SMALLINT"), - 6: .same(proto: "XDBC_FLOAT"), - 7: .same(proto: "XDBC_REAL"), - 8: .same(proto: "XDBC_DOUBLE"), - 9: .same(proto: "XDBC_DATETIME"), - 10: .same(proto: "XDBC_INTERVAL"), - 12: .same(proto: "XDBC_VARCHAR"), - 91: .same(proto: "XDBC_DATE"), - 92: .same(proto: "XDBC_TIME"), - 93: .same(proto: "XDBC_TIMESTAMP"), - ] -} - -extension Arrow_Flight_Protocol_Sql_XdbcDatetimeSubcode: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "XDBC_SUBCODE_UNKNOWN"), - 1: .aliased(proto: "XDBC_SUBCODE_YEAR", aliases: ["XDBC_SUBCODE_DATE"]), - 2: .aliased(proto: "XDBC_SUBCODE_TIME", aliases: ["XDBC_SUBCODE_MONTH"]), - 3: .aliased(proto: "XDBC_SUBCODE_TIMESTAMP", aliases: ["XDBC_SUBCODE_DAY"]), - 4: .aliased(proto: "XDBC_SUBCODE_TIME_WITH_TIMEZONE", aliases: ["XDBC_SUBCODE_HOUR"]), - 5: .aliased(proto: "XDBC_SUBCODE_TIMESTAMP_WITH_TIMEZONE", aliases: ["XDBC_SUBCODE_MINUTE"]), - 6: .same(proto: "XDBC_SUBCODE_SECOND"), - 7: .same(proto: "XDBC_SUBCODE_YEAR_TO_MONTH"), - 8: .same(proto: "XDBC_SUBCODE_DAY_TO_HOUR"), - 9: .same(proto: "XDBC_SUBCODE_DAY_TO_MINUTE"), - 10: .same(proto: "XDBC_SUBCODE_DAY_TO_SECOND"), - 11: .same(proto: "XDBC_SUBCODE_HOUR_TO_MINUTE"), - 12: .same(proto: "XDBC_SUBCODE_HOUR_TO_SECOND"), - 13: .same(proto: "XDBC_SUBCODE_MINUTE_TO_SECOND"), - 101: .same(proto: "XDBC_SUBCODE_INTERVAL_YEAR"), - 102: .same(proto: "XDBC_SUBCODE_INTERVAL_MONTH"), - 103: .same(proto: "XDBC_SUBCODE_INTERVAL_DAY"), - 104: .same(proto: "XDBC_SUBCODE_INTERVAL_HOUR"), - 105: .same(proto: "XDBC_SUBCODE_INTERVAL_MINUTE"), - 106: .same(proto: "XDBC_SUBCODE_INTERVAL_SECOND"), - 107: .same(proto: "XDBC_SUBCODE_INTERVAL_YEAR_TO_MONTH"), - 108: .same(proto: "XDBC_SUBCODE_INTERVAL_DAY_TO_HOUR"), - 109: .same(proto: "XDBC_SUBCODE_INTERVAL_DAY_TO_MINUTE"), - 110: .same(proto: "XDBC_SUBCODE_INTERVAL_DAY_TO_SECOND"), - 111: .same(proto: "XDBC_SUBCODE_INTERVAL_HOUR_TO_MINUTE"), - 112: .same(proto: "XDBC_SUBCODE_INTERVAL_HOUR_TO_SECOND"), - 113: .same(proto: "XDBC_SUBCODE_INTERVAL_MINUTE_TO_SECOND"), - ] -} - -extension Arrow_Flight_Protocol_Sql_Nullable: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "NULLABILITY_NO_NULLS"), - 1: .same(proto: "NULLABILITY_NULLABLE"), - 2: .same(proto: "NULLABILITY_UNKNOWN"), - ] -} - -extension Arrow_Flight_Protocol_Sql_Searchable: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "SEARCHABLE_NONE"), - 1: .same(proto: "SEARCHABLE_CHAR"), - 2: .same(proto: "SEARCHABLE_BASIC"), - 3: .same(proto: "SEARCHABLE_FULL"), - ] -} - -extension Arrow_Flight_Protocol_Sql_UpdateDeleteRules: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "CASCADE"), - 1: .same(proto: "RESTRICT"), - 2: .same(proto: "SET_NULL"), - 3: .same(proto: "NO_ACTION"), - 4: .same(proto: "SET_DEFAULT"), - ] -} - -extension Arrow_Flight_Protocol_Sql_CommandGetSqlInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetSqlInfo" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "info"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedUInt32Field(value: &self.info) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.info.isEmpty { - try visitor.visitPackedUInt32Field(value: self.info, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetSqlInfo, rhs: Arrow_Flight_Protocol_Sql_CommandGetSqlInfo) -> Bool { - if lhs.info != rhs.info {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetXdbcTypeInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetXdbcTypeInfo" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "data_type"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularInt32Field(value: &self._dataType) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._dataType { - try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetXdbcTypeInfo, rhs: Arrow_Flight_Protocol_Sql_CommandGetXdbcTypeInfo) -> Bool { - if lhs._dataType != rhs._dataType {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetCatalogs: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetCatalogs" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetCatalogs, rhs: Arrow_Flight_Protocol_Sql_CommandGetCatalogs) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetDbSchemas: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetDbSchemas" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "catalog"), - 2: .standard(proto: "db_schema_filter_pattern"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._catalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._dbSchemaFilterPattern) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._catalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._dbSchemaFilterPattern { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetDbSchemas, rhs: Arrow_Flight_Protocol_Sql_CommandGetDbSchemas) -> Bool { - if lhs._catalog != rhs._catalog {return false} - if lhs._dbSchemaFilterPattern != rhs._dbSchemaFilterPattern {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetTables: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetTables" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "catalog"), - 2: .standard(proto: "db_schema_filter_pattern"), - 3: .standard(proto: "table_name_filter_pattern"), - 4: .standard(proto: "table_types"), - 5: .standard(proto: "include_schema"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._catalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._dbSchemaFilterPattern) }() - case 3: try { try decoder.decodeSingularStringField(value: &self._tableNameFilterPattern) }() - case 4: try { try decoder.decodeRepeatedStringField(value: &self.tableTypes) }() - case 5: try { try decoder.decodeSingularBoolField(value: &self.includeSchema) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._catalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._dbSchemaFilterPattern { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - try { if let v = self._tableNameFilterPattern { - try visitor.visitSingularStringField(value: v, fieldNumber: 3) - } }() - if !self.tableTypes.isEmpty { - try visitor.visitRepeatedStringField(value: self.tableTypes, fieldNumber: 4) - } - if self.includeSchema != false { - try visitor.visitSingularBoolField(value: self.includeSchema, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetTables, rhs: Arrow_Flight_Protocol_Sql_CommandGetTables) -> Bool { - if lhs._catalog != rhs._catalog {return false} - if lhs._dbSchemaFilterPattern != rhs._dbSchemaFilterPattern {return false} - if lhs._tableNameFilterPattern != rhs._tableNameFilterPattern {return false} - if lhs.tableTypes != rhs.tableTypes {return false} - if lhs.includeSchema != rhs.includeSchema {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetTableTypes: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetTableTypes" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetTableTypes, rhs: Arrow_Flight_Protocol_Sql_CommandGetTableTypes) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetPrimaryKeys: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetPrimaryKeys" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "catalog"), - 2: .standard(proto: "db_schema"), - 3: .same(proto: "table"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._catalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._dbSchema) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.table) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._catalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._dbSchema { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - if !self.table.isEmpty { - try visitor.visitSingularStringField(value: self.table, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetPrimaryKeys, rhs: Arrow_Flight_Protocol_Sql_CommandGetPrimaryKeys) -> Bool { - if lhs._catalog != rhs._catalog {return false} - if lhs._dbSchema != rhs._dbSchema {return false} - if lhs.table != rhs.table {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetExportedKeys: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetExportedKeys" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "catalog"), - 2: .standard(proto: "db_schema"), - 3: .same(proto: "table"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._catalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._dbSchema) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.table) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._catalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._dbSchema { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - if !self.table.isEmpty { - try visitor.visitSingularStringField(value: self.table, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetExportedKeys, rhs: Arrow_Flight_Protocol_Sql_CommandGetExportedKeys) -> Bool { - if lhs._catalog != rhs._catalog {return false} - if lhs._dbSchema != rhs._dbSchema {return false} - if lhs.table != rhs.table {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetImportedKeys: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetImportedKeys" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "catalog"), - 2: .standard(proto: "db_schema"), - 3: .same(proto: "table"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._catalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._dbSchema) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.table) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._catalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._dbSchema { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - if !self.table.isEmpty { - try visitor.visitSingularStringField(value: self.table, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetImportedKeys, rhs: Arrow_Flight_Protocol_Sql_CommandGetImportedKeys) -> Bool { - if lhs._catalog != rhs._catalog {return false} - if lhs._dbSchema != rhs._dbSchema {return false} - if lhs.table != rhs.table {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandGetCrossReference: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandGetCrossReference" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "pk_catalog"), - 2: .standard(proto: "pk_db_schema"), - 3: .standard(proto: "pk_table"), - 4: .standard(proto: "fk_catalog"), - 5: .standard(proto: "fk_db_schema"), - 6: .standard(proto: "fk_table"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._pkCatalog) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._pkDbSchema) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.pkTable) }() - case 4: try { try decoder.decodeSingularStringField(value: &self._fkCatalog) }() - case 5: try { try decoder.decodeSingularStringField(value: &self._fkDbSchema) }() - case 6: try { try decoder.decodeSingularStringField(value: &self.fkTable) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._pkCatalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = self._pkDbSchema { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - if !self.pkTable.isEmpty { - try visitor.visitSingularStringField(value: self.pkTable, fieldNumber: 3) - } - try { if let v = self._fkCatalog { - try visitor.visitSingularStringField(value: v, fieldNumber: 4) - } }() - try { if let v = self._fkDbSchema { - try visitor.visitSingularStringField(value: v, fieldNumber: 5) - } }() - if !self.fkTable.isEmpty { - try visitor.visitSingularStringField(value: self.fkTable, fieldNumber: 6) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandGetCrossReference, rhs: Arrow_Flight_Protocol_Sql_CommandGetCrossReference) -> Bool { - if lhs._pkCatalog != rhs._pkCatalog {return false} - if lhs._pkDbSchema != rhs._pkDbSchema {return false} - if lhs.pkTable != rhs.pkTable {return false} - if lhs._fkCatalog != rhs._fkCatalog {return false} - if lhs._fkDbSchema != rhs._fkDbSchema {return false} - if lhs.fkTable != rhs.fkTable {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionCreatePreparedStatementRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "query"), - 2: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.query) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self._transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.query.isEmpty { - try visitor.visitSingularStringField(value: self.query, fieldNumber: 1) - } - try { if let v = self._transactionID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementRequest, rhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementRequest) -> Bool { - if lhs.query != rhs.query {return false} - if lhs._transactionID != rhs._transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_SubstraitPlan: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SubstraitPlan" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "plan"), - 2: .same(proto: "version"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.plan) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.version) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.plan.isEmpty { - try visitor.visitSingularBytesField(value: self.plan, fieldNumber: 1) - } - if !self.version.isEmpty { - try visitor.visitSingularStringField(value: self.version, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_SubstraitPlan, rhs: Arrow_Flight_Protocol_Sql_SubstraitPlan) -> Bool { - if lhs.plan != rhs.plan {return false} - if lhs.version != rhs.version {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedSubstraitPlanRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionCreatePreparedSubstraitPlanRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "plan"), - 2: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._plan) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self._transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._plan { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._transactionID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedSubstraitPlanRequest, rhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedSubstraitPlanRequest) -> Bool { - if lhs._plan != rhs._plan {return false} - if lhs._transactionID != rhs._transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionCreatePreparedStatementResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "prepared_statement_handle"), - 2: .standard(proto: "dataset_schema"), - 3: .standard(proto: "parameter_schema"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.preparedStatementHandle) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.datasetSchema) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.parameterSchema) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.preparedStatementHandle.isEmpty { - try visitor.visitSingularBytesField(value: self.preparedStatementHandle, fieldNumber: 1) - } - if !self.datasetSchema.isEmpty { - try visitor.visitSingularBytesField(value: self.datasetSchema, fieldNumber: 2) - } - if !self.parameterSchema.isEmpty { - try visitor.visitSingularBytesField(value: self.parameterSchema, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementResult, rhs: Arrow_Flight_Protocol_Sql_ActionCreatePreparedStatementResult) -> Bool { - if lhs.preparedStatementHandle != rhs.preparedStatementHandle {return false} - if lhs.datasetSchema != rhs.datasetSchema {return false} - if lhs.parameterSchema != rhs.parameterSchema {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionClosePreparedStatementRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionClosePreparedStatementRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "prepared_statement_handle"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.preparedStatementHandle) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.preparedStatementHandle.isEmpty { - try visitor.visitSingularBytesField(value: self.preparedStatementHandle, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionClosePreparedStatementRequest, rhs: Arrow_Flight_Protocol_Sql_ActionClosePreparedStatementRequest) -> Bool { - if lhs.preparedStatementHandle != rhs.preparedStatementHandle {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionBeginTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionBeginTransactionRequest" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionBeginTransactionRequest, rhs: Arrow_Flight_Protocol_Sql_ActionBeginTransactionRequest) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionBeginSavepointRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionBeginSavepointRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "transaction_id"), - 2: .same(proto: "name"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.name) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.transactionID.isEmpty { - try visitor.visitSingularBytesField(value: self.transactionID, fieldNumber: 1) - } - if !self.name.isEmpty { - try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionBeginSavepointRequest, rhs: Arrow_Flight_Protocol_Sql_ActionBeginSavepointRequest) -> Bool { - if lhs.transactionID != rhs.transactionID {return false} - if lhs.name != rhs.name {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionBeginTransactionResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionBeginTransactionResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.transactionID.isEmpty { - try visitor.visitSingularBytesField(value: self.transactionID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionBeginTransactionResult, rhs: Arrow_Flight_Protocol_Sql_ActionBeginTransactionResult) -> Bool { - if lhs.transactionID != rhs.transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionBeginSavepointResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionBeginSavepointResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "savepoint_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.savepointID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.savepointID.isEmpty { - try visitor.visitSingularBytesField(value: self.savepointID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionBeginSavepointResult, rhs: Arrow_Flight_Protocol_Sql_ActionBeginSavepointResult) -> Bool { - if lhs.savepointID != rhs.savepointID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionEndTransactionRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "transaction_id"), - 2: .same(proto: "action"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() - case 2: try { try decoder.decodeSingularEnumField(value: &self.action) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.transactionID.isEmpty { - try visitor.visitSingularBytesField(value: self.transactionID, fieldNumber: 1) - } - if self.action != .unspecified { - try visitor.visitSingularEnumField(value: self.action, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest, rhs: Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest) -> Bool { - if lhs.transactionID != rhs.transactionID {return false} - if lhs.action != rhs.action {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionEndTransactionRequest.EndTransaction: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "END_TRANSACTION_UNSPECIFIED"), - 1: .same(proto: "END_TRANSACTION_COMMIT"), - 2: .same(proto: "END_TRANSACTION_ROLLBACK"), - ] -} - -extension Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionEndSavepointRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "savepoint_id"), - 2: .same(proto: "action"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.savepointID) }() - case 2: try { try decoder.decodeSingularEnumField(value: &self.action) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.savepointID.isEmpty { - try visitor.visitSingularBytesField(value: self.savepointID, fieldNumber: 1) - } - if self.action != .unspecified { - try visitor.visitSingularEnumField(value: self.action, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest, rhs: Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest) -> Bool { - if lhs.savepointID != rhs.savepointID {return false} - if lhs.action != rhs.action {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionEndSavepointRequest.EndSavepoint: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "END_SAVEPOINT_UNSPECIFIED"), - 1: .same(proto: "END_SAVEPOINT_RELEASE"), - 2: .same(proto: "END_SAVEPOINT_ROLLBACK"), - ] -} - -extension Arrow_Flight_Protocol_Sql_CommandStatementQuery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandStatementQuery" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "query"), - 2: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.query) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self._transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.query.isEmpty { - try visitor.visitSingularStringField(value: self.query, fieldNumber: 1) - } - try { if let v = self._transactionID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandStatementQuery, rhs: Arrow_Flight_Protocol_Sql_CommandStatementQuery) -> Bool { - if lhs.query != rhs.query {return false} - if lhs._transactionID != rhs._transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandStatementSubstraitPlan: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandStatementSubstraitPlan" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "plan"), - 2: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._plan) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self._transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._plan { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._transactionID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandStatementSubstraitPlan, rhs: Arrow_Flight_Protocol_Sql_CommandStatementSubstraitPlan) -> Bool { - if lhs._plan != rhs._plan {return false} - if lhs._transactionID != rhs._transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_TicketStatementQuery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".TicketStatementQuery" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "statement_handle"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.statementHandle) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.statementHandle.isEmpty { - try visitor.visitSingularBytesField(value: self.statementHandle, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_TicketStatementQuery, rhs: Arrow_Flight_Protocol_Sql_TicketStatementQuery) -> Bool { - if lhs.statementHandle != rhs.statementHandle {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandPreparedStatementQuery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandPreparedStatementQuery" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "prepared_statement_handle"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.preparedStatementHandle) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.preparedStatementHandle.isEmpty { - try visitor.visitSingularBytesField(value: self.preparedStatementHandle, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandPreparedStatementQuery, rhs: Arrow_Flight_Protocol_Sql_CommandPreparedStatementQuery) -> Bool { - if lhs.preparedStatementHandle != rhs.preparedStatementHandle {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandStatementUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandStatementUpdate" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "query"), - 2: .standard(proto: "transaction_id"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.query) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self._transactionID) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.query.isEmpty { - try visitor.visitSingularStringField(value: self.query, fieldNumber: 1) - } - try { if let v = self._transactionID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandStatementUpdate, rhs: Arrow_Flight_Protocol_Sql_CommandStatementUpdate) -> Bool { - if lhs.query != rhs.query {return false} - if lhs._transactionID != rhs._transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_CommandPreparedStatementUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CommandPreparedStatementUpdate" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "prepared_statement_handle"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.preparedStatementHandle) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.preparedStatementHandle.isEmpty { - try visitor.visitSingularBytesField(value: self.preparedStatementHandle, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_CommandPreparedStatementUpdate, rhs: Arrow_Flight_Protocol_Sql_CommandPreparedStatementUpdate) -> Bool { - if lhs.preparedStatementHandle != rhs.preparedStatementHandle {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_DoPutUpdateResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".DoPutUpdateResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "record_count"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularInt64Field(value: &self.recordCount) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.recordCount != 0 { - try visitor.visitSingularInt64Field(value: self.recordCount, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_DoPutUpdateResult, rhs: Arrow_Flight_Protocol_Sql_DoPutUpdateResult) -> Bool { - if lhs.recordCount != rhs.recordCount {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionCancelQueryRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "info"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.info) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !self.info.isEmpty { - try visitor.visitSingularBytesField(value: self.info, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionCancelQueryRequest, rhs: Arrow_Flight_Protocol_Sql_ActionCancelQueryRequest) -> Bool { - if lhs.info != rhs.info {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".ActionCancelQueryResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "result"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.result) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if self.result != .unspecified { - try visitor.visitSingularEnumField(value: self.result, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: Arrow_Flight_Protocol_Sql_ActionCancelQueryResult, rhs: Arrow_Flight_Protocol_Sql_ActionCancelQueryResult) -> Bool { - if lhs.result != rhs.result {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Arrow_Flight_Protocol_Sql_ActionCancelQueryResult.CancelResult: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "CANCEL_RESULT_UNSPECIFIED"), - 1: .same(proto: "CANCEL_RESULT_CANCELLED"), - 2: .same(proto: "CANCEL_RESULT_CANCELLING"), - 3: .same(proto: "CANCEL_RESULT_NOT_CANCELLABLE"), - ] -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/FlightTicket.swift b/swift/ArrowFlight/Sources/ArrowFlight/FlightTicket.swift deleted file mode 100644 index ab3cb321c62..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/FlightTicket.swift +++ /dev/null @@ -1,35 +0,0 @@ -// 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 Foundation - -public class FlightTicket { - public let data: Data - init(_ ticket: Arrow_Flight_Protocol_Ticket) { - self.data = ticket.ticket - } - - public init(_ data: Data) { - self.data = data - } - - func toProtocol() -> Arrow_Flight_Protocol_Ticket { - var ticket = Arrow_Flight_Protocol_Ticket() - ticket.ticket = self.data - return ticket - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamReader.swift b/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamReader.swift deleted file mode 100644 index 464752dbcbe..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamReader.swift +++ /dev/null @@ -1,81 +0,0 @@ -// 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 Foundation -import Arrow -import GRPC - -public class RecordBatchStreamReader: AsyncSequence, AsyncIteratorProtocol { - public typealias AsyncIterator = RecordBatchStreamReader - public typealias Element = (Arrow.RecordBatch?, FlightDescriptor?) - let reader = ArrowReader() - var batches = [RecordBatch]() - var descriptor: FlightDescriptor? - var batchIndex = 0 - var streamIterator: any AsyncIteratorProtocol - var useUnalignedBuffers: Bool - let stream: GRPC.GRPCAsyncRequestStream - init(_ stream: GRPC.GRPCAsyncRequestStream, - useUnalignedBuffers: Bool = false) { - self.stream = stream - self.streamIterator = self.stream.makeAsyncIterator() - self.useUnalignedBuffers = useUnalignedBuffers - } - - public func next() async throws -> (Arrow.RecordBatch?, FlightDescriptor?)? { - guard !Task.isCancelled else { - return nil - } - - if batchIndex < batches.count { - let batch = batches[batchIndex] - batchIndex += 1 - return (batch, descriptor) - } - - let result = ArrowReader.makeArrowReaderResult() - while true { - let streamData = try await self.streamIterator.next() - if streamData == nil { - return nil - } - - let flightData = (streamData as? Arrow_Flight_Protocol_FlightData)! - let dataBody = flightData.dataBody - let dataHeader = flightData.dataHeader - descriptor = FlightDescriptor(flightData.flightDescriptor) - switch reader.fromMessage( - dataHeader, - dataBody: dataBody, - result: result, - useUnalignedBuffers: useUnalignedBuffers) { - case .success(()): - if result.batches.count > 0 { - batches = result.batches - batchIndex = 1 - return (batches[0], descriptor) - } - case .failure(let error): - throw error - } - } - } - - public func makeAsyncIterator() -> RecordBatchStreamReader { - self - } -} diff --git a/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamWriter.swift b/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamWriter.swift deleted file mode 100644 index d3e03fe17ce..00000000000 --- a/swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamWriter.swift +++ /dev/null @@ -1,96 +0,0 @@ -// 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 Foundation -import Arrow -import GRPC - -public class ActionTypeStreamWriter { - let stream: GRPCAsyncResponseStreamWriter - init(_ stream: GRPCAsyncResponseStreamWriter) { - self.stream = stream - } - - public func write(_ actionType: FlightActionType) async throws { - try await self.stream.send(actionType.toProtocol()) - } -} - -public class ResultStreamWriter { - let stream: GRPCAsyncResponseStreamWriter - init(_ stream: GRPCAsyncResponseStreamWriter) { - self.stream = stream - } - - public func write(_ result: FlightResult) async throws { - try await self.stream.send(result.toProtocol()) - } -} - -public class FlightInfoStreamWriter { - let stream: GRPCAsyncResponseStreamWriter - init(_ stream: GRPCAsyncResponseStreamWriter) { - self.stream = stream - } - - public func write(_ result: FlightInfo) async throws { - try await self.stream.send(result.toProtocol()) - } -} - -public class PutResultDataStreamWriter { - let stream: GRPCAsyncResponseStreamWriter - init(_ stream: GRPCAsyncResponseStreamWriter) { - self.stream = stream - } - - public func write(_ result: FlightPutResult) async throws { - try await self.stream.send(result.toProtocol()) - } -} - -public class RecordBatchStreamWriter { - let writer = ArrowWriter() - let stream: GRPCAsyncResponseStreamWriter - init(_ stream: GRPCAsyncResponseStreamWriter) { - self.stream = stream - } - - public func write(_ rb: RecordBatch) async throws { - switch writer.toMessage(rb.schema) { - case .success(let schemaData): - let schemaFlightData = Arrow_Flight_Protocol_FlightData.with { - $0.dataHeader = schemaData - } - - try await self.stream.send(schemaFlightData) - switch writer.toMessage(rb) { - case .success(let recordMessages): - let rbMessage = Arrow_Flight_Protocol_FlightData.with { - $0.dataHeader = recordMessages[0] - $0.dataBody = recordMessages[1] - } - - try await self.stream.send(rbMessage) - case .failure(let error): - throw error - } - case .failure(let error): - throw error - } - } -} diff --git a/swift/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift b/swift/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift deleted file mode 100644 index f7bc3c1ccb0..00000000000 --- a/swift/ArrowFlight/Tests/ArrowFlightTests/FlightTest.swift +++ /dev/null @@ -1,357 +0,0 @@ -// 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 struct Foundation.Data -import struct Foundation.URL -import GRPC -import NIOCore -import NIOPosix -import Arrow - -@testable import ArrowFlight - -func makeSchema() -> ArrowSchema { - let schemaBuilder = ArrowSchema.Builder() - return schemaBuilder.addField("col1", type: ArrowType(ArrowType.ArrowDouble), isNullable: true) - .addField("col2", type: ArrowType(ArrowType.ArrowString), isNullable: false) - .addField("col3", type: ArrowType(ArrowType.ArrowDate32), isNullable: false) - .finish() -} - -func makeRecordBatch() throws -> RecordBatch { - let doubleBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - doubleBuilder.append(11.11) - doubleBuilder.append(22.22) - doubleBuilder.append(33.33) - doubleBuilder.append(44.44) - let stringBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - stringBuilder.append("test10") - stringBuilder.append("test22") - stringBuilder.append("test33") - stringBuilder.append("test44") - let date32Builder = try ArrowArrayBuilders.loadDate32ArrayBuilder() - let date2 = Date(timeIntervalSinceReferenceDate: 86400 * 1) - let date1 = Date(timeIntervalSinceReferenceDate: 86400 * 5000 + 352) - date32Builder.append(date1) - date32Builder.append(date2) - date32Builder.append(date1) - date32Builder.append(date2) - let doubleHolder = ArrowArrayHolderImpl(try doubleBuilder.finish()) - let stringHolder = ArrowArrayHolderImpl(try stringBuilder.finish()) - let date32Holder = ArrowArrayHolderImpl(try date32Builder.finish()) - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: doubleHolder) - .addColumn("col2", arrowArray: stringHolder) - .addColumn("col3", arrowArray: date32Holder) - .finish() - switch result { - case .success(let recordBatch): - return recordBatch - case .failure(let error): - throw error - } -} - -var flights = [String: FlightInfo]() -final class MyFlightServer: ArrowFlightServer { - func doExchange( - _ reader: ArrowFlight.RecordBatchStreamReader, - writer: ArrowFlight.RecordBatchStreamWriter) async throws { - do { - for try await rbData in reader { - let rb = rbData.0! - XCTAssertEqual(rb.schema.fields.count, 3) - XCTAssertEqual(rb.length, 4) - } - - let rb = try makeRecordBatch() - try await writer.write(rb) - } catch { - print("Unknown error: \(error)") - } - } - - func doPut( - _ reader: ArrowFlight.RecordBatchStreamReader, - writer: ArrowFlight.PutResultDataStreamWriter) async throws { - for try await rbData in reader { - let rb = rbData.0! - let key = String(decoding: rbData.1!.cmd, as: UTF8.self) - flights[key] = try FlightInfo(schemaToMessage(rb.schema), endpoints: [], descriptor: rbData.1) - XCTAssertEqual(rb.schema.fields.count, 3) - XCTAssertEqual(rb.length, 4) - try await writer.write(FlightPutResult()) - } - } - - func doGet(_ ticket: ArrowFlight.FlightTicket, writer: ArrowFlight.RecordBatchStreamWriter) async throws { - try await writer.write(try makeRecordBatch()) - } - - func getSchema(_ request: ArrowFlight.FlightDescriptor) async throws -> ArrowFlight.FlightSchemaResult { - XCTAssertEqual(String(bytes: request.cmd, encoding: .utf8)!, "schema info") - XCTAssertEqual(request.type, .cmd) - return try ArrowFlight.FlightSchemaResult(schemaToMessage(makeSchema())) - } - - func getFlightInfo(_ request: ArrowFlight.FlightDescriptor) async throws -> ArrowFlight.FlightInfo { - let key = String(decoding: request.cmd, as: UTF8.self) - if flights[key] != nil { - return ArrowFlight.FlightInfo(flights[key]!.toProtocol()) - } - - throw ArrowFlightError.ioError("Flight not found") - } - - func listFlights(_ criteria: ArrowFlight.FlightCriteria, writer: ArrowFlight.FlightInfoStreamWriter) async throws { - XCTAssertEqual(String(bytes: criteria.expression, encoding: .utf8), "flight criteria expression") - for flightData in flights { - try await writer.write(flightData.value) - } - } - - func listActions(_ writer: ArrowFlight.ActionTypeStreamWriter) async throws { - try await writer.write(FlightActionType("clear", description: "Clear the stored flights.")) - try await writer.write(FlightActionType("shutdown", description: "Shut down this server.")) - } - - func doAction(_ action: FlightAction, writer: ResultStreamWriter) async throws { - XCTAssertEqual(action.type, "healthcheck") - XCTAssertEqual(String(bytes: action.body, encoding: .utf8)!, "healthcheck body") - try await writer.write(FlightResult("test_action result".data(using: .utf8)!)) - } -} - -struct FlightServerImpl { - var port = 1234 - static var server: Server? - static var group: MultiThreadedEventLoopGroup? - static func run() async throws { - do { - // Create an event loop group for the server to run on. - let group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) - // Create a provider using the features we read. - let provider = ArrowFlight.makeFlightServer(MyFlightServer()) - - // Start the server and print its address once it has started. - FlightServerImpl.server = try await Server.insecure(group: group) - .withServiceProviders([provider]) - .bind(host: "localhost", port: 8088) - .get() - - print("server started on port \(server!.channel.localAddress!.port!)") - // Wait on the server's `onClose` future to stop the program from exiting. - } catch { - print("Unknown server error: \(error)") - } - } -} - -public class FlightClientTester { - var client: FlightClient? - var group: MultiThreadedEventLoopGroup? - var channel: GRPCChannel? - - init() async throws { - // Load the features. - let group = PlatformSupport.makeEventLoopGroup(loopCount: 1) - let channel = try GRPCChannelPool.with( - target: .host("localhost", port: 8088), - transportSecurity: .plaintext, - eventLoopGroup: group - ) - - client = FlightClient(channel: channel) - } - - deinit { - try? group?.syncShutdownGracefully() - try? channel?.close().wait() - } - - func listActionTest() async throws { - var actionTypes = [FlightActionType]() - try await client?.listActions({ action in - actionTypes.append(action) - }) - - XCTAssertEqual(actionTypes.count, 2) - - XCTAssertEqual(actionTypes[0].type, "clear") - XCTAssertEqual(actionTypes[0].description, "Clear the stored flights.") - XCTAssertEqual(actionTypes[1].type, "shutdown") - XCTAssertEqual(actionTypes[1].description, "Shut down this server.") - } - - func listFlightsTest() async throws { - let flightCriteria = FlightCriteria("flight criteria expression".data(using: .utf8)!) - var numCalls = 0 - try await client?.listFlights(flightCriteria, closure: { data in - if let schema = data.schema { - XCTAssertGreaterThanOrEqual(schema.fields.count, 0) - numCalls += 1 - } - }) - - XCTAssertEqual(numCalls, 2) - } - - func doActionTest(_ type: String, actionBody: Data) async throws { - let action = FlightAction(type, body: actionBody) - var actionResults = [FlightResult]() - try await client?.doAction(action, closure: { result in - actionResults.append(result) - }) - - XCTAssertEqual(actionResults.count, 1) - XCTAssertEqual(String(bytes: actionResults[0].body, encoding: .utf8), "test_action result") - } - - func getSchemaTest(_ cmd: Data) async throws { - let descriptor = FlightDescriptor(cmd: cmd) - let schemaResult = try await client?.getSchema(descriptor) - let schema = schemaResult!.schema! - XCTAssertEqual(schema.fields.count, 3) - } - - func doGetTest(_ flightData: Data) async throws { - let ticket = FlightTicket(flightData) - var numCall = 0 - try await client?.doGet(ticket, readerResultClosure: { rb in - numCall += 1 - XCTAssertEqual(rb.schema!.fields.count, 3) - XCTAssertEqual(rb.batches[0].length, 4) - switch ArrowTable.from(recordBatches: rb.batches) { - case .success(let table): - for column in table.columns { - switch column.type.id { - case .double: - let doubleArray = column.data() as? ChunkedArray - XCTAssertNotNil(doubleArray) - XCTAssertEqual(doubleArray?[0], 11.11) - XCTAssertEqual(doubleArray?.asString(0), "11.11") - default: - continue - } - } - case .failure(let error): - throw error - } - }) - - XCTAssertEqual(numCall, 1) - } - - func doGetTestFlightData(_ flightData: Data) async throws { - let ticket = FlightTicket(flightData) - var numCall = 0 - let reader = ArrowReader() - let arrowResult = ArrowReader.makeArrowReaderResult() - try await client?.doGet(ticket, flightDataClosure: { flightData in - switch reader.fromMessage(flightData.dataHeader, dataBody: flightData.dataBody, result: arrowResult) { - case .success: - numCall += 1 - case .failure(let error): - throw error - } - }) - - XCTAssertEqual(numCall, 2) - } - - func doPutTest(_ cmd: String) async throws { - let descriptor = FlightDescriptor(cmd: cmd.data(using: .utf8)!) - let rb = try makeRecordBatch() - var numCall = 0 - try await client?.doPut(descriptor, recordBatches: [rb], closure: { _ in - numCall += 1 - }) - - XCTAssertEqual(numCall, 1) - } - - func doExchangeTest() async throws { - let descriptor = FlightDescriptor(cmd: "flight_ticket".data(using: .utf8)!) - let rb = try makeRecordBatch() - var numCall = 0 - try await client?.doExchange(descriptor, recordBatches: [rb], closure: { result in - numCall += 1 - XCTAssertEqual(result.schema?.fields.count, 3) - XCTAssertEqual(result.batches[0].length, 4) - }) - - XCTAssertEqual(numCall, 1) - } -} - -actor FlightServerData { - public var serverup = false - func setServerUp(_ serverUp: Bool) { - self.serverup = serverUp - } - - func isServerUp() -> Bool { - return serverup - } -} - -final class FlightTest: XCTestCase { - let serverData = FlightServerData() - - func testFlightServer() async throws { - let basicTask = Task { - try await FlightServerImpl.run() - defer { - print("server shutting down") - do { - try FlightServerImpl.group?.syncShutdownGracefully() - } catch { - } - } - - await serverData.setServerUp(true) - try await FlightServerImpl.server?.onClose.get() - return "done" - } - - let secondTask = Task { - defer { - _ = FlightServerImpl.server?.close() - } - - while await !serverData.isServerUp() { - try await Task.sleep(nanoseconds: 1_000_000) - } - - let clientImpl = try await FlightClientTester() - try await clientImpl.listActionTest() - try await clientImpl.doPutTest("flight_ticket") - try await clientImpl.doPutTest("flight_another") - try await clientImpl.listFlightsTest() - try await clientImpl.doActionTest("healthcheck", actionBody: Data("healthcheck body".utf8)) - try await clientImpl.getSchemaTest(Data("schema info".utf8)) - try await clientImpl.doGetTest(Data("'flight_ticket'".utf8)) - try await clientImpl.doGetTestFlightData(Data("'flight_another'".utf8)) - try await clientImpl.doExchangeTest() - return "done" - } - - _ = try await [basicTask.value, secondTask.value] - print("done running") - } -} diff --git a/swift/CDataWGo/.gitignore b/swift/CDataWGo/.gitignore deleted file mode 100644 index 0023a534063..00000000000 --- a/swift/CDataWGo/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.DS_Store -/.build -/Packages -xcuserdata/ -DerivedData/ -.swiftpm/configuration/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc diff --git a/swift/CDataWGo/Package.swift b/swift/CDataWGo/Package.swift deleted file mode 100644 index 4d517115aca..00000000000 --- a/swift/CDataWGo/Package.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version: 5.10 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -// 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 PackageDescription - -let package = Package( - name: "go-swift", - platforms: [ - .macOS(.v10_14) - ], - products: [ - .library( - name: "go-swift", - type: .static, - targets: ["go-swift"]) - ], - dependencies: [ - .package(path: "../Arrow") // 👈 Reference to a Local Package - ], - targets: [ - .target( - name: "go-swift", - dependencies: [ - .product(name: "Arrow", package: "Arrow") - ]) - ] -) diff --git a/swift/CDataWGo/Sources/go-swift/CDataTest.swift b/swift/CDataWGo/Sources/go-swift/CDataTest.swift deleted file mode 100644 index b38ca7240ab..00000000000 --- a/swift/CDataWGo/Sources/go-swift/CDataTest.swift +++ /dev/null @@ -1,132 +0,0 @@ -// 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 Arrow -import ArrowC - -@_cdecl("stringTypeFromSwift") -func stringTypeFromSwift(cSchema: UnsafePointer) { - let unsafePointer = UnsafeMutablePointer(mutating: cSchema) - let exporter = ArrowCExporter() - switch exporter.exportType(&unsafePointer.pointee, arrowType: ArrowType(ArrowType.ArrowString), name: "col1") { - case .success: - return - case .failure(let err): - fatalError("Error exporting string type from swift: \(err)") - } -} - -@_cdecl("stringTypeToSwift") -func stringTypeToSwift(cSchema: UnsafePointer) { - let importer = ArrowCImporter() - switch importer.importField(cSchema.pointee) { - case .success(let field): - if field.name != "col1" { - fatalError("Field name was incorrect expected: col1 but found: \(field.name)") - } - - if field.type.id != ArrowTypeId.string { - fatalError("Field type was incorrect expected: string but found: \(field.type.id)") - } - case .failure(let err): - fatalError("Error importing string type to swift: \(err)") - } -} - -@_cdecl("arrayIntFromSwift") -func arrayIntFromSwift(cArray: UnsafePointer) { - do { - let unsafePointer = UnsafeMutablePointer(mutating: cArray) - let arrayBuilder: NumberArrayBuilder = try ArrowArrayBuilders.loadNumberArrayBuilder() - for index in 0..<100 { - arrayBuilder.append(Int32(index)) - } - - let array = try arrayBuilder.finish() - let exporter = ArrowCExporter() - exporter.exportArray(&unsafePointer.pointee, arrowData: array.arrowData) - } catch let err { - fatalError("Error exporting array from swift \(err)") - } -} - -@_cdecl("arrayStringFromSwift") -func arrayStringFromSwift(cArray: UnsafePointer) { - do { - let unsafePointer = UnsafeMutablePointer(mutating: cArray) - let arrayBuilder = try ArrowArrayBuilders.loadStringArrayBuilder() - for index in 0..<100 { - arrayBuilder.append("test" + String(index)) - } - - let array = try arrayBuilder.finish() - let exporter = ArrowCExporter() - exporter.exportArray(&unsafePointer.pointee, arrowData: array.arrowData) - } catch let err { - fatalError("Error exporting array from swift \(err)") - } -} - -@_cdecl("arrayIntToSwift") -func arrayIntToSwift(cArray: UnsafePointer) { - let importer = ArrowCImporter() - switch importer.importArray(cArray, arrowType: ArrowType(ArrowType.ArrowInt32)) { - case .success(let int32Holder): - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: int32Holder) - .finish() - switch result { - case .success(let recordBatch): - let col1: Arrow.ArrowArray = recordBatch.data(for: 0) - for index in 0..) { - let importer = ArrowCImporter() - switch importer.importArray(cArray, arrowType: ArrowType(ArrowType.ArrowString)) { - case .success(let dataHolder): - let result = RecordBatch.Builder() - .addColumn("col1", arrowArray: dataHolder) - .finish() - switch result { - case .success(let recordBatch): - let col1: Arrow.ArrowArray = recordBatch.data(for: 0) - for index in 0.. -#include "go_swift.h" -*/ -import "C" -import ( - "strconv" - "unsafe" - - "github.com/apache/arrow-go/v18/arrow" - "github.com/apache/arrow-go/v18/arrow/array" - "github.com/apache/arrow-go/v18/arrow/cdata" - "github.com/apache/arrow-go/v18/arrow/memory" -) - -func stringTypeFromSwift() { - arrowSchema := &cdata.CArrowSchema{} - swSchema := (*C.struct_ArrowSchema)(unsafe.Pointer(arrowSchema)) - C.stringTypeFromSwift(swSchema) - gofield, _ := cdata.ImportCArrowField(arrowSchema) - if gofield.Name != "col1" { - panic("Imported type has incorrect name") - } -} - -func stringTypeToSwift() { - arrowSchema := &cdata.CArrowSchema{} - swSchema := (*C.struct_ArrowSchema)(unsafe.Pointer(arrowSchema)) - C.stringTypeFromSwift(swSchema) - gofield, _ := cdata.ImportCArrowField(arrowSchema) - if gofield.Name != "col1" { - panic("Imported type has incorrect name") - } -} - -func arrayStringFromSwift() { - arrowArray := &cdata.CArrowArray{} - swarray := (*C.struct_ArrowArray)(unsafe.Pointer(arrowArray)) - C.arrayStringFromSwift(swarray) - arr, _ := cdata.ImportCArrayWithType(arrowArray, arrow.BinaryTypes.String) - if arr.Len() != 100 { - panic("Array length is incorrect") - } - - for i := 0; i < 100; i++ { - if arr.ValueStr(i) != ("test" + strconv.Itoa(i)) { - panic("Array value is incorrect") - } - } -} - -func arrayIntFromSwift() { - arrowArray := &cdata.CArrowArray{} - swarray := (*C.struct_ArrowArray)(unsafe.Pointer(arrowArray)) - C.arrayIntFromSwift(swarray) - arr, _ := cdata.ImportCArrayWithType(arrowArray, arrow.PrimitiveTypes.Int32) - if arr.Len() != 100 { - panic("Array length is incorrect") - } - - vals := arr.(*array.Int32).Int32Values() - // and that the values are correct - for i, v := range vals { - if v != int32(i) { - panic("Array value is incorrect") - } - } -} - -func arrayIntToSwift() { - bld := array.NewUint32Builder(memory.DefaultAllocator) - defer bld.Release() - bld.AppendValues([]uint32{1, 2, 3, 4}, []bool{true, true, true, true}) - goarray := bld.NewUint32Array() - var carray cdata.CArrowArray - cdata.ExportArrowArray(goarray, &carray, nil) - swarray := (*C.struct_ArrowArray)(unsafe.Pointer(&carray)) - C.arrayIntToSwift(swarray) - - if swarray.release != nil { - panic("Release was not called by swift to deallocate C array") - } -} - -func arrayStringToSwift() { - bld := array.NewStringBuilder(memory.DefaultAllocator) - defer bld.Release() - bld.AppendValues([]string{"test0", "test1", "test2", "test3"}, []bool{true, true, true, true}) - goarray := bld.NewStringArray() - var carray cdata.CArrowArray - cdata.ExportArrowArray(goarray, &carray, nil) - swarray := (*C.struct_ArrowArray)(unsafe.Pointer(&carray)) - C.arrayStringToSwift(swarray) - - if swarray.release != nil { - panic("Release was not called by swift to deallocate C array") - } -} - -func main() { - stringTypeFromSwift() - stringTypeToSwift() - arrayStringFromSwift() - arrayIntFromSwift() - arrayIntToSwift() - arrayStringToSwift() -} diff --git a/swift/data-generator/swift-datagen/go.mod b/swift/data-generator/swift-datagen/go.mod deleted file mode 100644 index 4f70d416290..00000000000 --- a/swift/data-generator/swift-datagen/go.mod +++ /dev/null @@ -1,38 +0,0 @@ -// 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.23.0 - -toolchain go1.24.1 - -require github.com/apache/arrow-go/v18 v18.3.0 - -require ( - github.com/goccy/go-json v0.10.5 // indirect - github.com/google/flatbuffers v25.2.10+incompatible // indirect - github.com/klauspost/compress v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.10 // indirect - github.com/pierrec/lz4/v4 v4.1.22 // indirect - github.com/zeebo/xxh3 v1.0.2 // indirect - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect - golang.org/x/mod v0.24.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/tools v0.32.0 // indirect - golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect -) diff --git a/swift/data-generator/swift-datagen/go.sum b/swift/data-generator/swift-datagen/go.sum deleted file mode 100644 index 47a0aed07f6..00000000000 --- a/swift/data-generator/swift-datagen/go.sum +++ /dev/null @@ -1,54 +0,0 @@ -github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= -github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/apache/arrow-go/v18 v18.3.0 h1:Xq4A6dZj9Nu33sqZibzn012LNnewkTUlfKVUFD/RX/I= -github.com/apache/arrow-go/v18 v18.3.0/go.mod h1:eEM1DnUTHhgGAjf/ChvOAQbUQ+EPohtDrArffvUjPg8= -github.com/apache/thrift v0.21.0 h1:tdPmh/ptjE1IJnhbhrcl2++TauVjy242rkV/UzJChnE= -github.com/apache/thrift v0.21.0/go.mod h1:W1H8aR/QRtYNvrPeFXBtobyRkd0/YVhTc6i07XIAgDw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= -github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= -github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= -github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -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.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= -github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= -github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -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.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= -github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= -github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= -github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= -github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= -golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= -golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/swift/data-generator/swift-datagen/main.go b/swift/data-generator/swift-datagen/main.go deleted file mode 100644 index dbe24222faf..00000000000 --- a/swift/data-generator/swift-datagen/main.go +++ /dev/null @@ -1,116 +0,0 @@ -// 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/v18/arrow" - "github.com/apache/arrow-go/v18/arrow/array" - "github.com/apache/arrow-go/v18/arrow/ipc" - "github.com/apache/arrow-go/v18/arrow/memory" -) - -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 writeStructData() { - mem := memory.NewGoAllocator() - - fields := []arrow.Field{ - {Name: "my struct", Type: arrow.StructOf([]arrow.Field{ - {Name: "my string", Type: arrow.BinaryTypes.String}, - {Name: "my bool", Type: arrow.FixedWidthTypes.Boolean}, - }...)}, - } - - schema := arrow.NewSchema(fields, nil) - - bld := array.NewRecordBuilder(mem, schema) - defer bld.Release() - - sb := bld.Field(0).(*array.StructBuilder) - f1b := sb.FieldBuilder(0).(*array.StringBuilder) - f2b := sb.FieldBuilder(1).(*array.BooleanBuilder) - - sb.AppendValues([]bool{true, true, false}) - f1b.AppendValues([]string{"0", "1", ""}, []bool{true, true, false}) - f2b.AppendValues([]bool{false, true, false}, []bool{true, true, false}) - - rec := bld.NewRecord() - writeBytes(rec, "testdata_struct.arrow") -} - -func main() { - writeBoolData() - writeDoubleData() - writeStructData() -} diff --git a/swift/gen-flatbuffers.sh b/swift/gen-flatbuffers.sh deleted file mode 100755 index f55f4eb8ba7..00000000000 --- a/swift/gen-flatbuffers.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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.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 diff --git a/swift/gen-protobuffers.sh b/swift/gen-protobuffers.sh deleted file mode 100755 index 383a7a2f319..00000000000 --- a/swift/gen-protobuffers.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 -protoc --swift_out=./ArrowFlight/Sources/ArrowFlight --proto_path=../format Flight.proto -protoc --grpc-swift_out=./ArrowFlight/Sources/ArrowFlight --proto_path=../format Flight.proto -cat <
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 -mv ./ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift ./ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift.orig -cat header.swift ./ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift.orig > ./ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift -rm ./ArrowFlight/Sources/ArrowFlight/Flight.grpc.swift.orig -rm header.swift \ No newline at end of file