tustvold commented on code in PR #2586:
URL: https://github.com/apache/arrow-rs/pull/2586#discussion_r960740953
##########
arrow-flight/src/lib.rs:
##########
@@ -275,19 +280,23 @@ impl TryFrom<SchemaAsIpc<'_>> for IpcMessage {
type Error = ArrowError;
fn try_from(schema_ipc: SchemaAsIpc) -> ArrowResult<Self> {
- let pair = *schema_ipc;
- let encoded_data = flight_schema_as_encoded_data(pair.0, pair.1);
-
- let mut schema = vec![];
- arrow::ipc::writer::write_message(&mut schema, encoded_data, pair.1)?;
- Ok(IpcMessage(schema))
+ schema_to_ipc_format(schema_ipc)
}
}
+fn schema_to_ipc_format(schema_ipc: SchemaAsIpc) -> ArrowResult<IpcMessage> {
+ let pair = *schema_ipc;
+ let encoded_data = flight_schema_as_encoded_data(pair.0, pair.1);
+
+ let mut schema = vec![];
+ arrow::ipc::writer::write_message(&mut schema, encoded_data, pair.1)?;
Review Comment:
I've double-checked this will write the continuation token :+1:
##########
arrow-flight/src/lib.rs:
##########
@@ -254,10 +254,17 @@ impl From<SchemaAsIpc<'_>> for FlightData {
}
}
-impl From<SchemaAsIpc<'_>> for SchemaResult {
- fn from(schema_ipc: SchemaAsIpc) -> Self {
- let IpcMessage(vals) = flight_schema_as_flatbuffer(schema_ipc.0,
schema_ipc.1);
Review Comment:
I would agree the original Rust implementation is different, I'm not sure I
would go so far as to say it is incorrect. There is no particular need to send
the length, given the protobuf is already providing the message framing.
##########
arrow/src/ipc/convert.rs:
##########
@@ -153,6 +154,51 @@ pub fn schema_from_bytes(bytes: &[u8]) -> Result<Schema> {
}
}
+/// Try deserialize the IPC format bytes into a schema
+pub fn try_schema_from_ipc_buffer(buffer: &[u8]) -> Result<Schema> {
+ // There are two protocal types:
https://issues.apache.org/jira/browse/ARROW-6313
Review Comment:
```suggestion
// There are two protocol types:
https://issues.apache.org/jira/browse/ARROW-6313
```
##########
arrow/src/ipc/convert.rs:
##########
@@ -153,6 +154,51 @@ pub fn schema_from_bytes(bytes: &[u8]) -> Result<Schema> {
}
}
+/// Try deserialize the IPC format bytes into a schema
+pub fn try_schema_from_ipc_buffer(buffer: &[u8]) -> Result<Schema> {
+ // There are two protocal types:
https://issues.apache.org/jira/browse/ARROW-6313
+ // The original protocal is:
+ // 4 bytes - the byte length of the payload
+ // a flatbuffer Message whose header is the Schema
+ // The latest version of protocal is:
Review Comment:
```suggestion
// The latest version of protocol is:
```
--
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]