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/15 12:19:32 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #13598: ARROW-17078: [C++] Cleaning up C++ Examples

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


##########
cpp/examples/arrow/dataset_documentation_example.cc:
##########
@@ -194,10 +191,10 @@ std::shared_ptr<arrow::Table> FilterAndSelectDataset(
   auto dataset = factory->Finish().ValueOrDie();
   // Read specified columns with a row filter
   auto scan_builder = dataset->NewScan().ValueOrDie();
-  ABORT_ON_FAILURE(scan_builder->Project({"b"}));
-  ABORT_ON_FAILURE(scan_builder->Filter(cp::less(cp::field_ref("b"), cp::literal(4))));
+  ARROW_RETURN_NOT_OK(scan_builder->Project({"b"}));
+  ARROW_RETURN_NOT_OK(scan_builder->Filter(cp::less(cp::field_ref("b"), cp::literal(4))));
   auto scanner = scan_builder->Finish().ValueOrDie();

Review Comment:
   Can we also eliminate all uses of ValueOrDie?



##########
cpp/examples/arrow/dataset_documentation_example.cc:
##########
@@ -194,10 +191,10 @@ std::shared_ptr<arrow::Table> FilterAndSelectDataset(
   auto dataset = factory->Finish().ValueOrDie();
   // Read specified columns with a row filter
   auto scan_builder = dataset->NewScan().ValueOrDie();
-  ABORT_ON_FAILURE(scan_builder->Project({"b"}));
-  ABORT_ON_FAILURE(scan_builder->Filter(cp::less(cp::field_ref("b"), cp::literal(4))));
+  ARROW_RETURN_NOT_OK(scan_builder->Project({"b"}));
+  ARROW_RETURN_NOT_OK(scan_builder->Filter(cp::less(cp::field_ref("b"), cp::literal(4))));
   auto scanner = scan_builder->Finish().ValueOrDie();

Review Comment:
   That applies to other files here too.



##########
cpp/examples/arrow/flight_grpc_example.cc:
##########
@@ -84,20 +75,12 @@ class HelloWorldServiceImpl : public HelloWorldService::Service {
   }
 };
 
-int main(int argc, char** argv) {
-  gflags::ParseCommandLineFlags(&argc, &argv, true);
-
-  if (FLAGS_port < 0) {
-    // For CI
-    std::cout << "Must specify a port with -port" << std::endl;
-    return EXIT_SUCCESS;
-  }
-
+arrow::Status RunFlightGRPC() {

Review Comment:
   ```suggestion
   arrow::Status RunFlightGrpc() {
   ```



##########
cpp/examples/arrow/dataset_documentation_example.cc:
##########
@@ -39,99 +39,96 @@ namespace ds = arrow::dataset;
 namespace fs = arrow::fs;
 namespace cp = arrow::compute;
 
-#define ABORT_ON_FAILURE(expr)                     \
-  do {                                             \
-    arrow::Status status_ = (expr);                \
-    if (!status_.ok()) {                           \
-      std::cerr << status_.message() << std::endl; \
-      abort();                                     \
-    }                                              \
-  } while (0);
+/**
+ * @brief Run Example

Review Comment:
   nit: use `\brief` for consistency with the C++ codebase



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