Class: Parqueteur::Types::Decimal128Type

Inherits:
Parqueteur::Type show all
Defined in:
lib/parqueteur/types/decimal128_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) ⇒ Decimal128Type

Returns a new instance of Decimal128Type.



6
7
8
9
10
11
# File 'lib/parqueteur/types/decimal128_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/decimal128_type.rb', line 22

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

#build_value_array(values) ⇒ Object



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

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