liukun4515 commented on code in PR #2586:
URL: https://github.com/apache/arrow-rs/pull/2586#discussion_r958332880
##########
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);
- SchemaResult { schema: vals }
+impl TryFrom<SchemaAsIpc<'_>> for SchemaResult {
+ type Error = ArrowError;
+
+ fn try_from(schema_ipc: SchemaAsIpc) -> ArrowResult<Self> {
Review Comment:
> The Go implementation resolved the incompatibility very early on and so
never had to worry about the backwards compatibility. I'd suggest checking for
the continuation token and if it is there, attempt to parse both ways,
otherwise fall back to the original version.
I check the java code for the `getschema` api
In the server side
```
@Override
public void getSchema(Flight.FlightDescriptor request,
StreamObserver<Flight.SchemaResult> responseObserver) {
try {
SchemaResult result = producer
.getSchema(makeContext((ServerCallStreamObserver<?>)
responseObserver),
new FlightDescriptor(request));
responseObserver.onNext(result.toProtocol());
responseObserver.onCompleted();
} catch (Exception ex) {
responseObserver.onError(StatusUtils.toGrpcException(ex));
}
}
Flight.SchemaResult toProtocol() {
// Encode schema in a Message payload
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
MessageSerializer.serialize(new
WriteChannel(Channels.newChannel(baos)), schema, option);
} catch (IOException e) {
throw new RuntimeException(e);
}
return Flight.SchemaResult.newBuilder()
.setSchema(ByteString.copyFrom(baos.toByteArray()))
.build();
}
```
In the java, the server side just use the raw flatbuffer without the
continuation token @zeroshade @lidavidm
--
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]