kou commented on code in PR #37600:
URL: https://github.com/apache/arrow/pull/37600#discussion_r1318031489


##########
ruby/red-arrow/ext/arrow/raw-records.cpp:
##########
@@ -306,6 +306,10 @@ namespace red_arrow {
 
   VALUE
   record_batch_each_raw_record(VALUE rb_record_batch){

Review Comment:
   ```suggestion
     record_batch_each_raw_record(VALUE rb_record_batch) {
   ```



##########
ruby/red-arrow/test/test-record-batch.rb:
##########
@@ -178,5 +178,29 @@ def setup
                      @record_batch[[:c, "a", -1, 3..4]])
       end
     end
+
+    sub_test_case("#each_raw_record") do

Review Comment:
   We can always use no block version like this:
   
   ```diff
   diff --git a/ruby/red-arrow/test/each-raw-record/test-basic-arrays.rb 
b/ruby/red-arrow/test/each-raw-record/test-basic-arrays.rb
   index dbbbd79ee..05f0e90ef 100644
   --- a/ruby/red-arrow/test/each-raw-record/test-basic-arrays.rb
   +++ b/ruby/red-arrow/test/each-raw-record/test-basic-arrays.rb
   @@ -22,12 +22,8 @@ module EachRawRecordBasicArraysTests
          [nil],
          [nil],
        ]
   -    iterated_records = []
        target = build({column: :null}, records)
   -    target.each_raw_record do |record|
   -      iterated_records << record
   -    end
   -    assert_equal(records, iterated_records)
   +    assert_equal(records, target.each_raw_record.to_a)
      end
    
      def test_boolean
   ```
   
   Because a returned `Enumerator` uses with-block version.



##########
ruby/red-arrow/ext/arrow/raw-records.cpp:
##########
@@ -306,6 +306,10 @@ namespace red_arrow {
 
   VALUE
   record_batch_each_raw_record(VALUE rb_record_batch){
+    if (!rb_block_given_p()) {
+      return rb_funcall(rb_record_batch, rb_intern("to_enum"), 1, 
ID2SYM(rb_intern("each_raw_record")));

Review Comment:
   We can use `RETURN_SIZED_ENUMERATOR()`:
   
   
https://github.com/ruby/ruby/blob/05aaff2191cbe777d1efb915ab9652eeaa1c16b8/include/ruby/internal/intern/enumerator.h#L206-L209



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