Class: ArrowFormat::Org::Apache::Arrow::Flatbuf::Schema

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

Overview


A Schema describes the columns in a row batch

Constant Summary collapse

FIELDS =
{
  endianness: ::FlatBuffers::Field.new(:endianness, 0, 4, :short, 0),
  fields: ::FlatBuffers::Field.new(:fields, 1, 6, ["::ArrowFormat::Org::Apache::Arrow::Flatbuf::Field"], 0),
  custom_metadata: ::FlatBuffers::Field.new(:custom_metadata, 2, 8, ["::ArrowFormat::Org::Apache::Arrow::Flatbuf::KeyValue"], 0),
  features: ::FlatBuffers::Field.new(:features, 3, 10, [:long], 0),
}
Data =
define_data_class

Instance Method Summary collapse

Instance Method Details

#custom_metadataObject



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

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

  element_size = 4
  @view.unpack_vector(field_offset, element_size) do |element_offset|
    @view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::KeyValue, element_offset)
  end
end

#endiannessObject

endianness of the buffer it is Little Endian by default if endianness doesn’t match the underlying system then the vectors need to be converted



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

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

#featuresObject

Features used in the stream/file.



53
54
55
56
57
58
59
60
61
# File 'lib/arrow-format/org/apache/arrow/flatbuf/schema.rb', line 53

def features
  field_offset = @view.unpack_virtual_offset(10)
  return nil if field_offset.zero?

  element_size = 8
  @view.unpack_vector(field_offset, element_size) do |element_offset|
    @view.unpack_long(element_offset)
  end
end

#fieldsObject



63
64
65
66
67
68
69
70
71
# File 'lib/arrow-format/org/apache/arrow/flatbuf/schema.rb', line 63

def fields
  field_offset = @view.unpack_virtual_offset(6)
  return nil if field_offset.zero?

  element_size = 4
  @view.unpack_vector(field_offset, element_size) do |element_offset|
    @view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Field, element_offset)
  end
end