You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/05 12:09:58 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #13311: ARROW-16340: [Python] Move all Python related code into PyArrow

lidavidm commented on code in PR #13311:
URL: https://github.com/apache/arrow/pull/13311#discussion_r913722006


##########
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(schema_in);

Review Comment:
   nit
   ```suggestion
     return SchemaResult(std::move(schema_in));
   ```



##########
python/pyarrow/src_arrow/flight.cc:
##########
@@ -371,24 +370,21 @@ 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));
+  auto result =
+    arrow::flight::FlightInfo::Make(*schema,
+                                    descriptor,
+                                    endpoints,
+                                    total_records,
+                                    total_bytes);
+  *out = std::unique_ptr<arrow::flight::FlightInfo>(&(*result));

Review Comment:
   These should use ARROW_RETURN_NOT_OK
   
   ```suggestion
     ARROW_ASSIGN_OR_RAISE(auto result,
       arrow::flight::FlightInfo::Make(*schema,
                                       descriptor,
                                       endpoints,
                                       total_records,
                                       total_bytes));
     *out = std::unique_ptr<arrow::flight::FlightInfo>(std::move(result));
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org