Class: ArrowFormat::DecimalType

Inherits:
FixedSizeBinaryType show all
Defined in:
lib/arrow-format/type.rb

Direct Known Subclasses

Decimal128Type, Decimal256Type

Instance Attribute Summary collapse

Attributes inherited from FixedSizeBinaryType

#byte_width

Instance Method Summary collapse

Methods inherited from FixedSizeBinaryType

#build_array, #name

Constructor Details

#initialize(byte_width, precision, scale) ⇒ DecimalType

Returns a new instance of DecimalType.



761
762
763
764
765
# File 'lib/arrow-format/type.rb', line 761

def initialize(byte_width, precision, scale)
  super(byte_width)
  @precision = precision
  @scale = scale
end

Instance Attribute Details

#precisionObject (readonly)

Returns the value of attribute precision.



759
760
761
# File 'lib/arrow-format/type.rb', line 759

def precision
  @precision
end

#scaleObject (readonly)

Returns the value of attribute scale.



760
761
762
# File 'lib/arrow-format/type.rb', line 760

def scale
  @scale
end

Instance Method Details

#to_flatbuffersObject



771
772
773
774
775
776
777
# File 'lib/arrow-format/type.rb', line 771

def to_flatbuffers
  fb_type = FB::Decimal::Data.new
  fb_type.bit_width = @byte_width * 8
  fb_type.precision = @precision
  fb_type.scale = @scale
  fb_type
end

#to_sObject



767
768
769
# File 'lib/arrow-format/type.rb', line 767

def to_s
  "#{name}(#{@precision}, #{@scale})"
end