Class: Parqueteur::Types::Decimal256Type

Inherits:
Parqueteur::Type show all
Defined in:
lib/parqueteur/types/decimal256_type.rb

Instance Attribute Summary

Attributes inherited from Parqueteur::Type

#arrow_type, #options

Instance Method Summary collapse

Methods inherited from Parqueteur::Type

#resolve

Constructor Details

#initialize(options = {}, &block) ⇒ Decimal256Type

Returns a new instance of Decimal256Type.



6
7
8
9
10
11
# File 'lib/parqueteur/types/decimal256_type.rb', line 6

def initialize(options = {}, &block)
  @scale = options.fetch(:scale)
  @precision = options.fetch(:precision)
  @format_str = "%.#{@scale}f"
  super(options, &block)
end

Instance Method Details

#arrow_type_builderObject



22
23
24
25
26
# File 'lib/parqueteur/types/decimal256_type.rb', line 22

def arrow_type_builder
  Arrow::Decimal256DataType.new(
    @precision, @scale
  )
end

#build_value_array(values) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/parqueteur/types/decimal256_type.rb', line 13

def build_value_array(values)
  Arrow::Decimal256ArrayBuilder.build(
    @arrow_type,
    values.map do |value|
      Arrow::Decimal256.new(format(@format_str, BigDecimal(value)))
    end
  )
end