alamb commented on code in PR #9166:
URL: https://github.com/apache/arrow-rs/pull/9166#discussion_r2692187630


##########
arrow-array/src/nonblocking.rs:
##########
@@ -0,0 +1,33 @@
+// 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.
+
+//! Trait definitions specific to using Arrow with async.
+
+use std::sync::Arc;
+
+use arrow_schema::{ArrowError, SchemaRef};
+
+use crate::record_batch::RecordBatch;
+
+/// Trait for an asynchronous stream of `RecordBatch`es.
+pub trait RecordBatchStream: futures::Stream<Item = Result<RecordBatch, 
ArrowError>> {
+    /// Return the schema of this `RecordBatchStream`.
+    ///
+    /// Implementation of this trait should guarantee that all `RecordBatch`'s 
returned by this
+    /// reader should have the same schema as returned from this method.
+    fn schema(&self) -> SchemaRef;

Review Comment:
   FWIW we have a synchronous API in DataFusion and it works very well: 
https://docs.rs/datafusion/latest/datafusion/execution/trait.RecordBatchStream.html
   
   
   One nit I would suggest would be returning `&SchemaRef` rather than 
`SchemaRef` -- so that the caller can decide if they want to clone the Arc or 
not -- I know cloning Arc's isn't all that big a deal, but it does add up over 
time
   
   



-- 
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