quanghgx commented on code in PR #13986:
URL: https://github.com/apache/arrow/pull/13986#discussion_r962142251


##########
cpp/src/arrow/flight/types.cc:
##########
@@ -162,6 +162,33 @@ Status SchemaResult::GetSchema(ipc::DictionaryMemo* 
dictionary_memo,
   return GetSchema(dictionary_memo).Value(out);
 }
 
+arrow::Result<std::string> SchemaResult::SerializeToString() const {
+  pb::SchemaResult pb_schema_result;
+  RETURN_NOT_OK(internal::ToProto(*this, &pb_schema_result));
+
+  std::string out;
+  if (!pb_schema_result.SerializeToString(&out)) {
+    return Status::IOError("Serialized schema-result exceeded 2 GiB limit");
+  }
+  return out;
+}
+
+arrow::Result<SchemaResult> SchemaResult::Deserialize(
+    arrow::util::string_view serialized) {
+  pb::SchemaResult pb_schema_result;
+  if (serialized.size() > 
static_cast<size_t>(std::numeric_limits<int>::max())) {
+    return Status::Invalid("Serialized SchemaResult size should not exceed 2 
GiB");
+  }
+  google::protobuf::io::ArrayInputStream input(serialized.data(),
+                                               
static_cast<int>(serialized.size()));
+  if (!pb_schema_result.ParseFromZeroCopyStream(&input)) {
+    return Status::Invalid("Not a valid schema-result");
+  }
+  SchemaResult out;
+  RETURN_NOT_OK(internal::FromProto(pb_schema_result, &out));

Review Comment:
   thanks. I've just fixed this issue.



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