You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "abandy (via GitHub)" <gi...@apache.org> on 2023/05/18 02:38:14 UTC

[GitHub] [arrow] abandy opened a new pull request, #35660: GH-34858: [Swift] Initial Swift IPC writer

abandy opened a new pull request, #35660:
URL: https://github.com/apache/arrow/pull/35660

   ### Rationale for this change
   This adds the initial IPC writer for swift in order to write the arrow data to memory or to a file.
   
   ### What changes are included in this PR?
   
   - IPC writer
   - bug fixes found during writer testing
   
   ### Are these changes tested?
   
   Writer unit test added.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] ursabot commented on pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #35660:
URL: https://github.com/apache/arrow/pull/35660#issuecomment-1556886000

   ['Python', 'R'] benchmarks have high level of regressions.
   [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/3c122c05b9cf47819e6c853283061aae...47b166aa0f464693af37b4ce2b1fdcae/)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] kou commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199445141


##########
swift/Arrow/Sources/Arrow/ArrowReader.swift:
##########
@@ -36,11 +36,11 @@ public class ArrowReader {
     }
 
     private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
-        let builder = ArrowSchema.Builder()
+        let builder: ArrowSchema.Builder = ArrowSchema.Builder()

Review Comment:
   I'm not familiar with Swift but why do we need explicit type information here?



##########
swift/Arrow/Sources/Arrow/ArrowWriter.swift:
##########
@@ -0,0 +1,214 @@
+// 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 {
+    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 current_size: Int = 0
+        public var count: Int { return current_size }
+        public init(_ handle: FileHandle) {
+            self.handle = handle
+        }
+        
+        public func append(_ data: Data) {
+            self.handle.write(data)
+            self.current_size += data.count
+        }
+    }
+
+    private func writeField(_ fbb: inout FlatBufferBuilder, field: ArrowField) throws -> Offset {
+        let nameOffset = fbb.create(string: field.name)
+        let fieldTypeOfffset = try toFBType(&fbb, infoType: field.type)
+        let startOffset = org_apache_arrow_flatbuf_Field.startField(&fbb)
+        org_apache_arrow_flatbuf_Field.add(name: nameOffset , &fbb)

Review Comment:
   ```suggestion
           org_apache_arrow_flatbuf_Field.add(name: nameOffset, &fbb)
   ```



##########
swift/Arrow/Sources/Arrow/ArrowTable.swift:
##########
@@ -22,18 +22,58 @@ public class ChunkedArrayHolder {
     public let length: UInt
     public let nullCount: UInt
     public let holder: Any
-            
+    public let getBufferData: () throws -> [Data]
+    public let getBufferDataSizes: () throws -> [Int]
     public init<T>(_ chunked: ChunkedArray<T>) {
         self.holder = chunked
         self.length = chunked.length
         self.type = chunked.type
         self.nullCount = chunked.nullCount
+        self.getBufferData = {() throws -> [Data] in 
+            var bufferData = [Data]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {
+                numBuffers = 3
+            }
+
+            for _ in 0 ..< numBuffers {
+                bufferData.append(Data())
+            }
+
+            for arrow_data in chunked.arrays {
+                for index in 0 ..< numBuffers {
+                    arrow_data.arrowData.buffers[index].append(to: &bufferData[index])
+                }
+            }
+
+            return bufferData;
+        }
+        
+        self.getBufferDataSizes = {() throws -> [Int] in
+            var bufferDataSizes = [Int]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {

Review Comment:
   ```suggestion
               if !isFixedPrimitive(try toFBTypeEnum(chunked.type)) {
   ```



##########
swift/Arrow/Sources/Arrow/ArrowReader.swift:
##########
@@ -36,11 +36,11 @@ public class ArrowReader {
     }
 
     private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
-        let builder = ArrowSchema.Builder()
+        let builder: ArrowSchema.Builder = ArrowSchema.Builder()
         for index in 0 ..< schema.fieldsCount {
             let field = schema.fields(at: index)!
-            let arrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
-            builder.addField(arrowField)
+            let arrowField: ArrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
+            let _ = builder.addField(arrowField)

Review Comment:
   Is it OK that we don't need to check the return value?



##########
swift/Arrow/Tests/ArrowTests/IPCTests.swift:
##########
@@ -53,28 +78,83 @@ final class IPCTests: XCTestCase {
     func testFileReader_bool() throws {
         let fileURL = currentDirectory().appendingPathComponent("../../testdata_bool.arrow")
         let arrowReader = ArrowReader()
-        let recordBatchs = try arrowReader.fromFile(fileURL)
-        XCTAssertEqual(recordBatchs.count, 1)
-        for recordBatch in recordBatchs {
-            XCTAssertEqual(recordBatch.length, 5)
-            XCTAssertEqual(recordBatch.columns.count, 2)
-            XCTAssertEqual(recordBatch.schema.fields.count, 2)
-            XCTAssertEqual(recordBatch.schema.fields[0].name, "one")
-            XCTAssertEqual(recordBatch.schema.fields[0].type, ArrowType.ArrowBool)
-            XCTAssertEqual(recordBatch.schema.fields[1].name, "two")
+        let fileRBs = try arrowReader.fromFile(fileURL)
+        checkBoolRecordBatch(fileRBs)
+    }
+    
+    func testFileWriter_bool() throws {
+        //read existing file
+        let fileURL = currentDirectory().appendingPathComponent("../../testdata_bool.arrow")
+        let arrowReader = ArrowReader()
+        let fileRBs = try arrowReader.fromFile(fileURL)
+        checkBoolRecordBatch(fileRBs)
+        let arrowWriter = ArrowWriter()
+        //write data from file to a stream
+        let writeData = try arrowWriter.toStream(fileRBs[0].schema, batches: fileRBs)
+        //read stream back into recordbatches
+        checkBoolRecordBatch(try arrowReader.fromStream(writeData))
+        //write file record batches to another file
+        let outputUrl = currentDirectory().appendingPathComponent("../../testfilereader_bool.arrow")

Review Comment:
   ```suggestion
           let outputUrl = currentDirectory().appendingPathComponent("../../testfilewriter_bool.arrow")
   ```



##########
swift/Arrow/Sources/Arrow/ArrowTable.swift:
##########
@@ -22,18 +22,58 @@ public class ChunkedArrayHolder {
     public let length: UInt
     public let nullCount: UInt
     public let holder: Any
-            
+    public let getBufferData: () throws -> [Data]
+    public let getBufferDataSizes: () throws -> [Int]
     public init<T>(_ chunked: ChunkedArray<T>) {
         self.holder = chunked
         self.length = chunked.length
         self.type = chunked.type
         self.nullCount = chunked.nullCount
+        self.getBufferData = {() throws -> [Data] in 
+            var bufferData = [Data]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {

Review Comment:
   ```suggestion
               if !isFixedPrimitive(try toFBTypeEnum(chunked.type)) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199514942


##########
swift/Arrow/Sources/Arrow/ArrowReader.swift:
##########
@@ -36,11 +36,11 @@ public class ArrowReader {
     }
 
     private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
-        let builder = ArrowSchema.Builder()
+        let builder: ArrowSchema.Builder = ArrowSchema.Builder()
         for index in 0 ..< schema.fieldsCount {
             let field = schema.fields(at: index)!
-            let arrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
-            builder.addField(arrowField)
+            let arrowField: ArrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
+            let _ = builder.addField(arrowField)

Review Comment:
   The return value is just the Builder so we can chain the calls for other use cases. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] ursabot commented on pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #35660:
URL: https://github.com/apache/arrow/pull/35660#issuecomment-1556882854

   Benchmark runs are scheduled for baseline = 4129fe1a3e6fca1ab46d9f59a914110f58ec94c6 and contender = 65520b361941e9abad386614999dbc250295959e. 65520b361941e9abad386614999dbc250295959e is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1c0d35223e0a488b85ac6c6b818b0587...24194366feb44352affe2813c84ac53e/)
   [Finished :arrow_down:0.15% :arrow_up:0.09%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/b40c997d143c4a858ca0a963a4735e94...27d76796c8bd400ca6eeb6fd74e83b82/)
   [Finished :arrow_down:0.65% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/3c122c05b9cf47819e6c853283061aae...47b166aa0f464693af37b4ce2b1fdcae/)
   [Finished :arrow_down:0.75% :arrow_up:0.0%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/00518eacb6f440c9bf6fc3aef2bfd6ae...b35e9fe4ac9e49e6835ec075b4631568/)
   Buildkite builds:
   [Finished] [`65520b36` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2907)
   [Finished] [`65520b36` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2943)
   [Finished] [`65520b36` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2908)
   [Finished] [`65520b36` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2933)
   [Finished] [`4129fe1a` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2906)
   [Finished] [`4129fe1a` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2942)
   [Finished] [`4129fe1a` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2907)
   [Finished] [`4129fe1a` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2932)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] github-actions[bot] commented on pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35660:
URL: https://github.com/apache/arrow/pull/35660#issuecomment-1552329647

   * Closes: #35659


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] github-actions[bot] commented on pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35660:
URL: https://github.com/apache/arrow/pull/35660#issuecomment-1552329673

   :warning: GitHub issue #35659 **has been automatically assigned in GitHub** to PR creator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] kou commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199616597


##########
swift/Arrow/Sources/Arrow/ArrowReader.swift:
##########
@@ -36,11 +36,11 @@ public class ArrowReader {
     }
 
     private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
-        let builder = ArrowSchema.Builder()
+        let builder: ArrowSchema.Builder = ArrowSchema.Builder()
         for index in 0 ..< schema.fieldsCount {
             let field = schema.fields(at: index)!
-            let arrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
-            builder.addField(arrowField)
+            let arrowField: ArrowField = ArrowField(field.name!, type: findArrowType(field), isNullable: field.nullable)
+            let _ = builder.addField(arrowField)

Review Comment:
   I see.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on PR #35660:
URL: https://github.com/apache/arrow/pull/35660#issuecomment-1555408763

   Hi @kou, thank you!  I have updated accordingly and will merge after the changes based on your comments have passed checks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199514547


##########
swift/Arrow/Sources/Arrow/ArrowTable.swift:
##########
@@ -22,18 +22,58 @@ public class ChunkedArrayHolder {
     public let length: UInt
     public let nullCount: UInt
     public let holder: Any
-            
+    public let getBufferData: () throws -> [Data]
+    public let getBufferDataSizes: () throws -> [Int]
     public init<T>(_ chunked: ChunkedArray<T>) {
         self.holder = chunked
         self.length = chunked.length
         self.type = chunked.type
         self.nullCount = chunked.nullCount
+        self.getBufferData = {() throws -> [Data] in 
+            var bufferData = [Data]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {
+                numBuffers = 3
+            }
+
+            for _ in 0 ..< numBuffers {
+                bufferData.append(Data())
+            }
+
+            for arrow_data in chunked.arrays {
+                for index in 0 ..< numBuffers {
+                    arrow_data.arrowData.buffers[index].append(to: &bufferData[index])
+                }
+            }
+
+            return bufferData;
+        }
+        
+        self.getBufferDataSizes = {() throws -> [Int] in
+            var bufferDataSizes = [Int]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {

Review Comment:
   Will update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199514590


##########
swift/Arrow/Sources/Arrow/ArrowReader.swift:
##########
@@ -36,11 +36,11 @@ public class ArrowReader {
     }
 
     private func loadSchema(_ schema: org_apache_arrow_flatbuf_Schema) throws -> ArrowSchema {
-        let builder = ArrowSchema.Builder()
+        let builder: ArrowSchema.Builder = ArrowSchema.Builder()

Review Comment:
   This was added by xcode.  I will remove.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199514958


##########
swift/Arrow/Sources/Arrow/ArrowWriter.swift:
##########
@@ -0,0 +1,214 @@
+// 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 {
+    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 current_size: Int = 0
+        public var count: Int { return current_size }
+        public init(_ handle: FileHandle) {
+            self.handle = handle
+        }
+        
+        public func append(_ data: Data) {
+            self.handle.write(data)
+            self.current_size += data.count
+        }
+    }
+
+    private func writeField(_ fbb: inout FlatBufferBuilder, field: ArrowField) throws -> Offset {
+        let nameOffset = fbb.create(string: field.name)
+        let fieldTypeOfffset = try toFBType(&fbb, infoType: field.type)
+        let startOffset = org_apache_arrow_flatbuf_Field.startField(&fbb)
+        org_apache_arrow_flatbuf_Field.add(name: nameOffset , &fbb)

Review Comment:
   Will update.



##########
swift/Arrow/Tests/ArrowTests/IPCTests.swift:
##########
@@ -53,28 +78,83 @@ final class IPCTests: XCTestCase {
     func testFileReader_bool() throws {
         let fileURL = currentDirectory().appendingPathComponent("../../testdata_bool.arrow")
         let arrowReader = ArrowReader()
-        let recordBatchs = try arrowReader.fromFile(fileURL)
-        XCTAssertEqual(recordBatchs.count, 1)
-        for recordBatch in recordBatchs {
-            XCTAssertEqual(recordBatch.length, 5)
-            XCTAssertEqual(recordBatch.columns.count, 2)
-            XCTAssertEqual(recordBatch.schema.fields.count, 2)
-            XCTAssertEqual(recordBatch.schema.fields[0].name, "one")
-            XCTAssertEqual(recordBatch.schema.fields[0].type, ArrowType.ArrowBool)
-            XCTAssertEqual(recordBatch.schema.fields[1].name, "two")
+        let fileRBs = try arrowReader.fromFile(fileURL)
+        checkBoolRecordBatch(fileRBs)
+    }
+    
+    func testFileWriter_bool() throws {
+        //read existing file
+        let fileURL = currentDirectory().appendingPathComponent("../../testdata_bool.arrow")
+        let arrowReader = ArrowReader()
+        let fileRBs = try arrowReader.fromFile(fileURL)
+        checkBoolRecordBatch(fileRBs)
+        let arrowWriter = ArrowWriter()
+        //write data from file to a stream
+        let writeData = try arrowWriter.toStream(fileRBs[0].schema, batches: fileRBs)
+        //read stream back into recordbatches
+        checkBoolRecordBatch(try arrowReader.fromStream(writeData))
+        //write file record batches to another file
+        let outputUrl = currentDirectory().appendingPathComponent("../../testfilereader_bool.arrow")

Review Comment:
   Will update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] abandy commented on a diff in pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "abandy (via GitHub)" <gi...@apache.org>.
abandy commented on code in PR #35660:
URL: https://github.com/apache/arrow/pull/35660#discussion_r1199514523


##########
swift/Arrow/Sources/Arrow/ArrowTable.swift:
##########
@@ -22,18 +22,58 @@ public class ChunkedArrayHolder {
     public let length: UInt
     public let nullCount: UInt
     public let holder: Any
-            
+    public let getBufferData: () throws -> [Data]
+    public let getBufferDataSizes: () throws -> [Int]
     public init<T>(_ chunked: ChunkedArray<T>) {
         self.holder = chunked
         self.length = chunked.length
         self.type = chunked.type
         self.nullCount = chunked.nullCount
+        self.getBufferData = {() throws -> [Data] in 
+            var bufferData = [Data]()
+            var numBuffers = 2;
+            if(!isFixedPrimitive(try toFBTypeEnum(chunked.type))) {

Review Comment:
   Good catch, will update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] kou merged pull request #35660: GH-35659: [Swift] Initial Swift IPC writer

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #35660:
URL: https://github.com/apache/arrow/pull/35660


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org