Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cpp/src/arrow/flight/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/arrow/flight/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 7 additions & 13 deletions cpp/src/arrow/python/flight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down