red-arrow-format 23.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +26 -0
- data/LICENSE.txt +202 -0
- data/NOTICE.txt +2 -0
- data/README.md +61 -0
- data/Rakefile +67 -0
- data/lib/arrow-format/array.rb +476 -0
- data/lib/arrow-format/bitmap.rb +44 -0
- data/lib/arrow-format/error.rb +34 -0
- data/lib/arrow-format/field.rb +33 -0
- data/lib/arrow-format/file-reader.rb +213 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/binary.rb +21 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/binary_view.rb +27 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/block.rb +38 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/body_compression.rb +47 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/body_compression_method.rb +31 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/bool.rb +20 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/buffer.rb +38 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/compression_type.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/date.rb +36 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/date_unit.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/decimal.rb +48 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/dictionary_batch.rb +50 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/dictionary_encoding.rb +64 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/dictionary_kind.rb +26 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/duration.rb +30 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/endianness.rb +24 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/feature.rb +46 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/field.rb +92 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/field_node.rb +43 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/fixed_size_binary.rb +27 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/fixed_size_list.rb +27 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/floating_point.rb +30 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/footer.rb +74 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/int.rb +33 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/interval.rb +30 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/interval_unit.rb +23 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/key_value.rb +36 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/large_binary.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/large_list.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/large_list_view.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/large_utf8.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/list.rb +20 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/list_view.rb +23 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/map.rb +52 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/message.rb +68 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/message_header.rb +39 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/metadata_version.rb +36 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/null.rb +21 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/precision.rb +23 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/record_batch.rb +93 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/run_end_encoded.rb +25 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/schema.rb +68 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_matrix_compressed_axis.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_matrix_index_csx.rb +96 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor.rb +92 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor_index.rb +29 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor_index_coo.rb +93 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/sparse_tensor_index_csf.rb +129 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/struct_.rb +23 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/tensor.rb +74 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/tensor_dim.rb +38 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/time.rb +51 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/time_unit.rb +24 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/timestamp.rb +152 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/type.rb +55 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/union.rb +44 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/union_mode.rb +22 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/utf8.rb +21 -0
- data/lib/arrow-format/org/apache/arrow/flatbuf/utf8view.rb +27 -0
- data/lib/arrow-format/readable.rb +271 -0
- data/lib/arrow-format/record-batch.rb +36 -0
- data/lib/arrow-format/schema.rb +24 -0
- data/lib/arrow-format/streaming-pull-reader.rb +243 -0
- data/lib/arrow-format/streaming-reader.rb +50 -0
- data/lib/arrow-format/type.rb +704 -0
- data/lib/arrow-format/version.rb +26 -0
- data/lib/arrow-format.rb +20 -0
- data/red-arrow-format.gemspec +57 -0
- metadata +137 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
# Represents the same logical types that List can, but contains offsets and
|
|
15
|
+
# sizes allowing for writes in any order and sharing of child values among
|
|
16
|
+
# list values.
|
|
17
|
+
class ListView < ::FlatBuffers::Table
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
# A Map is a logical nested type that is represented as
|
|
15
|
+
#
|
|
16
|
+
# List<entries: Struct<key: K, value: V>>
|
|
17
|
+
#
|
|
18
|
+
# In this layout, the keys and values are each respectively contiguous. We do
|
|
19
|
+
# not constrain the key and value types, so the application is responsible
|
|
20
|
+
# for ensuring that the keys are hashable and unique. Whether the keys are sorted
|
|
21
|
+
# may be set in the metadata for this field.
|
|
22
|
+
#
|
|
23
|
+
# In a field with Map type, the field has a child Struct field, which then
|
|
24
|
+
# has two children: key type and the second the value type. The names of the
|
|
25
|
+
# child fields may be respectively "entries", "key", and "value", but this is
|
|
26
|
+
# not enforced.
|
|
27
|
+
#
|
|
28
|
+
# Map
|
|
29
|
+
# ```text
|
|
30
|
+
# - child[0] entries: Struct
|
|
31
|
+
# - child[0] key: K
|
|
32
|
+
# - child[1] value: V
|
|
33
|
+
# ```
|
|
34
|
+
# Neither the "entries" field nor the "key" field may be nullable.
|
|
35
|
+
#
|
|
36
|
+
# The metadata is structured so that Arrow systems without special handling
|
|
37
|
+
# for Map can make Map an alias for List. The "layout" attribute for the Map
|
|
38
|
+
# field must have the same contents as a List.
|
|
39
|
+
class Map < ::FlatBuffers::Table
|
|
40
|
+
# Set to true if the keys within each value are sorted
|
|
41
|
+
def keys_sorted?
|
|
42
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
43
|
+
return false if field_offset.zero?
|
|
44
|
+
|
|
45
|
+
@view.unpack_bool(field_offset)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Message.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
require_relative "../../../apache/arrow/flatbuf/key_value"
|
|
9
|
+
require_relative "../../../apache/arrow/flatbuf/message_header"
|
|
10
|
+
require_relative "../../../apache/arrow/flatbuf/metadata_version"
|
|
11
|
+
|
|
12
|
+
module ArrowFormat
|
|
13
|
+
module Org
|
|
14
|
+
module Apache
|
|
15
|
+
module Arrow
|
|
16
|
+
module Flatbuf
|
|
17
|
+
class Message < ::FlatBuffers::Table
|
|
18
|
+
def body_length
|
|
19
|
+
field_offset = @view.unpack_virtual_offset(10)
|
|
20
|
+
return 0 if field_offset.zero?
|
|
21
|
+
|
|
22
|
+
@view.unpack_long(field_offset)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def custom_metadata
|
|
26
|
+
field_offset = @view.unpack_virtual_offset(12)
|
|
27
|
+
return nil if field_offset.zero?
|
|
28
|
+
|
|
29
|
+
element_size = 4
|
|
30
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
31
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::KeyValue, element_offset)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def header
|
|
36
|
+
type = header_type
|
|
37
|
+
return nil if type.nil?
|
|
38
|
+
|
|
39
|
+
field_offset = @view.unpack_virtual_offset(8)
|
|
40
|
+
return nil if field_offset.zero?
|
|
41
|
+
@view.unpack_union(type.table_class, field_offset)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def header_type
|
|
45
|
+
field_offset = @view.unpack_virtual_offset(6)
|
|
46
|
+
if field_offset.zero?
|
|
47
|
+
enum_value = 0
|
|
48
|
+
else
|
|
49
|
+
enum_value = @view.unpack_utype(field_offset)
|
|
50
|
+
end
|
|
51
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::MessageHeader.try_convert(enum_value) || enum_value
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def version
|
|
55
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
56
|
+
if field_offset.zero?
|
|
57
|
+
enum_value = 0
|
|
58
|
+
else
|
|
59
|
+
enum_value = @view.unpack_short(field_offset)
|
|
60
|
+
end
|
|
61
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::MetadataVersion.try_convert(enum_value) || enum_value
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Message.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
# ----------------------------------------------------------------------
|
|
15
|
+
# The root Message type
|
|
16
|
+
# This union enables us to easily send different message types without
|
|
17
|
+
# redundant storage, and in the future we can easily add new message types.
|
|
18
|
+
#
|
|
19
|
+
# Arrow implementations do not need to implement all of the message types,
|
|
20
|
+
# which may include experimental metadata types. For maximum compatibility,
|
|
21
|
+
# it is best to send data using RecordBatch
|
|
22
|
+
class MessageHeader < ::FlatBuffers::Union
|
|
23
|
+
NONE = register("NONE", 0, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::Utf8View", "../../../apache/arrow/flatbuf/utf8view")
|
|
24
|
+
SCHEMA = register("Schema", 1, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::Schema", "../../../apache/arrow/flatbuf/schema")
|
|
25
|
+
DICTIONARY_BATCH = register("DictionaryBatch", 2, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::DictionaryBatch", "../../../apache/arrow/flatbuf/dictionary_batch")
|
|
26
|
+
RECORD_BATCH = register("RecordBatch", 3, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::RecordBatch", "../../../apache/arrow/flatbuf/record_batch")
|
|
27
|
+
TENSOR = register("Tensor", 4, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::Tensor", "../../../apache/arrow/flatbuf/tensor")
|
|
28
|
+
SPARSE_TENSOR = register("SparseTensor", 5, "::ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensor", "../../../apache/arrow/flatbuf/sparse_tensor")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
private def require_table_class
|
|
32
|
+
require_relative @require_path
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
class MetadataVersion < ::FlatBuffers::Enum
|
|
15
|
+
# 0.1.0 (October 2016).
|
|
16
|
+
V1 = register("V1", 0)
|
|
17
|
+
# 0.2.0 (February 2017). Non-backwards compatible with V1.
|
|
18
|
+
V2 = register("V2", 1)
|
|
19
|
+
# 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.
|
|
20
|
+
V3 = register("V3", 2)
|
|
21
|
+
# >= 0.8.0 (December 2017). Non-backwards compatible with V3.
|
|
22
|
+
V4 = register("V4", 3)
|
|
23
|
+
# >= 1.0.0 (July 2020). Backwards compatible with V4 (V5 readers can read V4
|
|
24
|
+
# metadata and IPC messages). Implementations are recommended to provide a
|
|
25
|
+
# V4 compatibility mode with V5 format changes disabled.
|
|
26
|
+
#
|
|
27
|
+
# Incompatible changes between V4 and V5:
|
|
28
|
+
# - Union buffer layout has changed. In V5, Unions don't have a validity
|
|
29
|
+
# bitmap buffer.
|
|
30
|
+
V5 = register("V5", 4)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
# These are stored in the flatbuffer in the Type union below
|
|
15
|
+
class Null < ::FlatBuffers::Table
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
class Precision < ::FlatBuffers::Enum
|
|
15
|
+
HALF = register("HALF", 0)
|
|
16
|
+
SINGLE = register("SINGLE", 1)
|
|
17
|
+
DOUBLE = register("DOUBLE", 2)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Message.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
require_relative "../../../apache/arrow/flatbuf/buffer"
|
|
9
|
+
require_relative "../../../apache/arrow/flatbuf/body_compression"
|
|
10
|
+
require_relative "../../../apache/arrow/flatbuf/field_node"
|
|
11
|
+
|
|
12
|
+
module ArrowFormat
|
|
13
|
+
module Org
|
|
14
|
+
module Apache
|
|
15
|
+
module Arrow
|
|
16
|
+
module Flatbuf
|
|
17
|
+
# A data header describing the shared memory layout of a "record" or "row"
|
|
18
|
+
# batch. Some systems call this a "row batch" internally and others a "record
|
|
19
|
+
# batch".
|
|
20
|
+
class RecordBatch < ::FlatBuffers::Table
|
|
21
|
+
# Buffers correspond to the pre-ordered flattened buffer tree
|
|
22
|
+
#
|
|
23
|
+
# The number of buffers appended to this list depends on the schema. For
|
|
24
|
+
# example, most primitive arrays will have 2 buffers, 1 for the validity
|
|
25
|
+
# bitmap and 1 for the values. For struct arrays, there will only be a
|
|
26
|
+
# single buffer for the validity (nulls) bitmap
|
|
27
|
+
def buffers
|
|
28
|
+
field_offset = @view.unpack_virtual_offset(8)
|
|
29
|
+
return nil if field_offset.zero?
|
|
30
|
+
|
|
31
|
+
element_size = 16
|
|
32
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
33
|
+
@view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, element_offset)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Optional compression of the message body
|
|
38
|
+
def compression
|
|
39
|
+
field_offset = @view.unpack_virtual_offset(10)
|
|
40
|
+
return nil if field_offset.zero?
|
|
41
|
+
|
|
42
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::BodyCompression, field_offset)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# number of records / rows. The arrays in the batch should all have this
|
|
46
|
+
# length
|
|
47
|
+
def length
|
|
48
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
49
|
+
return 0 if field_offset.zero?
|
|
50
|
+
|
|
51
|
+
@view.unpack_long(field_offset)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Nodes correspond to the pre-ordered flattened logical schema
|
|
55
|
+
def nodes
|
|
56
|
+
field_offset = @view.unpack_virtual_offset(6)
|
|
57
|
+
return nil if field_offset.zero?
|
|
58
|
+
|
|
59
|
+
element_size = 16
|
|
60
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
61
|
+
@view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::FieldNode, element_offset)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Some types such as Utf8View are represented using a variable number of buffers.
|
|
66
|
+
# For each such Field in the pre-ordered flattened logical schema, there will be
|
|
67
|
+
# an entry in variadicBufferCounts to indicate the number of number of variadic
|
|
68
|
+
# buffers which belong to that Field in the current RecordBatch.
|
|
69
|
+
#
|
|
70
|
+
# For example, the schema
|
|
71
|
+
# col1: Struct<alpha: Int32, beta: BinaryView, gamma: Float64>
|
|
72
|
+
# col2: Utf8View
|
|
73
|
+
# contains two Fields with variadic buffers so variadicBufferCounts will have
|
|
74
|
+
# two entries, the first counting the variadic buffers of `col1.beta` and the
|
|
75
|
+
# second counting `col2`'s.
|
|
76
|
+
#
|
|
77
|
+
# This field may be omitted if and only if the schema contains no Fields with
|
|
78
|
+
# a variable number of buffers, such as BinaryView and Utf8View.
|
|
79
|
+
def variadic_buffer_counts
|
|
80
|
+
field_offset = @view.unpack_virtual_offset(12)
|
|
81
|
+
return nil if field_offset.zero?
|
|
82
|
+
|
|
83
|
+
element_size = 8
|
|
84
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
85
|
+
@view.unpack_long(element_offset)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
# Contains two child arrays, run_ends and values.
|
|
15
|
+
# The run_ends child array must be a 16/32/64-bit integer array
|
|
16
|
+
# which encodes the indices at which the run with the value in
|
|
17
|
+
# each corresponding index in the values child array ends.
|
|
18
|
+
# Like list/struct types, the value array can be of any type.
|
|
19
|
+
class RunEndEncoded < ::FlatBuffers::Table
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //Schema.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
require_relative "../../../apache/arrow/flatbuf/key_value"
|
|
9
|
+
require_relative "../../../apache/arrow/flatbuf/endianness"
|
|
10
|
+
require_relative "../../../apache/arrow/flatbuf/field"
|
|
11
|
+
|
|
12
|
+
module ArrowFormat
|
|
13
|
+
module Org
|
|
14
|
+
module Apache
|
|
15
|
+
module Arrow
|
|
16
|
+
module Flatbuf
|
|
17
|
+
# ----------------------------------------------------------------------
|
|
18
|
+
# A Schema describes the columns in a row batch
|
|
19
|
+
class Schema < ::FlatBuffers::Table
|
|
20
|
+
def custom_metadata
|
|
21
|
+
field_offset = @view.unpack_virtual_offset(8)
|
|
22
|
+
return nil if field_offset.zero?
|
|
23
|
+
|
|
24
|
+
element_size = 4
|
|
25
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
26
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::KeyValue, element_offset)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# endianness of the buffer
|
|
31
|
+
# it is Little Endian by default
|
|
32
|
+
# if endianness doesn't match the underlying system then the vectors need to be converted
|
|
33
|
+
def endianness
|
|
34
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
35
|
+
if field_offset.zero?
|
|
36
|
+
enum_value = 0
|
|
37
|
+
else
|
|
38
|
+
enum_value = @view.unpack_short(field_offset)
|
|
39
|
+
end
|
|
40
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::Endianness.try_convert(enum_value) || enum_value
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Features used in the stream/file.
|
|
44
|
+
def features
|
|
45
|
+
field_offset = @view.unpack_virtual_offset(10)
|
|
46
|
+
return nil if field_offset.zero?
|
|
47
|
+
|
|
48
|
+
element_size = 8
|
|
49
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
50
|
+
@view.unpack_long(element_offset)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def fields
|
|
55
|
+
field_offset = @view.unpack_virtual_offset(6)
|
|
56
|
+
return nil if field_offset.zero?
|
|
57
|
+
|
|
58
|
+
element_size = 4
|
|
59
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
60
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Field, element_offset)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //SparseTensor.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
|
|
9
|
+
module ArrowFormat
|
|
10
|
+
module Org
|
|
11
|
+
module Apache
|
|
12
|
+
module Arrow
|
|
13
|
+
module Flatbuf
|
|
14
|
+
class SparseMatrixCompressedAxis < ::FlatBuffers::Enum
|
|
15
|
+
ROW = register("Row", 0)
|
|
16
|
+
COLUMN = register("Column", 1)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //SparseTensor.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
require_relative "../../../apache/arrow/flatbuf/sparse_matrix_compressed_axis"
|
|
9
|
+
require_relative "../../../apache/arrow/flatbuf/buffer"
|
|
10
|
+
require_relative "../../../apache/arrow/flatbuf/int"
|
|
11
|
+
|
|
12
|
+
module ArrowFormat
|
|
13
|
+
module Org
|
|
14
|
+
module Apache
|
|
15
|
+
module Arrow
|
|
16
|
+
module Flatbuf
|
|
17
|
+
# Compressed Sparse format, that is matrix-specific.
|
|
18
|
+
class SparseMatrixIndexCSX < ::FlatBuffers::Table
|
|
19
|
+
# Which axis, row or column, is compressed
|
|
20
|
+
def compressed_axis
|
|
21
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
22
|
+
if field_offset.zero?
|
|
23
|
+
enum_value = 0
|
|
24
|
+
else
|
|
25
|
+
enum_value = @view.unpack_short(field_offset)
|
|
26
|
+
end
|
|
27
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseMatrixCompressedAxis.try_convert(enum_value) || enum_value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# indicesBuffer stores the location and size of the array that
|
|
31
|
+
# contains the column indices of the corresponding non-zero values.
|
|
32
|
+
# The type of index value is long.
|
|
33
|
+
#
|
|
34
|
+
# For example, the indices of the above X is:
|
|
35
|
+
# ```text
|
|
36
|
+
# indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
|
|
37
|
+
# ```
|
|
38
|
+
# Note that the indices are sorted in lexicographical order for each row.
|
|
39
|
+
def indices_buffer
|
|
40
|
+
field_offset = @view.unpack_virtual_offset(12)
|
|
41
|
+
return nil if field_offset.zero?
|
|
42
|
+
|
|
43
|
+
@view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, field_offset)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The type of values in indicesBuffer
|
|
47
|
+
def indices_type
|
|
48
|
+
field_offset = @view.unpack_virtual_offset(10)
|
|
49
|
+
return nil if field_offset.zero?
|
|
50
|
+
|
|
51
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Int, field_offset)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# indptrBuffer stores the location and size of indptr array that
|
|
55
|
+
# represents the range of the rows.
|
|
56
|
+
# The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
|
|
57
|
+
# The length of this array is 1 + (the number of rows), and the type
|
|
58
|
+
# of index value is long.
|
|
59
|
+
#
|
|
60
|
+
# For example, let X be the following 6x4 matrix:
|
|
61
|
+
# ```text
|
|
62
|
+
# X := [[0, 1, 2, 0],
|
|
63
|
+
# [0, 0, 3, 0],
|
|
64
|
+
# [0, 4, 0, 5],
|
|
65
|
+
# [0, 0, 0, 0],
|
|
66
|
+
# [6, 0, 7, 8],
|
|
67
|
+
# [0, 9, 0, 0]].
|
|
68
|
+
# ```
|
|
69
|
+
# The array of non-zero values in X is:
|
|
70
|
+
# ```text
|
|
71
|
+
# values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
|
|
72
|
+
# ```
|
|
73
|
+
# And the indptr of X is:
|
|
74
|
+
# ```text
|
|
75
|
+
# indptr(X) = [0, 2, 3, 5, 5, 8, 10].
|
|
76
|
+
# ```
|
|
77
|
+
def indptr_buffer
|
|
78
|
+
field_offset = @view.unpack_virtual_offset(8)
|
|
79
|
+
return nil if field_offset.zero?
|
|
80
|
+
|
|
81
|
+
@view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, field_offset)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# The type of values in indptrBuffer
|
|
85
|
+
def indptr_type
|
|
86
|
+
field_offset = @view.unpack_virtual_offset(6)
|
|
87
|
+
return nil if field_offset.zero?
|
|
88
|
+
|
|
89
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Int, field_offset)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Automatically generated. Don't modify manually.
|
|
2
|
+
#
|
|
3
|
+
# Red FlatBuffers version: 0.0.3
|
|
4
|
+
# Declared by: //SparseTensor.fbs
|
|
5
|
+
# Rooting type: org.apache.arrow.flatbuf.Message (//Message.fbs)
|
|
6
|
+
|
|
7
|
+
require "flatbuffers"
|
|
8
|
+
require_relative "../../../apache/arrow/flatbuf/buffer"
|
|
9
|
+
require_relative "../../../apache/arrow/flatbuf/tensor_dim"
|
|
10
|
+
require_relative "../../../apache/arrow/flatbuf/sparse_tensor_index"
|
|
11
|
+
require_relative "../../../apache/arrow/flatbuf/type"
|
|
12
|
+
|
|
13
|
+
module ArrowFormat
|
|
14
|
+
module Org
|
|
15
|
+
module Apache
|
|
16
|
+
module Arrow
|
|
17
|
+
module Flatbuf
|
|
18
|
+
class SparseTensor < ::FlatBuffers::Table
|
|
19
|
+
# The location and size of the tensor's data
|
|
20
|
+
def data
|
|
21
|
+
field_offset = @view.unpack_virtual_offset(16)
|
|
22
|
+
return nil if field_offset.zero?
|
|
23
|
+
|
|
24
|
+
@view.unpack_struct(::ArrowFormat::Org::Apache::Arrow::Flatbuf::Buffer, field_offset)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The number of non-zero values in a sparse tensor.
|
|
28
|
+
def non_zero_length
|
|
29
|
+
field_offset = @view.unpack_virtual_offset(10)
|
|
30
|
+
return 0 if field_offset.zero?
|
|
31
|
+
|
|
32
|
+
@view.unpack_long(field_offset)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# The dimensions of the tensor, optionally named.
|
|
36
|
+
def shape
|
|
37
|
+
field_offset = @view.unpack_virtual_offset(8)
|
|
38
|
+
return nil if field_offset.zero?
|
|
39
|
+
|
|
40
|
+
element_size = 4
|
|
41
|
+
@view.unpack_vector(field_offset, element_size) do |element_offset|
|
|
42
|
+
@view.unpack_table(::ArrowFormat::Org::Apache::Arrow::Flatbuf::TensorDim, element_offset)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Sparse tensor index
|
|
47
|
+
def sparse_index
|
|
48
|
+
type = sparse_index_type
|
|
49
|
+
return nil if type.nil?
|
|
50
|
+
|
|
51
|
+
field_offset = @view.unpack_virtual_offset(14)
|
|
52
|
+
return nil if field_offset.zero?
|
|
53
|
+
@view.unpack_union(type.table_class, field_offset)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def sparse_index_type
|
|
57
|
+
field_offset = @view.unpack_virtual_offset(12)
|
|
58
|
+
if field_offset.zero?
|
|
59
|
+
enum_value = 0
|
|
60
|
+
else
|
|
61
|
+
enum_value = @view.unpack_utype(field_offset)
|
|
62
|
+
end
|
|
63
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::SparseTensorIndex.try_convert(enum_value) || enum_value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# The type of data contained in a value cell.
|
|
67
|
+
# Currently only fixed-width value types are supported,
|
|
68
|
+
# no strings or nested types.
|
|
69
|
+
def type
|
|
70
|
+
type = type_type
|
|
71
|
+
return nil if type.nil?
|
|
72
|
+
|
|
73
|
+
field_offset = @view.unpack_virtual_offset(6)
|
|
74
|
+
return nil if field_offset.zero?
|
|
75
|
+
@view.unpack_union(type.table_class, field_offset)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def type_type
|
|
79
|
+
field_offset = @view.unpack_virtual_offset(4)
|
|
80
|
+
if field_offset.zero?
|
|
81
|
+
enum_value = 0
|
|
82
|
+
else
|
|
83
|
+
enum_value = @view.unpack_utype(field_offset)
|
|
84
|
+
end
|
|
85
|
+
::ArrowFormat::Org::Apache::Arrow::Flatbuf::Type.try_convert(enum_value) || enum_value
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|