hiroyuki-sato commented on code in PR #48704:
URL: https://github.com/apache/arrow/pull/48704#discussion_r2657782571
##########
ruby/red-arrow-format/lib/arrow-format/array.rb:
##########
@@ -309,40 +309,57 @@ def to_a
end
class DecimalArray < FixedSizeBinaryArray
- end
-
- class Decimal128Array < DecimalArray
def to_a
byte_width = @type.byte_width
- buffer_types = [:u64, :s64] # TODO: big endian support
+ buffer_types = [:u64] * (byte_width / 8 - 1) + [:s64]
values = 0.step(@size * byte_width - 1, byte_width).collect do |offset|
@values_buffer.get_values(buffer_types, offset)
end
apply_validity(values).collect do |value|
if value.nil?
nil
else
- low, high = value
- BigDecimal(format_value(low, high))
+ BigDecimal(format_value(value))
end
end
end
private
- def format_value(low, high)
+ def format_value(components)
+ highest = components.last
width = @type.precision
- width += 1 if high < 0
- value = (high << 64) + low
- string = value.to_s.ljust(width, "0")
+ width += 1 if highest < 0
+ value = 0
+ components.reverse_each do |component|
+ value = (value << 64) + component
+ end
+ string = value.to_s
if @type.scale < 0
string << ("0" * [email protected])
Review Comment:
Thank you for your comment. It was misunderstanding.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]