Sha256: 3f17368ac131e093c2e4aa6d57b1b3a8e1d3aa45564463dd10ccc5ea0df60d65

Contents?: true

Size: 1.67 KB

Versions: 8

Compression:

Stored size: 1.67 KB

Contents

# Copyright 2017 Kouhei Sutou <kou@clear-code.com>
#
# Licensed 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 RecordBatchTest < Test::Unit::TestCase
  sub_test_case(".each") do
    setup do
      fields = [
        Arrow::Field.new("count", :uint32),
      ]
      @schema = Arrow::Schema.new(fields)
      @counts = Arrow::UInt32Array.new([1, 2, 4, 8])
      @record_batch = Arrow::RecordBatch.new(@schema, @counts.length, [@counts])
    end

    test("default") do
      records = []
      @record_batch.each do |record|
        records << [record, record.index]
      end
      assert_equal([
                     [0, 0],
                     [1, 1],
                     [2, 2],
                     [3, 3],
                   ],
                   records.collect {|record, i| [record.index, i]})
    end

    test("reuse_record: true") do
      records = []
      @record_batch.each(reuse_record: true) do |record|
        records << [record, record.index]
      end
      assert_equal([
                     [3, 0],
                     [3, 1],
                     [3, 2],
                     [3, 3],
                   ],
                   records.collect {|record, i| [record.index, i]})
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
red-arrow-0.8.2 test/test-record-batch.rb
red-arrow-0.8.1 test/test-record-batch.rb
red-arrow-0.8.0 test/test-record-batch.rb
red-arrow-0.4.1 test/test-record-batch.rb
red-arrow-0.4.0 test/test-record-batch.rb
red-arrow-0.3.1 test/test-record-batch.rb
red-arrow-0.3.0 test/test-record-batch.rb
red-arrow-0.2.2 test/test-record-batch.rb