alamb commented on code in PR #3391:
URL: https://github.com/apache/arrow-rs/pull/3391#discussion_r1057004432
##########
arrow-flight/src/client.rs:
##########
@@ -268,300 +271,3 @@ impl FlightClient {
request
}
}
-
-/// A stream of [`RecordBatch`]es from from an Arrow Flight server.
-///
-/// To access the lower level Flight messages directly, consider
-/// calling [`Self::into_inner`] and using the [`FlightDataStream`]
-/// directly.
-#[derive(Debug)]
-pub struct FlightRecordBatchStream {
Review Comment:
This is moved / renamed / tested in decode.rs
##########
arrow-flight/tests/client.rs:
##########
@@ -173,7 +174,90 @@ async fn test_get_flight_info_metadata() {
// TODO more negative tests (like if there are endpoints defined, etc)
-// TODO test for do_get
+#[tokio::test]
+async fn test_do_get() {
Review Comment:
here are the tests for `do_get` promised in
https://github.com/apache/arrow-rs/pull/3378
##########
arrow-flight/tests/encode_decode.rs:
##########
@@ -0,0 +1,283 @@
+// 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.
+
+//! Tests for round trip encoding / decoding
Review Comment:
Here are the round trip tests for encode/decode (that ensure that
`RecordBatch`es sent via Flight get through correctly
I expect that we can use this framework as we sort out how to properly
encode dictionaries (e.g. https://github.com/apache/arrow-rs/issues/3389)
##########
arrow-flight/src/encode.rs:
##########
@@ -0,0 +1,503 @@
+// 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.
+
+use std::{collections::VecDeque, fmt::Debug, pin::Pin, sync::Arc, task::Poll};
+
+use crate::{error::FlightError, error::Result, FlightData, SchemaAsIpc};
+use arrow_array::{ArrayRef, RecordBatch};
+use arrow_ipc::writer::{DictionaryTracker, IpcDataGenerator, IpcWriteOptions};
+use arrow_schema::{DataType, Field, Schema, SchemaRef};
+use bytes::Bytes;
+use futures::{ready, stream::BoxStream, Stream, StreamExt};
+
+/// Creates a [`Stream`](futures::Stream) of [`FlightData`]s from a
+/// `Stream` of [`Result`]<[`RecordBatch`], [`FlightError`]>.
+///
+/// This can be used to implement [`FlightService::do_get`] in an
+/// Arrow Flight implementation;
+///
+/// # Caveats
+/// 1. [`DictionaryArray`](arrow_array::array::DictionaryArray)s
+/// are converted to their underlying types prior to transport, due to
+/// <https://github.com/apache/arrow-rs/issues/3389>.
+///
+/// # Example
+/// ```no_run
+/// # use std::sync::Arc;
+/// # use arrow_array::{ArrayRef, RecordBatch, UInt32Array};
+/// # async fn f() {
+/// # let c1 = UInt32Array::from(vec![1, 2, 3, 4, 5, 6]);
+/// # let record_batch = RecordBatch::try_from_iter(vec![
+/// # ("a", Arc::new(c1) as ArrayRef)
+/// # ])
+/// # .expect("cannot create record batch");
+/// use arrow_flight::encode::FlightDataEncoderBuilder;
+///
+/// // Get an input stream of Result<RecordBatch, FlightError>
+/// let input_stream = futures::stream::iter(vec![Ok(record_batch)]);
+///
+/// // Build a stream of `Result<FlightData>` (e.g. to return for do_get)
+/// let flight_data_stream = FlightDataEncoderBuilder::new()
+/// .build(input_stream);
+///
+/// // Create a tonic `Response` that can be returned from a Flight server
+/// let response = tonic::Response::new(flight_data_stream);
+/// # }
+/// ```
+///
+/// [`FlightService::do_get`]:
crate::flight_service_server::FlightService::do_get
+#[derive(Debug)]
+pub struct FlightDataEncoderBuilder {
+ /// The maximum message size (see details on
[`Self::with_max_message_size`]).
+ max_batch_size: usize,
+ /// Ipc writer options
+ options: IpcWriteOptions,
+ /// Metadata to add to the schema message
+ app_metadata: Bytes,
Review Comment:
I hope eventually there can be options related to dictionary encoding here
-- like "try and match dictionaries" for example
##########
arrow-flight/src/encode.rs:
##########
@@ -0,0 +1,503 @@
+// 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.
+
+use std::{collections::VecDeque, fmt::Debug, pin::Pin, sync::Arc, task::Poll};
Review Comment:
This is code based on https://github.com/influxdata/influxdb_iox/pull/6460,
It handles encoding RecordBatches into FlightData and the details of
dictionaries, etc.
##########
arrow-ipc/src/writer.rs:
##########
@@ -37,7 +37,7 @@ use arrow_schema::*;
use crate::compression::CompressionCodec;
use crate::CONTINUATION_MARKER;
-/// IPC write options used to control the behaviour of the writer
+/// IPC write options used to control the behaviour of the [`IpcDataGenerator`]
Review Comment:
drive by doc fixes
--
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]