Class: ArrowFormat::Org::Apache::Arrow::Flatbuf::Time

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

Overview

Time is either a 32-bit or 64-bit signed integer type representing an elapsed time since midnight, stored in either of four units: seconds, milliseconds, microseconds or nanoseconds.

The integer ‘bitWidth` depends on the `unit` and must be one of the following:

  • SECOND and MILLISECOND: 32 bits

  • MICROSECOND and NANOSECOND: 64 bits

The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds (exclusive), adjusted for the time unit (for example, up to 86400000 exclusive for the MILLISECOND unit). This definition doesn’t allow for leap seconds. Time values from measurements with leap seconds will need to be corrected when ingesting into Arrow (for example by replacing the value 86400 with 86399).

Constant Summary collapse

FIELDS =
{
  unit: ::FlatBuffers::Field.new(:unit, 0, 4, :short, 0),
  bit_width: ::FlatBuffers::Field.new(:bit_width, 1, 6, :int, 0),
}
Data =
define_data_class

Instance Method Summary collapse

Instance Method Details

#bit_widthObject



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

def bit_width
  field_offset = @view.unpack_virtual_offset(6)
  return 32 if field_offset.zero?

  @view.unpack_int(field_offset)
end

#unitObject



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

def unit
  field_offset = @view.unpack_virtual_offset(4)
  if field_offset.zero?
    enum_value = 1
  else
    enum_value = @view.unpack_short(field_offset)
  end
  ::ArrowFormat::Org::Apache::Arrow::Flatbuf::TimeUnit.try_convert(enum_value) || enum_value
end