This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new edf2429 ARROW-9307: [Ruby] Add Arrow::RecordBatchIterator#to_a
edf2429 is described below
commit edf24290046d95967d620104c5238f30ff032b6d
Author: Sutou Kouhei <[email protected]>
AuthorDate: Sat Jul 4 06:18:09 2020 +0900
ARROW-9307: [Ruby] Add Arrow::RecordBatchIterator#to_a
Closes #7627 from kou/ruby-record-batch-iterator-to-a
Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
ruby/red-arrow/lib/arrow/loader.rb | 1 +
ruby/red-arrow/lib/arrow/record-batch-iterator.rb | 22 ++++++++++++++
ruby/red-arrow/test/test-record-batch-iterator.rb | 37 +++++++++++++++++++++++
3 files changed, 60 insertions(+)
diff --git a/ruby/red-arrow/lib/arrow/loader.rb
b/ruby/red-arrow/lib/arrow/loader.rb
index 13a3808..c8724cf 100644
--- a/ruby/red-arrow/lib/arrow/loader.rb
+++ b/ruby/red-arrow/lib/arrow/loader.rb
@@ -70,6 +70,7 @@ module Arrow
require "arrow/record-batch"
require "arrow/record-batch-builder"
require "arrow/record-batch-file-reader"
+ require "arrow/record-batch-iterator"
require "arrow/record-batch-stream-reader"
require "arrow/rolling-window"
require "arrow/schema"
diff --git a/ruby/red-arrow/lib/arrow/record-batch-iterator.rb
b/ruby/red-arrow/lib/arrow/record-batch-iterator.rb
new file mode 100644
index 0000000..4b828c6d
--- /dev/null
+++ b/ruby/red-arrow/lib/arrow/record-batch-iterator.rb
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+module Arrow
+ class RecordBatchIterator
+ alias_method :to_a, :to_list
+ end
+end
diff --git a/ruby/red-arrow/test/test-record-batch-iterator.rb
b/ruby/red-arrow/test/test-record-batch-iterator.rb
new file mode 100644
index 0000000..88f3eca
--- /dev/null
+++ b/ruby/red-arrow/test/test-record-batch-iterator.rb
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class RecordBatchIteratorTest < Test::Unit::TestCase
+ def setup
+ @schema = Arrow::Schema.new(visible: :boolean,
+ count: :uint32)
+ @record_batches = [
+ Arrow::RecordBatch.new(@schema,
+ visible: [true],
+ count: [1]),
+ Arrow::RecordBatch.new(@schema,
+ visible: [false, nil],
+ count: [nil, 3]),
+ ]
+ @iterator = Arrow::RecordBatchIterator.new(@record_batches)
+ end
+
+ def test_to_a
+ assert_equal(@record_batches,
+ @iterator.to_a)
+ end
+end