Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ruby/red-arrow-format/lib/arrow-format/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ def buffer_type
:s32
end

def pack_template
"l"
end

def build_array(...)
Date32Array.new(...)
end
Expand All @@ -441,6 +445,10 @@ def buffer_type
:s64
end

def pack_template
"q"
end

def build_array(...)
Date64Array.new(...)
end
Expand Down
60 changes: 60 additions & 0 deletions ruby/red-arrow-format/test/test-date32-array.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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 TestDate32Array < Test::Unit::TestCase
def setup
@date_2017_08_28 = 17406
@date_2025_12_09 = 20431
end

sub_test_case("#initialize") do
def test_no_null
values = [@date_2017_08_28, @date_2025_12_09]
assert_equal(values,
ArrowFormat::Date32Array.new(values).to_a)
end

def test_mixed
values = [@date_2017_08_28, nil, @date_2025_12_09]
assert_equal(values,
ArrowFormat::Date32Array.new(values).to_a)
end
end

sub_test_case("#==") do
def test_no_slice
values = [@date_2017_08_28, nil, @date_2025_12_09]
array1 = ArrowFormat::Date32Array.new(values)
array2 = ArrowFormat::Date32Array.new(values)
assert_equal(array1, array2)
end

def test_sliced
values = [@date_2017_08_28, nil, @date_2025_12_09]
array1 = ArrowFormat::Date32Array.new(values)
array2 = ArrowFormat::Date32Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [@date_2017_08_28, nil, @date_2025_12_09]
array1 = ArrowFormat::Date32Array.new(values)
array2 = ArrowFormat::Date32Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
end
60 changes: 60 additions & 0 deletions ruby/red-arrow-format/test/test-date64-array.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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 TestDate64Array < Test::Unit::TestCase
def setup
@date_2017_08_28_00_00_00 = 1503878400000
@date_2025_12_10_00_00_00 = 1765324800000
end

sub_test_case("#initialize") do
def test_no_null
values = [@date_2017_08_28_00_00_00, @date_2025_12_10_00_00_00]
assert_equal(values,
ArrowFormat::Date64Array.new(values).to_a)
end

def test_mixed
values = [@date_2017_08_28_00_00_00, nil, @date_2025_12_10_00_00_00]
assert_equal(values,
ArrowFormat::Date64Array.new(values).to_a)
end
end

sub_test_case("#==") do
def test_no_slice
values = [@date_2017_08_28_00_00_00, nil, @date_2025_12_10_00_00_00]
array1 = ArrowFormat::Date64Array.new(values)
array2 = ArrowFormat::Date64Array.new(values)
assert_equal(array1, array2)
end

def test_sliced
values = [@date_2017_08_28_00_00_00, nil, @date_2025_12_10_00_00_00]
array1 = ArrowFormat::Date64Array.new(values)
array2 = ArrowFormat::Date64Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [@date_2017_08_28_00_00_00, nil, @date_2025_12_10_00_00_00]
array1 = ArrowFormat::Date64Array.new(values)
array2 = ArrowFormat::Date64Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
end
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-float32-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-Float::INFINITY, -0.0, nil, +0.0, +Float::INFINITY]
array1 = ArrowFormat::Float32Array.new(values)
array2 = ArrowFormat::Float32Array.new([0.0] + values + [0.0])
array2 = ArrowFormat::Float32Array.new([0.0, *values, 0.0])
assert_equal(array1, array2.slice(1, 5))
end

def test_sliced_different_content
values = [-Float::INFINITY, -0.0, nil, +0.0, +Float::INFINITY]
array1 = ArrowFormat::Float32Array.new(values)
array2 = ArrowFormat::Float32Array.new([0.0, 0.0] + values + [0.0])
array2 = ArrowFormat::Float32Array.new([0.0, 0.0, *values, 0.0])
assert_not_equal(array1, array2.slice(1, 5))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-float64-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-Float::INFINITY, -0.0, nil, +0.0, +Float::INFINITY]
array1 = ArrowFormat::Float64Array.new(values)
array2 = ArrowFormat::Float64Array.new([0.0] + values + [0.0])
array2 = ArrowFormat::Float64Array.new([0.0, *values, 0.0])
assert_equal(array1, array2.slice(1, 5))
end

def test_sliced_different_content
values = [-Float::INFINITY, -0.0, nil, +0.0, +Float::INFINITY]
array1 = ArrowFormat::Float64Array.new(values)
array2 = ArrowFormat::Float64Array.new([0.0, 0.0] + values + [0.0])
array2 = ArrowFormat::Float64Array.new([0.0, 0.0, *values, 0.0])
assert_not_equal(array1, array2.slice(1, 5))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-int16-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-(2 ** 15), nil, (2 ** 15) - 1]
array1 = ArrowFormat::Int16Array.new(values)
array2 = ArrowFormat::Int16Array.new([0] + values + [0])
array2 = ArrowFormat::Int16Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [-(2 ** 15), nil, (2 ** 15) - 1]
array1 = ArrowFormat::Int16Array.new(values)
array2 = ArrowFormat::Int16Array.new([0, 0] + values + [0])
array2 = ArrowFormat::Int16Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-int32-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-(2 ** 31), nil, (2 ** 31) - 1]
array1 = ArrowFormat::Int32Array.new(values)
array2 = ArrowFormat::Int32Array.new([0] + values + [0])
array2 = ArrowFormat::Int32Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [-(2 ** 31), nil, (2 ** 31) - 1]
array1 = ArrowFormat::Int32Array.new(values)
array2 = ArrowFormat::Int32Array.new([0, 0] + values + [0])
array2 = ArrowFormat::Int32Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-int64-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-(2 ** 63), nil, (2 ** 63) - 1]
array1 = ArrowFormat::Int64Array.new(values)
array2 = ArrowFormat::Int64Array.new([0] + values + [0])
array2 = ArrowFormat::Int64Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [-(2 ** 63), nil, (2 ** 63) - 1]
array1 = ArrowFormat::Int64Array.new(values)
array2 = ArrowFormat::Int64Array.new([0, 0] + values + [0])
array2 = ArrowFormat::Int64Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-int8-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [-(2 ** 7), nil, (2 ** 7) - 1]
array1 = ArrowFormat::Int8Array.new(values)
array2 = ArrowFormat::Int8Array.new([0] + values + [0])
array2 = ArrowFormat::Int8Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [-(2 ** 7), nil, (2 ** 7) - 1]
array1 = ArrowFormat::Int8Array.new(values)
array2 = ArrowFormat::Int8Array.new([0, 0] + values + [0])
array2 = ArrowFormat::Int8Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-uint16-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [0, nil, (2 ** 16) - 1]
array1 = ArrowFormat::UInt16Array.new(values)
array2 = ArrowFormat::UInt16Array.new([0] + values + [0])
array2 = ArrowFormat::UInt16Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [0, nil, (2 ** 16) - 1]
array1 = ArrowFormat::UInt16Array.new(values)
array2 = ArrowFormat::UInt16Array.new([0, 0] + values + [0])
array2 = ArrowFormat::UInt16Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-uint32-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [0, nil, (2 ** 32) - 1]
array1 = ArrowFormat::UInt32Array.new(values)
array2 = ArrowFormat::UInt32Array.new([0] + values + [0])
array2 = ArrowFormat::UInt32Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [0, nil, (2 ** 32) - 1]
array1 = ArrowFormat::UInt32Array.new(values)
array2 = ArrowFormat::UInt32Array.new([0, 0] + values + [0])
array2 = ArrowFormat::UInt32Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-uint64-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [0, nil, (2 ** 64) - 1]
array1 = ArrowFormat::UInt64Array.new(values)
array2 = ArrowFormat::UInt64Array.new([0] + values + [0])
array2 = ArrowFormat::UInt64Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [0, nil, (2 ** 64) - 1]
array1 = ArrowFormat::UInt64Array.new(values)
array2 = ArrowFormat::UInt64Array.new([0, 0] + values + [0])
array2 = ArrowFormat::UInt64Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
4 changes: 2 additions & 2 deletions ruby/red-arrow-format/test/test-uint8-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_no_slice
def test_sliced
values = [0, nil, (2 ** 8) - 1]
array1 = ArrowFormat::UInt8Array.new(values)
array2 = ArrowFormat::UInt8Array.new([0] + values + [0])
array2 = ArrowFormat::UInt8Array.new([0, *values, 0])
assert_equal(array1, array2.slice(1, 3))
end

def test_sliced_different_content
values = [0, nil, (2 ** 8) - 1]
array1 = ArrowFormat::UInt8Array.new(values)
array2 = ArrowFormat::UInt8Array.new([0, 0] + values + [0])
array2 = ArrowFormat::UInt8Array.new([0, 0, *values, 0])
assert_not_equal(array1, array2.slice(1, 3))
end
end
Expand Down
Loading