You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2022/07/08 13:21:57 UTC
[arrow] branch master updated: ARROW-17011: [C++][Flight] Remove the need for serialization_internal.h inside python/flight.cc (#13546)
This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new c54cc9c547 ARROW-17011: [C++][Flight] Remove the need for serialization_internal.h inside python/flight.cc (#13546)
c54cc9c547 is described below
commit c54cc9c5476de39f12a367d315c272e944a2233e
Author: Alenka Frim <Al...@users.noreply.github.com>
AuthorDate: Fri Jul 8 15:21:49 2022 +0200
ARROW-17011: [C++][Flight] Remove the need for serialization_internal.h inside python/flight.cc (#13546)
The changes made to flight and python flight in https://github.com/apache/arrow/pull/13311 are moved into this separate PR. The reason for separation is for the changes to be merged before the next release and also to make https://github.com/apache/arrow/pull/13311 less complex.
The changes are same as in the PR mentioned. I hope that the changes in `cpp/src/arrow/python/flight.cc` can serve as a test.
cc @lidavidm @jorisvandenbossche
Authored-by: Alenka Frim <fr...@gmail.com>
Signed-off-by: David Li <li...@gmail.com>
---
cpp/src/arrow/flight/types.cc | 6 ++++++
cpp/src/arrow/flight/types.h | 3 +++
cpp/src/arrow/python/flight.cc | 20 +++++++-------------
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/cpp/src/arrow/flight/types.cc b/cpp/src/arrow/flight/types.cc
index efc96bb775..ddb8a036fb 100644
--- a/cpp/src/arrow/flight/types.cc
+++ b/cpp/src/arrow/flight/types.cc
@@ -150,6 +150,12 @@ arrow::Result<std::shared_ptr<Schema>> SchemaResult::GetSchema(
return ipc::ReadSchema(&schema_reader, dictionary_memo);
}
+arrow::Result<SchemaResult> SchemaResult::Make(const Schema& schema) {
+ std::string schema_in;
+ RETURN_NOT_OK(internal::SchemaToString(schema, &schema_in));
+ return SchemaResult(std::move(schema_in));
+}
+
Status SchemaResult::GetSchema(ipc::DictionaryMemo* dictionary_memo,
std::shared_ptr<Schema>* out) const {
return GetSchema(dictionary_memo).Value(out);
diff --git a/cpp/src/arrow/flight/types.h b/cpp/src/arrow/flight/types.h
index 8a77b8fc0c..a061f33afe 100644
--- a/cpp/src/arrow/flight/types.h
+++ b/cpp/src/arrow/flight/types.h
@@ -396,6 +396,9 @@ struct ARROW_FLIGHT_EXPORT SchemaResult {
public:
explicit SchemaResult(std::string schema) : raw_schema_(std::move(schema)) {}
+ /// \brief Factory method to construct a SchemaResult.
+ static arrow::Result<SchemaResult> Make(const Schema& schema);
+
/// \brief return schema
/// \param[in,out] dictionary_memo for dictionary bookkeeping, will
/// be modified
diff --git a/cpp/src/arrow/python/flight.cc b/cpp/src/arrow/python/flight.cc
index 51155e5383..9077bbe4ac 100644
--- a/cpp/src/arrow/python/flight.cc
+++ b/cpp/src/arrow/python/flight.cc
@@ -18,7 +18,6 @@
#include <signal.h>
#include <utility>
-#include "arrow/flight/serialization_internal.h"
#include "arrow/python/flight.h"
#include "arrow/util/io_util.h"
#include "arrow/util/logging.h"
@@ -371,24 +370,19 @@ Status CreateFlightInfo(const std::shared_ptr<arrow::Schema>& schema,
const std::vector<arrow::flight::FlightEndpoint>& endpoints,
int64_t total_records, int64_t total_bytes,
std::unique_ptr<arrow::flight::FlightInfo>* out) {
- arrow::flight::FlightInfo::Data flight_data;
- RETURN_NOT_OK(arrow::flight::internal::SchemaToString(*schema, &flight_data.schema));
- flight_data.descriptor = descriptor;
- flight_data.endpoints = endpoints;
- flight_data.total_records = total_records;
- flight_data.total_bytes = total_bytes;
- arrow::flight::FlightInfo value(flight_data);
- *out = std::unique_ptr<arrow::flight::FlightInfo>(new arrow::flight::FlightInfo(value));
+ ARROW_ASSIGN_OR_RAISE(auto result,
+ arrow::flight::FlightInfo::Make(*schema, descriptor, endpoints,
+ total_records, total_bytes));
+ *out = std::unique_ptr<arrow::flight::FlightInfo>(
+ new arrow::flight::FlightInfo(std::move(result)));
return Status::OK();
}
Status CreateSchemaResult(const std::shared_ptr<arrow::Schema>& schema,
std::unique_ptr<arrow::flight::SchemaResult>* out) {
- std::string schema_in;
- RETURN_NOT_OK(arrow::flight::internal::SchemaToString(*schema, &schema_in));
- arrow::flight::SchemaResult value(schema_in);
+ ARROW_ASSIGN_OR_RAISE(auto result, arrow::flight::SchemaResult::Make(*schema));
*out = std::unique_ptr<arrow::flight::SchemaResult>(
- new arrow::flight::SchemaResult(value));
+ new arrow::flight::SchemaResult(std::move(result)));
return Status::OK();
}