MCPcopy Create free account
hub / github.com/apache/arrow / RecordBatchTest

Class RecordBatchTest

ruby/red-arrow/test/test-record-batch.rb:18–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16# under the License.
17
18class RecordBatchTest < Test::Unit::TestCase
19 sub_test_case(".new") do
20 def setup
21 @schema = Arrow::Schema.new(visible: :boolean,
22 count: :uint32)
23 end
24
25 test("[raw_table]") do
26 raw_table = {
27 visible: [true, nil, false],
28 count: [1, nil, 3],
29 }
30 record_batch = Arrow::RecordBatch.new(raw_table)
31 assert_equal([
32 {"visible" => true, "count" => 1},
33 {"visible" => nil, "count" => nil},
34 {"visible" => false, "count" => 3},
35 ],
36 record_batch.each_record.collect(&:to_h))
37 end
38
39 test("[Schema, records]") do
40 records = [
41 {visible: true, count: 1},
42 nil,
43 [false, 3],
44 ]
45 record_batch = Arrow::RecordBatch.new(@schema, records)
46 assert_equal([
47 {"visible" => true, "count" => 1},
48 {"visible" => nil, "count" => nil},
49 {"visible" => false, "count" => 3},
50 ],
51 record_batch.each_record.collect(&:to_h))
52 end
53
54 test("[Schema, columns]") do
55 columns = {
56 visible: [true, nil, false],
57 count: [1, 2, nil],
58 }
59 record_batch = Arrow::RecordBatch.new(@schema, columns)
60 assert_equal([
61 {"visible" => true, "count" => 1},
62 {"visible" => nil, "count" => 2},
63 {"visible" => false, "count" => nil},
64 ],
65 record_batch.each_record.collect(&:to_h))
66 end
67
68 test("[Schema, n_rows, columns]") do
69 columns = [
70 Arrow::BooleanArray.new([true, nil, false]),
71 Arrow::UInt32Array.new([1, 2, nil]),
72 ]
73 n_rows = columns[0].length
74 record_batch = Arrow::RecordBatch.new(@schema, n_rows, columns)
75 assert_equal([

Callers

nothing calls this directly

Calls 9

testFunction · 0.85
each_recordMethod · 0.80
newMethod · 0.45
lengthMethod · 0.45
eachMethod · 0.45
indexMethod · 0.45
to_tableMethod · 0.45
sizeMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected