Class: ArrowFormat::Org::Apache::Arrow::Flatbuf::Decimal

Inherits:
FlatBuffers::Table
  • Object
show all
Defined in:
lib/arrow-format/org/apache/arrow/flatbuf/decimal.rb

Overview

Exact decimal value represented as an integer value in two’s complement. Currently 32-bit (4-byte), 64-bit (8-byte), 128-bit (16-byte) and 256-bit (32-byte) integers are used. The representation uses the endianness indicated in the Schema.

Constant Summary collapse

FIELDS =
{
  precision: ::FlatBuffers::Field.new(:precision, 0, 4, :int, 0),
  scale: ::FlatBuffers::Field.new(:scale, 1, 6, :int, 0),
  bit_width: ::FlatBuffers::Field.new(:bit_width, 2, 8, :int, 0),
}
Data =
define_data_class

Instance Method Summary collapse

Instance Method Details

#bit_widthObject

Number of bits per value. The accepted widths are 32, 64, 128 and 256. We use bitWidth for consistency with Int::bitWidth.



29
30
31
32
33
34
# File 'lib/arrow-format/org/apache/arrow/flatbuf/decimal.rb', line 29

def bit_width
  field_offset = @view.unpack_virtual_offset(8)
  return 128 if field_offset.zero?

  @view.unpack_int(field_offset)
end

#precisionObject

Total number of decimal digits



37
38
39
40
41
42
# File 'lib/arrow-format/org/apache/arrow/flatbuf/decimal.rb', line 37

def precision
  field_offset = @view.unpack_virtual_offset(4)
  return 0 if field_offset.zero?

  @view.unpack_int(field_offset)
end

#scaleObject

Number of digits after the decimal point “.”



45
46
47
48
49
50
# File 'lib/arrow-format/org/apache/arrow/flatbuf/decimal.rb', line 45

def scale
  field_offset = @view.unpack_virtual_offset(6)
  return 0 if field_offset.zero?

  @view.unpack_int(field_offset)
end