alamb commented on code in PR #11161:
URL: https://github.com/apache/arrow-rs/pull/11161#discussion_r4145158389
##########
arrow-array/src/ffi_stream.rs:
##########
@@ -533,6 +548,78 @@ impl RecordBatchReader for ArrowArrayStreamReader {
}
}
+/// An [`ArrayReader`] which imports arrays from an [`FFI_ArrowArrayStream`].
+///
+/// Unlike [`ArrowArrayStreamReader`], the stream's arrays may be of **any**
data type. This
+/// supports reading a stream of generic arrays that may not represent record
batches.
Review Comment:
I don't fully undersrtand the distinction -- can't ArrowArrayStreamReader
also read any type of array (as RecordBatch can have any type of array 🤔 )
##########
arrow-array/src/array_reader.rs:
##########
@@ -0,0 +1,160 @@
+// 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.
+
+//! Traits for reading a stream of [`ArrayRef`] that share a single
[`FieldRef`].
+
+use arrow_schema::{ArrowError, FieldRef};
+
+use crate::array::ArrayRef;
+
+/// Trait for types that can read `ArrayRef`'s.
+///
+/// This is the array-level counterpart to [`RecordBatchReader`], for streams
whose
+/// elements are not record batches.
+///
+/// To create from an iterator, see [ArrayIterator].
+///
+/// [`RecordBatchReader`]: crate::RecordBatchReader
+pub trait ArrayReader: Iterator<Item = Result<ArrayRef, ArrowError>> {
+ /// Returns the field of this `ArrayReader`.
+ ///
+ /// Implementation of this trait should guarantee that all `ArrayRef`'s
returned by this
+ /// reader should have the same field as returned from this method.
+ fn field(&self) -> FieldRef;
Review Comment:
If possible, I recommend returning `&FieldRef` so the caller can decide if
they need to increment the ref count. 🤷
--
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]