otegami commented on code in PR #37137:
URL: https://github.com/apache/arrow/pull/37137#discussion_r1299163383


##########
ruby/red-arrow/ext/arrow/raw-records.cpp:
##########
@@ -144,6 +144,122 @@ namespace red_arrow {
       // The number of columns.
       const int n_columns_;
     };
+
+    class RawRecordsProducer : private Converter, public arrow::ArrayVisitor {
+    public:
+      explicit RawRecordsProducer(int n_columns)
+        : Converter(),
+          record_(Qnil),
+          n_columns_(n_columns) {
+      }
+
+      void produce(const arrow::RecordBatch& record_batch) {
+        rb::protect([&] {
+          const auto n_rows = record_batch.num_rows();
+          for (int64_t i = 0; i < n_rows; ++i) {
+            record_ = rb_ary_new_capa(n_columns_);
+            row_offset_ = i;
+
+            for (int i = 0; i < n_columns_; ++i) {
+              const auto array = record_batch.column(i).get();
+              column_index_ = i;
+
+              check_status(array->Accept(this),
+                           "[record-batch][each-raw-record]");
+            }
+            rb_yield(record_);
+          }
+          return Qnil;
+        });
+      }
+
+      void produce(const arrow::Table& table) {
+        rb::protect([&] {
+          const auto n_rows = table.num_rows();
+          for (int64_t i = 0; i < n_rows; ++i) {
+            row_offset_ = i;
+            record_ = rb_ary_new_capa(n_columns_);
+
+            for (int i = 0; i < n_columns_; ++i) {
+              const auto& chunked_array = table.column(i).get();
+              column_index_ = i;
+
+              for (const auto array : chunked_array->chunks()) {

Review Comment:
   fix: 
[34b53e0](https://github.com/apache/arrow/pull/37137/commits/34b53e0a3ed95788cdcc617b010093636a3ad8c3)
   I changed the logic of `void produce(const arrow::Table& table)`. So could 
you recheck this point again?🙏



##########
ruby/red-arrow/ext/arrow/raw-records.cpp:
##########
@@ -144,6 +144,122 @@ namespace red_arrow {
       // The number of columns.
       const int n_columns_;
     };
+
+    class RawRecordsProducer : private Converter, public arrow::ArrayVisitor {
+    public:
+      explicit RawRecordsProducer(int n_columns)
+        : Converter(),
+          record_(Qnil),
+          n_columns_(n_columns) {
+      }
+
+      void produce(const arrow::RecordBatch& record_batch) {
+        rb::protect([&] {
+          const auto n_rows = record_batch.num_rows();
+          for (int64_t i = 0; i < n_rows; ++i) {
+            record_ = rb_ary_new_capa(n_columns_);
+            row_offset_ = i;
+
+            for (int i = 0; i < n_columns_; ++i) {
+              const auto array = record_batch.column(i).get();
+              column_index_ = i;
+
+              check_status(array->Accept(this),
+                           "[record-batch][each-raw-record]");
+            }
+            rb_yield(record_);
+          }
+          return Qnil;
+        });
+      }
+
+      void produce(const arrow::Table& table) {
+        rb::protect([&] {
+          const auto n_rows = table.num_rows();
+          for (int64_t i = 0; i < n_rows; ++i) {
+            row_offset_ = i;
+            record_ = rb_ary_new_capa(n_columns_);
+
+            for (int i = 0; i < n_columns_; ++i) {
+              const auto& chunked_array = table.column(i).get();
+              column_index_ = i;
+
+              for (const auto array : chunked_array->chunks()) {

Review Comment:
   fix: 
[34b53e0](https://github.com/apache/arrow/pull/37137/commits/34b53e0a3ed95788cdcc617b010093636a3ad8c3)
   I changed the logic of `void produce(const arrow::Table& table)`. So could 
you recheck this point again?🙏



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