edponce commented on code in PR #13859:
URL: https://github.com/apache/arrow/pull/13859#discussion_r943940439


##########
cpp/examples/tutorial_examples/arrow_example.cc:
##########
@@ -0,0 +1,87 @@
+#include <arrow/api.h>
+
+#include <iostream>
+
+arrow::Status RunMain(int argc, char** argv) {
+
+  // Creating Arrays and Tables
+  arrow::Int8Builder int8builder; 
+  int8_t days_raw[5] = {1, 12, 17, 23, 28};
+  ARROW_RETURN_NOT_OK(int8builder.AppendValues(days_raw, 5));
+  std::shared_ptr<arrow::Array> days;
+  ARROW_ASSIGN_OR_RAISE(days, int8builder.Finish());
+
+  int8_t months_raw[5] = {1, 3, 5, 7, 1};
+  ARROW_RETURN_NOT_OK(int8builder.AppendValues(months_raw, 5));
+  std::shared_ptr<arrow::Array> months;
+  ARROW_ASSIGN_OR_RAISE(months, int8builder.Finish());
+
+  arrow::Int16Builder int16builder;
+  int16_t years_raw[5] = {1990, 2000, 1995, 2000, 1995};
+  ARROW_RETURN_NOT_OK(int16builder.AppendValues(years_raw, 5));
+  std::shared_ptr<arrow::Array> years;
+  ARROW_ASSIGN_OR_RAISE(years, int16builder.Finish());
+
+  std::shared_ptr<arrow::Field> field_day, field_month, field_year;
+  std::shared_ptr<arrow::Schema> schema;
+
+  field_day = arrow::field("Day", arrow::int8());
+  field_month = arrow::field("Month", arrow::int8());
+  field_year = arrow::field("Year", arrow::int16());
+
+  schema = arrow::schema({field_day, field_month, field_year});
+
+  std::shared_ptr<arrow::RecordBatch> rbatch;
+  rbatch = arrow::RecordBatch::Make(schema, days->length(), {days, months, 
years});
+
+  std::cout << rbatch->ToString();
+
+  int8_t days_raw2[5] = {6, 12, 3, 30, 22};
+  ARROW_RETURN_NOT_OK(int8builder.AppendValues(days_raw2, 5));
+  std::shared_ptr<arrow::Array> days2;
+  ARROW_ASSIGN_OR_RAISE(days2, int8builder.Finish());
+
+  int8_t months_raw2[5] = {5, 4, 11, 3, 2};
+  ARROW_RETURN_NOT_OK(int8builder.AppendValues(months_raw2, 5));
+  std::shared_ptr<arrow::Array> months2;
+  ARROW_ASSIGN_OR_RAISE(months2, int8builder.Finish());
+
+  int16_t years_raw2[5] = {1980, 2001, 1915, 2020, 1996};
+  ARROW_RETURN_NOT_OK(int16builder.AppendValues(years_raw2, 5));
+  std::shared_ptr<arrow::Array> years2;
+  ARROW_ASSIGN_OR_RAISE(years2, int16builder.Finish());
+
+  arrow::ArrayVector day_vecs(2);
+  day_vecs[0] = days;
+  day_vecs[1] = days2;

Review Comment:
   Simplify to 
   ```c++
   arrow::ArrayVector day_vecs{days, days2};
   ```
   and similarly in all other places where a `std::vector<T>` is initialized at 
instantiation.



##########
cpp/examples/tutorial_examples/arrow_example.cc:
##########
@@ -0,0 +1,87 @@
+#include <arrow/api.h>
+
+#include <iostream>
+
+arrow::Status RunMain(int argc, char** argv) {

Review Comment:
   Instead of naming all functions as `RunMain`, I recommend to use a 
representative name as if it was part of "real" code. Also, maybe some of the 
`RunMain` could be split into multiple functions, like a: `MakeArrays()`, 
`MakeTableFromChunks()`. But not sure how the return value would look like for 
a collection of items. Arrow has `Result` which can be a value or a `Status`, 
but I do not think it handles sequences.



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