heronshoes commented on code in PR #34441:
URL: https://github.com/apache/arrow/pull/34441#discussion_r1125135206


##########
ruby/red-arrow/lib/arrow/record-batch-file-reader.rb:
##########
@@ -20,6 +20,8 @@ class RecordBatchFileReader
     include Enumerable
 
     def each
+      return to_enum(__method__) unless block_given?

Review Comment:
   How about to supply the size of Enumerator?
   
   ```suggestion
         return to_enum(__method__) { n_record_batches } unless block_given?
   ```



##########
ruby/red-arrow/test/test-record-batch-file-reader.rb:
##########
@@ -112,4 +112,18 @@ class RecordBatchFileReaderTest < Test::Unit::TestCase
       end
     end
   end
+
+  sub_test_case("#each") do
+    test("without block") do
+      buffer = Arrow::ResizableBuffer.new(1024)
+      Arrow::Table.new(number: [1, 2, 3]).save(buffer)
+      Arrow::BufferInputStream.open(buffer) do |input|
+        reader = Arrow::RecordBatchFileReader.new(input)
+        assert_equal([
+                       Arrow::RecordBatch.new(number: [1, 2, 3]),
+                     ],
+                     reader.each.to_a)
+      end
+    end

Review Comment:
   ```suggestion
       test("without block") do
         buffer = Arrow::ResizableBuffer.new(1024)
         Arrow::Table.new(number: [1, 2, 3]).save(buffer)
         Arrow::BufferInputStream.open(buffer) do |input|
           reader = Arrow::RecordBatchFileReader.new(input)
           assert_equal([
                          Arrow::RecordBatch.new(number: [1, 2, 3]),
                        ],
                        reader.each.to_a)
         end
       end
   
       test("without block, test size") do
         buffer = Arrow::ResizableBuffer.new(1024)
         Arrow::Table.new(number: [1, 2, 3]).save(buffer)
         Arrow::BufferInputStream.open(buffer) do |input|
           reader = Arrow::RecordBatchFileReader.new(input)
           assert_equal 1, reader.each.size
         end
       end
   ```
   
   Added test "without block, test size".



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