Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Arrow/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Arrow/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
targets: ["Arrow"])
],
dependencies: [
.package(url: "https://github.com/google/flatbuffers.git", from: "25.2.10"),
.package(url: "https://github.com/google/flatbuffers.git", exact: "25.2.10"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.3.0")
],
targets: [
Expand Down
19 changes: 10 additions & 9 deletions Arrow/Sources/Arrow/ArrowReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ public class ArrowReader { // swiftlint:disable:this type_body_length

offset += Int(MemoryLayout<UInt32>.size)
streamData = input[offset...]
let dataBuffer = ByteBuffer(
var dataBuffer = ByteBuffer(
data: streamData,
allowReadingUnalignedBuffers: true)
let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: dataBuffer)
allowReadingUnalignedBuffers: true
)
let message: org_apache_arrow_flatbuf_Message = getRoot(byteBuffer: &dataBuffer)
switch message.headerType {
case .recordbatch:
let rbMessage = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)!
Expand Down Expand Up @@ -296,10 +297,10 @@ public class ArrowReader { // swiftlint:disable:this type_body_length
let result = ArrowReaderResult()
let footerStartOffset = fileData.count - Int(footerLength + 4)
let footerData = fileData[footerStartOffset...]
let footerBuffer = ByteBuffer(
var footerBuffer = ByteBuffer(
data: footerData,
allowReadingUnalignedBuffers: useUnalignedBuffers)
let footer = org_apache_arrow_flatbuf_Footer.getRootAsFooter(bb: footerBuffer)
let footer: org_apache_arrow_flatbuf_Footer = getRoot(byteBuffer: &footerBuffer)
let schemaResult = loadSchema(footer.schema!)
switch schemaResult {
case .success(let schema):
Expand Down Expand Up @@ -327,10 +328,10 @@ public class ArrowReader { // swiftlint:disable:this type_body_length
let messageStartOffset = recordBatch.offset + (Int64(MemoryLayout<Int32>.size) * messageOffset)
let messageEndOffset = messageStartOffset + Int64(messageLength)
let recordBatchData = fileData[messageStartOffset ..< messageEndOffset]
let mbb = ByteBuffer(
var mbb = ByteBuffer(
data: recordBatchData,
allowReadingUnalignedBuffers: useUnalignedBuffers)
let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: mbb)
let message: org_apache_arrow_flatbuf_Message = getRoot(byteBuffer: &mbb)
switch message.headerType {
case .recordbatch:
let rbMessage = message.header(type: org_apache_arrow_flatbuf_RecordBatch.self)!
Expand Down Expand Up @@ -380,10 +381,10 @@ public class ArrowReader { // swiftlint:disable:this type_body_length
result: ArrowReaderResult,
useUnalignedBuffers: Bool = false
) -> Result<Void, ArrowError> {
let mbb = ByteBuffer(
var mbb = ByteBuffer(
data: dataHeader,
allowReadingUnalignedBuffers: useUnalignedBuffers)
let message = org_apache_arrow_flatbuf_Message.getRootAsMessage(bb: mbb)
let message: org_apache_arrow_flatbuf_Message = getRoot(byteBuffer: &mbb)
switch message.headerType {
case .schema:
let sMessage = message.header(type: org_apache_arrow_flatbuf_Schema.self)!
Expand Down
9 changes: 3 additions & 6 deletions Arrow/Sources/Arrow/File_generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// 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
Expand All @@ -23,7 +22,7 @@ import FlatBuffers

public struct org_apache_arrow_flatbuf_Block: NativeStruct, Verifiable, FlatbuffersInitializable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }

/// Index to the start of the RecordBlock (note this is past the Message header)
private var _offset: Int64
Expand Down Expand Up @@ -68,7 +67,7 @@ public struct org_apache_arrow_flatbuf_Block: NativeStruct, Verifiable, Flatbuff

public struct org_apache_arrow_flatbuf_Block_Mutable: FlatBufferObject {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct

Expand All @@ -84,12 +83,10 @@ public struct org_apache_arrow_flatbuf_Block_Mutable: FlatBufferObject {
///
public struct org_apache_arrow_flatbuf_Footer: FlatBufferObject, Verifiable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
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) }

Expand Down
50 changes: 32 additions & 18 deletions Arrow/Sources/Arrow/Message_generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// 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
Expand Down Expand Up @@ -94,7 +93,7 @@ public enum org_apache_arrow_flatbuf_MessageHeader: UInt8, UnionEnum {
/// 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() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }

/// The number of value slots in the Arrow array at this level of a nested
/// tree
Expand Down Expand Up @@ -144,7 +143,7 @@ public struct org_apache_arrow_flatbuf_FieldNode: NativeStruct, Verifiable, Flat
/// 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() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct

Expand All @@ -159,12 +158,10 @@ public struct org_apache_arrow_flatbuf_FieldNode_Mutable: FlatBufferObject {
/// message types
public struct org_apache_arrow_flatbuf_BodyCompression: FlatBufferObject, Verifiable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
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) }

Expand Down Expand Up @@ -208,12 +205,10 @@ public struct org_apache_arrow_flatbuf_BodyCompression: FlatBufferObject, Verifi
/// batch".
public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
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) }

Expand All @@ -222,6 +217,7 @@ public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable
case nodes = 6
case buffers = 8
case compression = 10
case variadicBufferCounts = 12
var v: Int32 { Int32(self.rawValue) }
var p: VOffset { self.rawValue }
}
Expand All @@ -246,7 +242,25 @@ public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable
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) }
/// Some types such as Utf8View are represented using a variable number of buffers.
/// For each such Field in the pre-ordered flattened logical schema, there will be
/// an entry in variadicBufferCounts to indicate the number of number of variadic
/// buffers which belong to that Field in the current RecordBatch.
///
/// For example, the schema
/// col1: Struct<alpha: Int32, beta: BinaryView, gamma: Float64>
/// col2: Utf8View
/// contains two Fields with variadic buffers so variadicBufferCounts will have
/// two entries, the first counting the variadic buffers of `col1.beta` and the
/// second counting `col2`'s.
///
/// This field may be omitted if and only if the schema contains no Fields with
/// a variable number of buffers, such as BinaryView and Utf8View.
public var hasVariadicBufferCounts: Bool { let o = _accessor.offset(VTOFFSET.variadicBufferCounts.v); return o == 0 ? false : true }
public var variadicBufferCountsCount: Int32 { let o = _accessor.offset(VTOFFSET.variadicBufferCounts.v); return o == 0 ? 0 : _accessor.vector(count: o) }
public func variadicBufferCounts(at index: Int32) -> Int64 { let o = _accessor.offset(VTOFFSET.variadicBufferCounts.v); return o == 0 ? 0 : _accessor.directRead(of: Int64.self, offset: _accessor.vector(at: o) + index * 8) }
public var variadicBufferCounts: [Int64] { return _accessor.getVector(at: VTOFFSET.variadicBufferCounts.v) ?? [] }
public static func startRecordBatch(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 5) }
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) {
Expand All @@ -257,19 +271,22 @@ public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable
builder.startVector(size * MemoryLayout<org_apache_arrow_flatbuf_Buffer>.size, elementSize: MemoryLayout<org_apache_arrow_flatbuf_Buffer>.alignment)
}
public static func add(compression: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: compression, at: VTOFFSET.compression.p) }
public static func addVectorOf(variadicBufferCounts: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: variadicBufferCounts, at: VTOFFSET.variadicBufferCounts.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()
compressionOffset compression: Offset = Offset(),
variadicBufferCountsVectorOffset variadicBufferCounts: 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)
org_apache_arrow_flatbuf_RecordBatch.addVectorOf(variadicBufferCounts: variadicBufferCounts, &fbb)
return org_apache_arrow_flatbuf_RecordBatch.endRecordBatch(&fbb, start: __start)
}

Expand All @@ -279,6 +296,7 @@ public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable
try _v.visit(field: VTOFFSET.nodes.p, fieldName: "nodes", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_FieldNode, org_apache_arrow_flatbuf_FieldNode>>.self)
try _v.visit(field: VTOFFSET.buffers.p, fieldName: "buffers", required: false, type: ForwardOffset<Vector<org_apache_arrow_flatbuf_Buffer, org_apache_arrow_flatbuf_Buffer>>.self)
try _v.visit(field: VTOFFSET.compression.p, fieldName: "compression", required: false, type: ForwardOffset<org_apache_arrow_flatbuf_BodyCompression>.self)
try _v.visit(field: VTOFFSET.variadicBufferCounts.p, fieldName: "variadicBufferCounts", required: false, type: ForwardOffset<Vector<Int64, Int64>>.self)
_v.finish()
}
}
Expand All @@ -291,12 +309,10 @@ public struct org_apache_arrow_flatbuf_RecordBatch: FlatBufferObject, Verifiable
/// flag
public struct org_apache_arrow_flatbuf_DictionaryBatch: FlatBufferObject, Verifiable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
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) }

Expand All @@ -313,7 +329,7 @@ public struct org_apache_arrow_flatbuf_DictionaryBatch: FlatBufferObject, Verifi
/// 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 var isDelta: Bool { let o = _accessor.offset(VTOFFSET.isDelta.v); return o == 0 ? false : _accessor.readBuffer(of: Bool.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) }
Expand Down Expand Up @@ -344,12 +360,10 @@ public struct org_apache_arrow_flatbuf_DictionaryBatch: FlatBufferObject, Verifi

public struct org_apache_arrow_flatbuf_Message: FlatBufferObject, Verifiable {

static func validateVersion() { FlatBuffersVersion_23_1_4() }
static func validateVersion() { FlatBuffersVersion_25_2_10() }
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) }

Expand Down
Loading