Skip to content
Draft
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
14 changes: 14 additions & 0 deletions ruby/red-arrow-format/lib/arrow-format/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ def to_a
end
end

class DecimalArray < FixedSizeBinaryArray
def to_a
byte_width = @type.byte_width
values = 0.step(@size * byte_width - 1, byte_width).collect do |offset|
# TODO: How to represent in Ruby?
@values_buffer.get_string(offset, byte_width)
Comment on lines +313 to +314
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make this PR ready when I solve this TODO.

end
apply_validity(values)
end
end

class Decimal128Array < DecimalArray
end

class VariableSizeListArray < Array
def initialize(type, size, validity_buffer, offsets_buffer, child)
super(type, size, validity_buffer)
Expand Down
6 changes: 6 additions & 0 deletions ruby/red-arrow-format/lib/arrow-format/readable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
require_relative "org/apache/arrow/flatbuf/bool"
require_relative "org/apache/arrow/flatbuf/date"
require_relative "org/apache/arrow/flatbuf/date_unit"
require_relative "org/apache/arrow/flatbuf/decimal"
require_relative "org/apache/arrow/flatbuf/duration"
require_relative "org/apache/arrow/flatbuf/fixed_size_binary"
require_relative "org/apache/arrow/flatbuf/floating_point"
Expand Down Expand Up @@ -166,6 +167,11 @@ def read_field(fb_field)
type = LargeUTF8Type.singleton
when Org::Apache::Arrow::Flatbuf::FixedSizeBinary
type = FixedSizeBinaryType.new(fb_type.byte_width)
when Org::Apache::Arrow::Flatbuf::Decimal
case fb_type.bit_width
when 128
type = Decimal128Type.new(fb_type.precision, fb_type.scale)
end
end
Field.new(fb_field.name, type, fb_field.nullable?)
end
Expand Down
Loading
Loading