abandy commented on code in PR #36547:
URL: https://github.com/apache/arrow/pull/36547#discussion_r1268290947


##########
swift/ArrowFlight/Sources/ArrowFlight/FlightClient.swift:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import struct Foundation.Data
+import struct Foundation.URL
+import GRPC
+import NIOCore
+import NIOPosix
+import Arrow
+
+public class FlightClient {
+    let client: Arrow_Flight_Protocol_FlightServiceAsyncClient
+    public init(channel: GRPCChannel) {
+        client = Arrow_Flight_Protocol_FlightServiceAsyncClient(channel: 
channel)
+    }
+    
+    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 {

Review Comment:
   Will change, agreed, I will start looking around.



##########
swift/ArrowFlight/Sources/ArrowFlight/RecordBatchStreamReader.swift:
##########
@@ -0,0 +1,67 @@
+// 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 = RecordBatch
+    let reader = ArrowReader()
+    var batches = [RecordBatch]()
+    var batchIndex = 0
+    var streamIterator: any AsyncIteratorProtocol
+    let stream: GRPC.GRPCAsyncRequestStream<Arrow_Flight_Protocol_FlightData>
+    init(_ stream: 
GRPC.GRPCAsyncRequestStream<Arrow_Flight_Protocol_FlightData>) {
+        self.stream = stream
+        self.streamIterator = self.stream.makeAsyncIterator()
+    }
+    
+    public func next() async throws -> Arrow.RecordBatch? {
+        guard !Task.isCancelled else {
+            return nil
+        }
+
+        if batchIndex < batches.count {
+            let batch = batches[batchIndex]
+            batchIndex += 1
+            return batch
+        }
+         
+        while true {
+            let flight_data = try await self.streamIterator.next()

Review Comment:
   Will do.,



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to