micromegas 0.2.2__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
@@ -0,0 +1,2925 @@
1
+ # automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ # namespace: flatbuf
4
+
5
+ import flatbuffers
6
+ from flatbuffers.compat import import_numpy
7
+ np = import_numpy()
8
+
9
+ class MetadataVersion(object):
10
+ # 0.1.0 (October 2016).
11
+ V1 = 0
12
+ # 0.2.0 (February 2017). Non-backwards compatible with V1.
13
+ V2 = 1
14
+ # 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.
15
+ V3 = 2
16
+ # >= 0.8.0 (December 2017). Non-backwards compatible with V3.
17
+ V4 = 3
18
+ # >= 1.0.0 (July 2020). Backwards compatible with V4 (V5 readers can read V4
19
+ # metadata and IPC messages). Implementations are recommended to provide a
20
+ # V4 compatibility mode with V5 format changes disabled.
21
+ #
22
+ # Incompatible changes between V4 and V5:
23
+ # - Union buffer layout has changed. In V5, Unions don't have a validity
24
+ # bitmap buffer.
25
+ V5 = 4
26
+
27
+
28
+ # Represents Arrow Features that might not have full support
29
+ # within implementations. This is intended to be used in
30
+ # two scenarios:
31
+ # 1. A mechanism for readers of Arrow Streams
32
+ # and files to understand that the stream or file makes
33
+ # use of a feature that isn't supported or unknown to
34
+ # the implementation (and therefore can meet the Arrow
35
+ # forward compatibility guarantees).
36
+ # 2. A means of negotiating between a client and server
37
+ # what features a stream is allowed to use. The enums
38
+ # values here are intented to represent higher level
39
+ # features, additional details maybe negotiated
40
+ # with key-value pairs specific to the protocol.
41
+ #
42
+ # Enums added to this list should be assigned power-of-two values
43
+ # to facilitate exchanging and comparing bitmaps for supported
44
+ # features.
45
+ class Feature(object):
46
+ # Needed to make flatbuffers happy.
47
+ UNUSED = 0
48
+ # The stream makes use of multiple full dictionaries with the
49
+ # same ID and assumes clients implement dictionary replacement
50
+ # correctly.
51
+ DICTIONARY_REPLACEMENT = 1
52
+ # The stream makes use of compressed bodies as described
53
+ # in Message.fbs.
54
+ COMPRESSED_BODY = 2
55
+
56
+
57
+ class UnionMode(object):
58
+ Sparse = 0
59
+ Dense = 1
60
+
61
+
62
+ class Precision(object):
63
+ HALF = 0
64
+ SINGLE = 1
65
+ DOUBLE = 2
66
+
67
+
68
+ class DateUnit(object):
69
+ DAY = 0
70
+ MILLISECOND = 1
71
+
72
+
73
+ class TimeUnit(object):
74
+ SECOND = 0
75
+ MILLISECOND = 1
76
+ MICROSECOND = 2
77
+ NANOSECOND = 3
78
+
79
+
80
+ class IntervalUnit(object):
81
+ YEAR_MONTH = 0
82
+ DAY_TIME = 1
83
+ MONTH_DAY_NANO = 2
84
+
85
+
86
+ # ----------------------------------------------------------------------
87
+ # Top-level Type value, enabling extensible type-specific metadata. We can
88
+ # add new logical types to Type without breaking backwards compatibility
89
+ class Type(object):
90
+ NONE = 0
91
+ Null = 1
92
+ Int = 2
93
+ FloatingPoint = 3
94
+ Binary = 4
95
+ Utf8 = 5
96
+ Bool = 6
97
+ Decimal = 7
98
+ Date = 8
99
+ Time = 9
100
+ Timestamp = 10
101
+ Interval = 11
102
+ List = 12
103
+ Struct_ = 13
104
+ Union = 14
105
+ FixedSizeBinary = 15
106
+ FixedSizeList = 16
107
+ Map = 17
108
+ Duration = 18
109
+ LargeBinary = 19
110
+ LargeUtf8 = 20
111
+ LargeList = 21
112
+ RunEndEncoded = 22
113
+ BinaryView = 23
114
+ Utf8View = 24
115
+ ListView = 25
116
+ LargeListView = 26
117
+
118
+
119
+ # ----------------------------------------------------------------------
120
+ # Dictionary encoding metadata
121
+ # Maintained for forwards compatibility, in the future
122
+ # Dictionaries might be explicit maps between integers and values
123
+ # allowing for non-contiguous index values
124
+ class DictionaryKind(object):
125
+ DenseArray = 0
126
+
127
+
128
+ # ----------------------------------------------------------------------
129
+ # Endianness of the platform producing the data
130
+ class Endianness(object):
131
+ Little = 0
132
+ Big = 1
133
+
134
+
135
+ class SparseMatrixCompressedAxis(object):
136
+ Row = 0
137
+ Column = 1
138
+
139
+
140
+ class SparseTensorIndex(object):
141
+ NONE = 0
142
+ SparseTensorIndexCOO = 1
143
+ SparseMatrixIndexCSX = 2
144
+ SparseTensorIndexCSF = 3
145
+
146
+
147
+ class CompressionType(object):
148
+ LZ4_FRAME = 0
149
+ ZSTD = 1
150
+
151
+
152
+ # Provided for forward compatibility in case we need to support different
153
+ # strategies for compressing the IPC message body (like whole-body
154
+ # compression rather than buffer-level) in the future
155
+ class BodyCompressionMethod(object):
156
+ # Each constituent buffer is first compressed with the indicated
157
+ # compressor, and then written with the uncompressed length in the first 8
158
+ # bytes as a 64-bit little-endian signed integer followed by the compressed
159
+ # buffer bytes (and then padding as required by the protocol). The
160
+ # uncompressed length may be set to -1 to indicate that the data that
161
+ # follows is not compressed, which can be useful for cases where
162
+ # compression does not yield appreciable savings.
163
+ BUFFER = 0
164
+
165
+
166
+ # ----------------------------------------------------------------------
167
+ # The root Message type
168
+ # This union enables us to easily send different message types without
169
+ # redundant storage, and in the future we can easily add new message types.
170
+ #
171
+ # Arrow implementations do not need to implement all of the message types,
172
+ # which may include experimental metadata types. For maximum compatibility,
173
+ # it is best to send data using RecordBatch
174
+ class MessageHeader(object):
175
+ NONE = 0
176
+ Schema = 1
177
+ DictionaryBatch = 2
178
+ RecordBatch = 3
179
+ Tensor = 4
180
+ SparseTensor = 5
181
+
182
+
183
+ # These are stored in the flatbuffer in the Type union below
184
+ class Null(object):
185
+ __slots__ = ['_tab']
186
+
187
+ @classmethod
188
+ def GetRootAs(cls, buf, offset=0):
189
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
190
+ x = Null()
191
+ x.Init(buf, n + offset)
192
+ return x
193
+
194
+ @classmethod
195
+ def GetRootAsNull(cls, buf, offset=0):
196
+ """This method is deprecated. Please switch to GetRootAs."""
197
+ return cls.GetRootAs(buf, offset)
198
+ # Null
199
+ def Init(self, buf, pos):
200
+ self._tab = flatbuffers.table.Table(buf, pos)
201
+
202
+ def NullStart(builder):
203
+ builder.StartObject(0)
204
+
205
+ def NullEnd(builder):
206
+ return builder.EndObject()
207
+
208
+
209
+
210
+ # A Struct_ in the flatbuffer metadata is the same as an Arrow Struct
211
+ # (according to the physical memory layout). We used Struct_ here as
212
+ # Struct is a reserved word in Flatbuffers
213
+ class Struct_(object):
214
+ __slots__ = ['_tab']
215
+
216
+ @classmethod
217
+ def GetRootAs(cls, buf, offset=0):
218
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
219
+ x = Struct_()
220
+ x.Init(buf, n + offset)
221
+ return x
222
+
223
+ @classmethod
224
+ def GetRootAsStruct_(cls, buf, offset=0):
225
+ """This method is deprecated. Please switch to GetRootAs."""
226
+ return cls.GetRootAs(buf, offset)
227
+ # Struct_
228
+ def Init(self, buf, pos):
229
+ self._tab = flatbuffers.table.Table(buf, pos)
230
+
231
+ def Struct_Start(builder):
232
+ builder.StartObject(0)
233
+
234
+ def Struct_End(builder):
235
+ return builder.EndObject()
236
+
237
+
238
+
239
+ class List(object):
240
+ __slots__ = ['_tab']
241
+
242
+ @classmethod
243
+ def GetRootAs(cls, buf, offset=0):
244
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
245
+ x = List()
246
+ x.Init(buf, n + offset)
247
+ return x
248
+
249
+ @classmethod
250
+ def GetRootAsList(cls, buf, offset=0):
251
+ """This method is deprecated. Please switch to GetRootAs."""
252
+ return cls.GetRootAs(buf, offset)
253
+ # List
254
+ def Init(self, buf, pos):
255
+ self._tab = flatbuffers.table.Table(buf, pos)
256
+
257
+ def ListStart(builder):
258
+ builder.StartObject(0)
259
+
260
+ def ListEnd(builder):
261
+ return builder.EndObject()
262
+
263
+
264
+
265
+ # Same as List, but with 64-bit offsets, allowing to represent
266
+ # extremely large data values.
267
+ class LargeList(object):
268
+ __slots__ = ['_tab']
269
+
270
+ @classmethod
271
+ def GetRootAs(cls, buf, offset=0):
272
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
273
+ x = LargeList()
274
+ x.Init(buf, n + offset)
275
+ return x
276
+
277
+ @classmethod
278
+ def GetRootAsLargeList(cls, buf, offset=0):
279
+ """This method is deprecated. Please switch to GetRootAs."""
280
+ return cls.GetRootAs(buf, offset)
281
+ # LargeList
282
+ def Init(self, buf, pos):
283
+ self._tab = flatbuffers.table.Table(buf, pos)
284
+
285
+ def LargeListStart(builder):
286
+ builder.StartObject(0)
287
+
288
+ def LargeListEnd(builder):
289
+ return builder.EndObject()
290
+
291
+
292
+
293
+ # Represents the same logical types that List can, but contains offsets and
294
+ # sizes allowing for writes in any order and sharing of child values among
295
+ # list values.
296
+ class ListView(object):
297
+ __slots__ = ['_tab']
298
+
299
+ @classmethod
300
+ def GetRootAs(cls, buf, offset=0):
301
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
302
+ x = ListView()
303
+ x.Init(buf, n + offset)
304
+ return x
305
+
306
+ @classmethod
307
+ def GetRootAsListView(cls, buf, offset=0):
308
+ """This method is deprecated. Please switch to GetRootAs."""
309
+ return cls.GetRootAs(buf, offset)
310
+ # ListView
311
+ def Init(self, buf, pos):
312
+ self._tab = flatbuffers.table.Table(buf, pos)
313
+
314
+ def ListViewStart(builder):
315
+ builder.StartObject(0)
316
+
317
+ def ListViewEnd(builder):
318
+ return builder.EndObject()
319
+
320
+
321
+
322
+ # Same as ListView, but with 64-bit offsets and sizes, allowing to represent
323
+ # extremely large data values.
324
+ class LargeListView(object):
325
+ __slots__ = ['_tab']
326
+
327
+ @classmethod
328
+ def GetRootAs(cls, buf, offset=0):
329
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
330
+ x = LargeListView()
331
+ x.Init(buf, n + offset)
332
+ return x
333
+
334
+ @classmethod
335
+ def GetRootAsLargeListView(cls, buf, offset=0):
336
+ """This method is deprecated. Please switch to GetRootAs."""
337
+ return cls.GetRootAs(buf, offset)
338
+ # LargeListView
339
+ def Init(self, buf, pos):
340
+ self._tab = flatbuffers.table.Table(buf, pos)
341
+
342
+ def LargeListViewStart(builder):
343
+ builder.StartObject(0)
344
+
345
+ def LargeListViewEnd(builder):
346
+ return builder.EndObject()
347
+
348
+
349
+
350
+ class FixedSizeList(object):
351
+ __slots__ = ['_tab']
352
+
353
+ @classmethod
354
+ def GetRootAs(cls, buf, offset=0):
355
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
356
+ x = FixedSizeList()
357
+ x.Init(buf, n + offset)
358
+ return x
359
+
360
+ @classmethod
361
+ def GetRootAsFixedSizeList(cls, buf, offset=0):
362
+ """This method is deprecated. Please switch to GetRootAs."""
363
+ return cls.GetRootAs(buf, offset)
364
+ # FixedSizeList
365
+ def Init(self, buf, pos):
366
+ self._tab = flatbuffers.table.Table(buf, pos)
367
+
368
+ # Number of list items per value
369
+ # FixedSizeList
370
+ def ListSize(self):
371
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
372
+ if o != 0:
373
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
374
+ return 0
375
+
376
+ def FixedSizeListStart(builder):
377
+ builder.StartObject(1)
378
+
379
+ def FixedSizeListAddListSize(builder, listSize):
380
+ builder.PrependInt32Slot(0, listSize, 0)
381
+
382
+ def FixedSizeListEnd(builder):
383
+ return builder.EndObject()
384
+
385
+
386
+
387
+ # A Map is a logical nested type that is represented as
388
+ #
389
+ # List<entries: Struct<key: K, value: V>>
390
+ #
391
+ # In this layout, the keys and values are each respectively contiguous. We do
392
+ # not constrain the key and value types, so the application is responsible
393
+ # for ensuring that the keys are hashable and unique. Whether the keys are sorted
394
+ # may be set in the metadata for this field.
395
+ #
396
+ # In a field with Map type, the field has a child Struct field, which then
397
+ # has two children: key type and the second the value type. The names of the
398
+ # child fields may be respectively "entries", "key", and "value", but this is
399
+ # not enforced.
400
+ #
401
+ # Map
402
+ # ```text
403
+ # - child[0] entries: Struct
404
+ # - child[0] key: K
405
+ # - child[1] value: V
406
+ # ```
407
+ # Neither the "entries" field nor the "key" field may be nullable.
408
+ #
409
+ # The metadata is structured so that Arrow systems without special handling
410
+ # for Map can make Map an alias for List. The "layout" attribute for the Map
411
+ # field must have the same contents as a List.
412
+ class Map(object):
413
+ __slots__ = ['_tab']
414
+
415
+ @classmethod
416
+ def GetRootAs(cls, buf, offset=0):
417
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
418
+ x = Map()
419
+ x.Init(buf, n + offset)
420
+ return x
421
+
422
+ @classmethod
423
+ def GetRootAsMap(cls, buf, offset=0):
424
+ """This method is deprecated. Please switch to GetRootAs."""
425
+ return cls.GetRootAs(buf, offset)
426
+ # Map
427
+ def Init(self, buf, pos):
428
+ self._tab = flatbuffers.table.Table(buf, pos)
429
+
430
+ # Set to true if the keys within each value are sorted
431
+ # Map
432
+ def KeysSorted(self):
433
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
434
+ if o != 0:
435
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
436
+ return False
437
+
438
+ def MapStart(builder):
439
+ builder.StartObject(1)
440
+
441
+ def MapAddKeysSorted(builder, keysSorted):
442
+ builder.PrependBoolSlot(0, keysSorted, 0)
443
+
444
+ def MapEnd(builder):
445
+ return builder.EndObject()
446
+
447
+
448
+
449
+ # A union is a complex type with children in Field
450
+ # By default ids in the type vector refer to the offsets in the children
451
+ # optionally typeIds provides an indirection between the child offset and the type id
452
+ # for each child `typeIds[offset]` is the id used in the type vector
453
+ class Union(object):
454
+ __slots__ = ['_tab']
455
+
456
+ @classmethod
457
+ def GetRootAs(cls, buf, offset=0):
458
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
459
+ x = Union()
460
+ x.Init(buf, n + offset)
461
+ return x
462
+
463
+ @classmethod
464
+ def GetRootAsUnion(cls, buf, offset=0):
465
+ """This method is deprecated. Please switch to GetRootAs."""
466
+ return cls.GetRootAs(buf, offset)
467
+ # Union
468
+ def Init(self, buf, pos):
469
+ self._tab = flatbuffers.table.Table(buf, pos)
470
+
471
+ # Union
472
+ def Mode(self):
473
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
474
+ if o != 0:
475
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
476
+ return 0
477
+
478
+ # Union
479
+ def TypeIds(self, j):
480
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
481
+ if o != 0:
482
+ a = self._tab.Vector(o)
483
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
484
+ return 0
485
+
486
+ # Union
487
+ def TypeIdsAsNumpy(self):
488
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
489
+ if o != 0:
490
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
491
+ return 0
492
+
493
+ # Union
494
+ def TypeIdsLength(self):
495
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
496
+ if o != 0:
497
+ return self._tab.VectorLen(o)
498
+ return 0
499
+
500
+ # Union
501
+ def TypeIdsIsNone(self):
502
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
503
+ return o == 0
504
+
505
+ def UnionStart(builder):
506
+ builder.StartObject(2)
507
+
508
+ def UnionAddMode(builder, mode):
509
+ builder.PrependInt16Slot(0, mode, 0)
510
+
511
+ def UnionAddTypeIds(builder, typeIds):
512
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(typeIds), 0)
513
+
514
+ def UnionStartTypeIdsVector(builder, numElems):
515
+ return builder.StartVector(4, numElems, 4)
516
+
517
+ def UnionEnd(builder):
518
+ return builder.EndObject()
519
+
520
+
521
+
522
+ class Int(object):
523
+ __slots__ = ['_tab']
524
+
525
+ @classmethod
526
+ def GetRootAs(cls, buf, offset=0):
527
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
528
+ x = Int()
529
+ x.Init(buf, n + offset)
530
+ return x
531
+
532
+ @classmethod
533
+ def GetRootAsInt(cls, buf, offset=0):
534
+ """This method is deprecated. Please switch to GetRootAs."""
535
+ return cls.GetRootAs(buf, offset)
536
+ # Int
537
+ def Init(self, buf, pos):
538
+ self._tab = flatbuffers.table.Table(buf, pos)
539
+
540
+ # Int
541
+ def BitWidth(self):
542
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
543
+ if o != 0:
544
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
545
+ return 0
546
+
547
+ # Int
548
+ def IsSigned(self):
549
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
550
+ if o != 0:
551
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
552
+ return False
553
+
554
+ def IntStart(builder):
555
+ builder.StartObject(2)
556
+
557
+ def IntAddBitWidth(builder, bitWidth):
558
+ builder.PrependInt32Slot(0, bitWidth, 0)
559
+
560
+ def IntAddIsSigned(builder, isSigned):
561
+ builder.PrependBoolSlot(1, isSigned, 0)
562
+
563
+ def IntEnd(builder):
564
+ return builder.EndObject()
565
+
566
+
567
+
568
+ class FloatingPoint(object):
569
+ __slots__ = ['_tab']
570
+
571
+ @classmethod
572
+ def GetRootAs(cls, buf, offset=0):
573
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
574
+ x = FloatingPoint()
575
+ x.Init(buf, n + offset)
576
+ return x
577
+
578
+ @classmethod
579
+ def GetRootAsFloatingPoint(cls, buf, offset=0):
580
+ """This method is deprecated. Please switch to GetRootAs."""
581
+ return cls.GetRootAs(buf, offset)
582
+ # FloatingPoint
583
+ def Init(self, buf, pos):
584
+ self._tab = flatbuffers.table.Table(buf, pos)
585
+
586
+ # FloatingPoint
587
+ def Precision(self):
588
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
589
+ if o != 0:
590
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
591
+ return 0
592
+
593
+ def FloatingPointStart(builder):
594
+ builder.StartObject(1)
595
+
596
+ def FloatingPointAddPrecision(builder, precision):
597
+ builder.PrependInt16Slot(0, precision, 0)
598
+
599
+ def FloatingPointEnd(builder):
600
+ return builder.EndObject()
601
+
602
+
603
+
604
+ # Unicode with UTF-8 encoding
605
+ class Utf8(object):
606
+ __slots__ = ['_tab']
607
+
608
+ @classmethod
609
+ def GetRootAs(cls, buf, offset=0):
610
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
611
+ x = Utf8()
612
+ x.Init(buf, n + offset)
613
+ return x
614
+
615
+ @classmethod
616
+ def GetRootAsUtf8(cls, buf, offset=0):
617
+ """This method is deprecated. Please switch to GetRootAs."""
618
+ return cls.GetRootAs(buf, offset)
619
+ # Utf8
620
+ def Init(self, buf, pos):
621
+ self._tab = flatbuffers.table.Table(buf, pos)
622
+
623
+ def Utf8Start(builder):
624
+ builder.StartObject(0)
625
+
626
+ def Utf8End(builder):
627
+ return builder.EndObject()
628
+
629
+
630
+
631
+ # Opaque binary data
632
+ class Binary(object):
633
+ __slots__ = ['_tab']
634
+
635
+ @classmethod
636
+ def GetRootAs(cls, buf, offset=0):
637
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
638
+ x = Binary()
639
+ x.Init(buf, n + offset)
640
+ return x
641
+
642
+ @classmethod
643
+ def GetRootAsBinary(cls, buf, offset=0):
644
+ """This method is deprecated. Please switch to GetRootAs."""
645
+ return cls.GetRootAs(buf, offset)
646
+ # Binary
647
+ def Init(self, buf, pos):
648
+ self._tab = flatbuffers.table.Table(buf, pos)
649
+
650
+ def BinaryStart(builder):
651
+ builder.StartObject(0)
652
+
653
+ def BinaryEnd(builder):
654
+ return builder.EndObject()
655
+
656
+
657
+
658
+ # Same as Utf8, but with 64-bit offsets, allowing to represent
659
+ # extremely large data values.
660
+ class LargeUtf8(object):
661
+ __slots__ = ['_tab']
662
+
663
+ @classmethod
664
+ def GetRootAs(cls, buf, offset=0):
665
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
666
+ x = LargeUtf8()
667
+ x.Init(buf, n + offset)
668
+ return x
669
+
670
+ @classmethod
671
+ def GetRootAsLargeUtf8(cls, buf, offset=0):
672
+ """This method is deprecated. Please switch to GetRootAs."""
673
+ return cls.GetRootAs(buf, offset)
674
+ # LargeUtf8
675
+ def Init(self, buf, pos):
676
+ self._tab = flatbuffers.table.Table(buf, pos)
677
+
678
+ def LargeUtf8Start(builder):
679
+ builder.StartObject(0)
680
+
681
+ def LargeUtf8End(builder):
682
+ return builder.EndObject()
683
+
684
+
685
+
686
+ # Same as Binary, but with 64-bit offsets, allowing to represent
687
+ # extremely large data values.
688
+ class LargeBinary(object):
689
+ __slots__ = ['_tab']
690
+
691
+ @classmethod
692
+ def GetRootAs(cls, buf, offset=0):
693
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
694
+ x = LargeBinary()
695
+ x.Init(buf, n + offset)
696
+ return x
697
+
698
+ @classmethod
699
+ def GetRootAsLargeBinary(cls, buf, offset=0):
700
+ """This method is deprecated. Please switch to GetRootAs."""
701
+ return cls.GetRootAs(buf, offset)
702
+ # LargeBinary
703
+ def Init(self, buf, pos):
704
+ self._tab = flatbuffers.table.Table(buf, pos)
705
+
706
+ def LargeBinaryStart(builder):
707
+ builder.StartObject(0)
708
+
709
+ def LargeBinaryEnd(builder):
710
+ return builder.EndObject()
711
+
712
+
713
+
714
+ # Logically the same as Utf8, but the internal representation uses a view
715
+ # struct that contains the string length and either the string's entire data
716
+ # inline (for small strings) or an inlined prefix, an index of another buffer,
717
+ # and an offset pointing to a slice in that buffer (for non-small strings).
718
+ #
719
+ # Since it uses a variable number of data buffers, each Field with this type
720
+ # must have a corresponding entry in `variadicBufferCounts`.
721
+ class Utf8View(object):
722
+ __slots__ = ['_tab']
723
+
724
+ @classmethod
725
+ def GetRootAs(cls, buf, offset=0):
726
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
727
+ x = Utf8View()
728
+ x.Init(buf, n + offset)
729
+ return x
730
+
731
+ @classmethod
732
+ def GetRootAsUtf8View(cls, buf, offset=0):
733
+ """This method is deprecated. Please switch to GetRootAs."""
734
+ return cls.GetRootAs(buf, offset)
735
+ # Utf8View
736
+ def Init(self, buf, pos):
737
+ self._tab = flatbuffers.table.Table(buf, pos)
738
+
739
+ def Utf8ViewStart(builder):
740
+ builder.StartObject(0)
741
+
742
+ def Utf8ViewEnd(builder):
743
+ return builder.EndObject()
744
+
745
+
746
+
747
+ # Logically the same as Binary, but the internal representation uses a view
748
+ # struct that contains the string length and either the string's entire data
749
+ # inline (for small strings) or an inlined prefix, an index of another buffer,
750
+ # and an offset pointing to a slice in that buffer (for non-small strings).
751
+ #
752
+ # Since it uses a variable number of data buffers, each Field with this type
753
+ # must have a corresponding entry in `variadicBufferCounts`.
754
+ class BinaryView(object):
755
+ __slots__ = ['_tab']
756
+
757
+ @classmethod
758
+ def GetRootAs(cls, buf, offset=0):
759
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
760
+ x = BinaryView()
761
+ x.Init(buf, n + offset)
762
+ return x
763
+
764
+ @classmethod
765
+ def GetRootAsBinaryView(cls, buf, offset=0):
766
+ """This method is deprecated. Please switch to GetRootAs."""
767
+ return cls.GetRootAs(buf, offset)
768
+ # BinaryView
769
+ def Init(self, buf, pos):
770
+ self._tab = flatbuffers.table.Table(buf, pos)
771
+
772
+ def BinaryViewStart(builder):
773
+ builder.StartObject(0)
774
+
775
+ def BinaryViewEnd(builder):
776
+ return builder.EndObject()
777
+
778
+
779
+
780
+ class FixedSizeBinary(object):
781
+ __slots__ = ['_tab']
782
+
783
+ @classmethod
784
+ def GetRootAs(cls, buf, offset=0):
785
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
786
+ x = FixedSizeBinary()
787
+ x.Init(buf, n + offset)
788
+ return x
789
+
790
+ @classmethod
791
+ def GetRootAsFixedSizeBinary(cls, buf, offset=0):
792
+ """This method is deprecated. Please switch to GetRootAs."""
793
+ return cls.GetRootAs(buf, offset)
794
+ # FixedSizeBinary
795
+ def Init(self, buf, pos):
796
+ self._tab = flatbuffers.table.Table(buf, pos)
797
+
798
+ # Number of bytes per value
799
+ # FixedSizeBinary
800
+ def ByteWidth(self):
801
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
802
+ if o != 0:
803
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
804
+ return 0
805
+
806
+ def FixedSizeBinaryStart(builder):
807
+ builder.StartObject(1)
808
+
809
+ def FixedSizeBinaryAddByteWidth(builder, byteWidth):
810
+ builder.PrependInt32Slot(0, byteWidth, 0)
811
+
812
+ def FixedSizeBinaryEnd(builder):
813
+ return builder.EndObject()
814
+
815
+
816
+
817
+ class Bool(object):
818
+ __slots__ = ['_tab']
819
+
820
+ @classmethod
821
+ def GetRootAs(cls, buf, offset=0):
822
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
823
+ x = Bool()
824
+ x.Init(buf, n + offset)
825
+ return x
826
+
827
+ @classmethod
828
+ def GetRootAsBool(cls, buf, offset=0):
829
+ """This method is deprecated. Please switch to GetRootAs."""
830
+ return cls.GetRootAs(buf, offset)
831
+ # Bool
832
+ def Init(self, buf, pos):
833
+ self._tab = flatbuffers.table.Table(buf, pos)
834
+
835
+ def BoolStart(builder):
836
+ builder.StartObject(0)
837
+
838
+ def BoolEnd(builder):
839
+ return builder.EndObject()
840
+
841
+
842
+
843
+ # Contains two child arrays, run_ends and values.
844
+ # The run_ends child array must be a 16/32/64-bit integer array
845
+ # which encodes the indices at which the run with the value in
846
+ # each corresponding index in the values child array ends.
847
+ # Like list/struct types, the value array can be of any type.
848
+ class RunEndEncoded(object):
849
+ __slots__ = ['_tab']
850
+
851
+ @classmethod
852
+ def GetRootAs(cls, buf, offset=0):
853
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
854
+ x = RunEndEncoded()
855
+ x.Init(buf, n + offset)
856
+ return x
857
+
858
+ @classmethod
859
+ def GetRootAsRunEndEncoded(cls, buf, offset=0):
860
+ """This method is deprecated. Please switch to GetRootAs."""
861
+ return cls.GetRootAs(buf, offset)
862
+ # RunEndEncoded
863
+ def Init(self, buf, pos):
864
+ self._tab = flatbuffers.table.Table(buf, pos)
865
+
866
+ def RunEndEncodedStart(builder):
867
+ builder.StartObject(0)
868
+
869
+ def RunEndEncodedEnd(builder):
870
+ return builder.EndObject()
871
+
872
+
873
+
874
+ # Exact decimal value represented as an integer value in two's
875
+ # complement. Currently 32-bit (4-byte), 64-bit (8-byte),
876
+ # 128-bit (16-byte) and 256-bit (32-byte) integers are used.
877
+ # The representation uses the endianness indicated in the Schema.
878
+ class Decimal(object):
879
+ __slots__ = ['_tab']
880
+
881
+ @classmethod
882
+ def GetRootAs(cls, buf, offset=0):
883
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
884
+ x = Decimal()
885
+ x.Init(buf, n + offset)
886
+ return x
887
+
888
+ @classmethod
889
+ def GetRootAsDecimal(cls, buf, offset=0):
890
+ """This method is deprecated. Please switch to GetRootAs."""
891
+ return cls.GetRootAs(buf, offset)
892
+ # Decimal
893
+ def Init(self, buf, pos):
894
+ self._tab = flatbuffers.table.Table(buf, pos)
895
+
896
+ # Total number of decimal digits
897
+ # Decimal
898
+ def Precision(self):
899
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
900
+ if o != 0:
901
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
902
+ return 0
903
+
904
+ # Number of digits after the decimal point "."
905
+ # Decimal
906
+ def Scale(self):
907
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
908
+ if o != 0:
909
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
910
+ return 0
911
+
912
+ # Number of bits per value. The accepted widths are 32, 64, 128 and 256.
913
+ # We use bitWidth for consistency with Int::bitWidth.
914
+ # Decimal
915
+ def BitWidth(self):
916
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
917
+ if o != 0:
918
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
919
+ return 128
920
+
921
+ def DecimalStart(builder):
922
+ builder.StartObject(3)
923
+
924
+ def DecimalAddPrecision(builder, precision):
925
+ builder.PrependInt32Slot(0, precision, 0)
926
+
927
+ def DecimalAddScale(builder, scale):
928
+ builder.PrependInt32Slot(1, scale, 0)
929
+
930
+ def DecimalAddBitWidth(builder, bitWidth):
931
+ builder.PrependInt32Slot(2, bitWidth, 128)
932
+
933
+ def DecimalEnd(builder):
934
+ return builder.EndObject()
935
+
936
+
937
+
938
+ # Date is either a 32-bit or 64-bit signed integer type representing an
939
+ # elapsed time since UNIX epoch (1970-01-01), stored in either of two units:
940
+ #
941
+ # * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no
942
+ # leap seconds), where the values are evenly divisible by 86400000
943
+ # * Days (32 bits) since the UNIX epoch
944
+ class Date(object):
945
+ __slots__ = ['_tab']
946
+
947
+ @classmethod
948
+ def GetRootAs(cls, buf, offset=0):
949
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
950
+ x = Date()
951
+ x.Init(buf, n + offset)
952
+ return x
953
+
954
+ @classmethod
955
+ def GetRootAsDate(cls, buf, offset=0):
956
+ """This method is deprecated. Please switch to GetRootAs."""
957
+ return cls.GetRootAs(buf, offset)
958
+ # Date
959
+ def Init(self, buf, pos):
960
+ self._tab = flatbuffers.table.Table(buf, pos)
961
+
962
+ # Date
963
+ def Unit(self):
964
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
965
+ if o != 0:
966
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
967
+ return 1
968
+
969
+ def DateStart(builder):
970
+ builder.StartObject(1)
971
+
972
+ def DateAddUnit(builder, unit):
973
+ builder.PrependInt16Slot(0, unit, 1)
974
+
975
+ def DateEnd(builder):
976
+ return builder.EndObject()
977
+
978
+
979
+
980
+ # Time is either a 32-bit or 64-bit signed integer type representing an
981
+ # elapsed time since midnight, stored in either of four units: seconds,
982
+ # milliseconds, microseconds or nanoseconds.
983
+ #
984
+ # The integer `bitWidth` depends on the `unit` and must be one of the following:
985
+ # * SECOND and MILLISECOND: 32 bits
986
+ # * MICROSECOND and NANOSECOND: 64 bits
987
+ #
988
+ # The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds
989
+ # (exclusive), adjusted for the time unit (for example, up to 86400000
990
+ # exclusive for the MILLISECOND unit).
991
+ # This definition doesn't allow for leap seconds. Time values from
992
+ # measurements with leap seconds will need to be corrected when ingesting
993
+ # into Arrow (for example by replacing the value 86400 with 86399).
994
+ class Time(object):
995
+ __slots__ = ['_tab']
996
+
997
+ @classmethod
998
+ def GetRootAs(cls, buf, offset=0):
999
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1000
+ x = Time()
1001
+ x.Init(buf, n + offset)
1002
+ return x
1003
+
1004
+ @classmethod
1005
+ def GetRootAsTime(cls, buf, offset=0):
1006
+ """This method is deprecated. Please switch to GetRootAs."""
1007
+ return cls.GetRootAs(buf, offset)
1008
+ # Time
1009
+ def Init(self, buf, pos):
1010
+ self._tab = flatbuffers.table.Table(buf, pos)
1011
+
1012
+ # Time
1013
+ def Unit(self):
1014
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1015
+ if o != 0:
1016
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1017
+ return 1
1018
+
1019
+ # Time
1020
+ def BitWidth(self):
1021
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1022
+ if o != 0:
1023
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
1024
+ return 32
1025
+
1026
+ def TimeStart(builder):
1027
+ builder.StartObject(2)
1028
+
1029
+ def TimeAddUnit(builder, unit):
1030
+ builder.PrependInt16Slot(0, unit, 1)
1031
+
1032
+ def TimeAddBitWidth(builder, bitWidth):
1033
+ builder.PrependInt32Slot(1, bitWidth, 32)
1034
+
1035
+ def TimeEnd(builder):
1036
+ return builder.EndObject()
1037
+
1038
+
1039
+
1040
+ # Timestamp is a 64-bit signed integer representing an elapsed time since a
1041
+ # fixed epoch, stored in either of four units: seconds, milliseconds,
1042
+ # microseconds or nanoseconds, and is optionally annotated with a timezone.
1043
+ #
1044
+ # Timestamp values do not include any leap seconds (in other words, all
1045
+ # days are considered 86400 seconds long).
1046
+ #
1047
+ # Timestamps with a non-empty timezone
1048
+ # ------------------------------------
1049
+ #
1050
+ # If a Timestamp column has a non-empty timezone value, its epoch is
1051
+ # 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone
1052
+ # (the Unix epoch), regardless of the Timestamp's own timezone.
1053
+ #
1054
+ # Therefore, timestamp values with a non-empty timezone correspond to
1055
+ # physical points in time together with some additional information about
1056
+ # how the data was obtained and/or how to display it (the timezone).
1057
+ #
1058
+ # For example, the timestamp value 0 with the timezone string "Europe/Paris"
1059
+ # corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the
1060
+ # application may prefer to display it as "January 1st 1970, 01h00" in
1061
+ # the Europe/Paris timezone (which is the same physical point in time).
1062
+ #
1063
+ # One consequence is that timestamp values with a non-empty timezone
1064
+ # can be compared and ordered directly, since they all share the same
1065
+ # well-known point of reference (the Unix epoch).
1066
+ #
1067
+ # Timestamps with an unset / empty timezone
1068
+ # -----------------------------------------
1069
+ #
1070
+ # If a Timestamp column has no timezone value, its epoch is
1071
+ # 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone.
1072
+ #
1073
+ # Therefore, timestamp values without a timezone cannot be meaningfully
1074
+ # interpreted as physical points in time, but only as calendar / clock
1075
+ # indications ("wall clock time") in an unspecified timezone.
1076
+ #
1077
+ # For example, the timestamp value 0 with an empty timezone string
1078
+ # corresponds to "January 1st 1970, 00h00" in an unknown timezone: there
1079
+ # is not enough information to interpret it as a well-defined physical
1080
+ # point in time.
1081
+ #
1082
+ # One consequence is that timestamp values without a timezone cannot
1083
+ # be reliably compared or ordered, since they may have different points of
1084
+ # reference. In particular, it is *not* possible to interpret an unset
1085
+ # or empty timezone as the same as "UTC".
1086
+ #
1087
+ # Conversion between timezones
1088
+ # ----------------------------
1089
+ #
1090
+ # If a Timestamp column has a non-empty timezone, changing the timezone
1091
+ # to a different non-empty value is a metadata-only operation:
1092
+ # the timestamp values need not change as their point of reference remains
1093
+ # the same (the Unix epoch).
1094
+ #
1095
+ # However, if a Timestamp column has no timezone value, changing it to a
1096
+ # non-empty value requires to think about the desired semantics.
1097
+ # One possibility is to assume that the original timestamp values are
1098
+ # relative to the epoch of the timezone being set; timestamp values should
1099
+ # then adjusted to the Unix epoch (for example, changing the timezone from
1100
+ # empty to "Europe/Paris" would require converting the timestamp values
1101
+ # from "Europe/Paris" to "UTC", which seems counter-intuitive but is
1102
+ # nevertheless correct).
1103
+ #
1104
+ # Guidelines for encoding data from external libraries
1105
+ # ----------------------------------------------------
1106
+ #
1107
+ # Date & time libraries often have multiple different data types for temporal
1108
+ # data. In order to ease interoperability between different implementations the
1109
+ # Arrow project has some recommendations for encoding these types into a Timestamp
1110
+ # column.
1111
+ #
1112
+ # An "instant" represents a physical point in time that has no relevant timezone
1113
+ # (for example, astronomical data). To encode an instant, use a Timestamp with
1114
+ # the timezone string set to "UTC", and make sure the Timestamp values
1115
+ # are relative to the UTC epoch (January 1st 1970, midnight).
1116
+ #
1117
+ # A "zoned date-time" represents a physical point in time annotated with an
1118
+ # informative timezone (for example, the timezone in which the data was
1119
+ # recorded). To encode a zoned date-time, use a Timestamp with the timezone
1120
+ # string set to the name of the timezone, and make sure the Timestamp values
1121
+ # are relative to the UTC epoch (January 1st 1970, midnight).
1122
+ #
1123
+ # (There is some ambiguity between an instant and a zoned date-time with the
1124
+ # UTC timezone. Both of these are stored the same in Arrow. Typically,
1125
+ # this distinction does not matter. If it does, then an application should
1126
+ # use custom metadata or an extension type to distinguish between the two cases.)
1127
+ #
1128
+ # An "offset date-time" represents a physical point in time combined with an
1129
+ # explicit offset from UTC. To encode an offset date-time, use a Timestamp
1130
+ # with the timezone string set to the numeric timezone offset string
1131
+ # (e.g. "+03:00"), and make sure the Timestamp values are relative to
1132
+ # the UTC epoch (January 1st 1970, midnight).
1133
+ #
1134
+ # A "naive date-time" (also called "local date-time" in some libraries)
1135
+ # represents a wall clock time combined with a calendar date, but with
1136
+ # no indication of how to map this information to a physical point in time.
1137
+ # Naive date-times must be handled with care because of this missing
1138
+ # information, and also because daylight saving time (DST) may make
1139
+ # some values ambiguous or nonexistent. A naive date-time may be
1140
+ # stored as a struct with Date and Time fields. However, it may also be
1141
+ # encoded into a Timestamp column with an empty timezone. The timestamp
1142
+ # values should be computed "as if" the timezone of the date-time values
1143
+ # was UTC; for example, the naive date-time "January 1st 1970, 00h00" would
1144
+ # be encoded as timestamp value 0.
1145
+ class Timestamp(object):
1146
+ __slots__ = ['_tab']
1147
+
1148
+ @classmethod
1149
+ def GetRootAs(cls, buf, offset=0):
1150
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1151
+ x = Timestamp()
1152
+ x.Init(buf, n + offset)
1153
+ return x
1154
+
1155
+ @classmethod
1156
+ def GetRootAsTimestamp(cls, buf, offset=0):
1157
+ """This method is deprecated. Please switch to GetRootAs."""
1158
+ return cls.GetRootAs(buf, offset)
1159
+ # Timestamp
1160
+ def Init(self, buf, pos):
1161
+ self._tab = flatbuffers.table.Table(buf, pos)
1162
+
1163
+ # Timestamp
1164
+ def Unit(self):
1165
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1166
+ if o != 0:
1167
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1168
+ return 0
1169
+
1170
+ # The timezone is an optional string indicating the name of a timezone,
1171
+ # one of:
1172
+ #
1173
+ # * As used in the Olson timezone database (the "tz database" or
1174
+ # "tzdata"), such as "America/New_York".
1175
+ # * An absolute timezone offset of the form "+XX:XX" or "-XX:XX",
1176
+ # such as "+07:30".
1177
+ #
1178
+ # Whether a timezone string is present indicates different semantics about
1179
+ # the data (see above).
1180
+ # Timestamp
1181
+ def Timezone(self):
1182
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1183
+ if o != 0:
1184
+ return self._tab.String(o + self._tab.Pos)
1185
+ return None
1186
+
1187
+ def TimestampStart(builder):
1188
+ builder.StartObject(2)
1189
+
1190
+ def TimestampAddUnit(builder, unit):
1191
+ builder.PrependInt16Slot(0, unit, 0)
1192
+
1193
+ def TimestampAddTimezone(builder, timezone):
1194
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(timezone), 0)
1195
+
1196
+ def TimestampEnd(builder):
1197
+ return builder.EndObject()
1198
+
1199
+
1200
+
1201
+ class Interval(object):
1202
+ __slots__ = ['_tab']
1203
+
1204
+ @classmethod
1205
+ def GetRootAs(cls, buf, offset=0):
1206
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1207
+ x = Interval()
1208
+ x.Init(buf, n + offset)
1209
+ return x
1210
+
1211
+ @classmethod
1212
+ def GetRootAsInterval(cls, buf, offset=0):
1213
+ """This method is deprecated. Please switch to GetRootAs."""
1214
+ return cls.GetRootAs(buf, offset)
1215
+ # Interval
1216
+ def Init(self, buf, pos):
1217
+ self._tab = flatbuffers.table.Table(buf, pos)
1218
+
1219
+ # Interval
1220
+ def Unit(self):
1221
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1222
+ if o != 0:
1223
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1224
+ return 0
1225
+
1226
+ def IntervalStart(builder):
1227
+ builder.StartObject(1)
1228
+
1229
+ def IntervalAddUnit(builder, unit):
1230
+ builder.PrependInt16Slot(0, unit, 0)
1231
+
1232
+ def IntervalEnd(builder):
1233
+ return builder.EndObject()
1234
+
1235
+
1236
+
1237
+ class Duration(object):
1238
+ __slots__ = ['_tab']
1239
+
1240
+ @classmethod
1241
+ def GetRootAs(cls, buf, offset=0):
1242
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1243
+ x = Duration()
1244
+ x.Init(buf, n + offset)
1245
+ return x
1246
+
1247
+ @classmethod
1248
+ def GetRootAsDuration(cls, buf, offset=0):
1249
+ """This method is deprecated. Please switch to GetRootAs."""
1250
+ return cls.GetRootAs(buf, offset)
1251
+ # Duration
1252
+ def Init(self, buf, pos):
1253
+ self._tab = flatbuffers.table.Table(buf, pos)
1254
+
1255
+ # Duration
1256
+ def Unit(self):
1257
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1258
+ if o != 0:
1259
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1260
+ return 1
1261
+
1262
+ def DurationStart(builder):
1263
+ builder.StartObject(1)
1264
+
1265
+ def DurationAddUnit(builder, unit):
1266
+ builder.PrependInt16Slot(0, unit, 1)
1267
+
1268
+ def DurationEnd(builder):
1269
+ return builder.EndObject()
1270
+
1271
+
1272
+
1273
+ # ----------------------------------------------------------------------
1274
+ # user defined key value pairs to add custom metadata to arrow
1275
+ # key namespacing is the responsibility of the user
1276
+ class KeyValue(object):
1277
+ __slots__ = ['_tab']
1278
+
1279
+ @classmethod
1280
+ def GetRootAs(cls, buf, offset=0):
1281
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1282
+ x = KeyValue()
1283
+ x.Init(buf, n + offset)
1284
+ return x
1285
+
1286
+ @classmethod
1287
+ def GetRootAsKeyValue(cls, buf, offset=0):
1288
+ """This method is deprecated. Please switch to GetRootAs."""
1289
+ return cls.GetRootAs(buf, offset)
1290
+ # KeyValue
1291
+ def Init(self, buf, pos):
1292
+ self._tab = flatbuffers.table.Table(buf, pos)
1293
+
1294
+ # KeyValue
1295
+ def Key(self):
1296
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1297
+ if o != 0:
1298
+ return self._tab.String(o + self._tab.Pos)
1299
+ return None
1300
+
1301
+ # KeyValue
1302
+ def Value(self):
1303
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1304
+ if o != 0:
1305
+ return self._tab.String(o + self._tab.Pos)
1306
+ return None
1307
+
1308
+ def KeyValueStart(builder):
1309
+ builder.StartObject(2)
1310
+
1311
+ def KeyValueAddKey(builder, key):
1312
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(key), 0)
1313
+
1314
+ def KeyValueAddValue(builder, value):
1315
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)
1316
+
1317
+ def KeyValueEnd(builder):
1318
+ return builder.EndObject()
1319
+
1320
+
1321
+
1322
+ class DictionaryEncoding(object):
1323
+ __slots__ = ['_tab']
1324
+
1325
+ @classmethod
1326
+ def GetRootAs(cls, buf, offset=0):
1327
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1328
+ x = DictionaryEncoding()
1329
+ x.Init(buf, n + offset)
1330
+ return x
1331
+
1332
+ @classmethod
1333
+ def GetRootAsDictionaryEncoding(cls, buf, offset=0):
1334
+ """This method is deprecated. Please switch to GetRootAs."""
1335
+ return cls.GetRootAs(buf, offset)
1336
+ # DictionaryEncoding
1337
+ def Init(self, buf, pos):
1338
+ self._tab = flatbuffers.table.Table(buf, pos)
1339
+
1340
+ # The known dictionary id in the application where this data is used. In
1341
+ # the file or streaming formats, the dictionary ids are found in the
1342
+ # DictionaryBatch messages
1343
+ # DictionaryEncoding
1344
+ def Id(self):
1345
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1346
+ if o != 0:
1347
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
1348
+ return 0
1349
+
1350
+ # The dictionary indices are constrained to be non-negative integers. If
1351
+ # this field is null, the indices must be signed int32. To maximize
1352
+ # cross-language compatibility and performance, implementations are
1353
+ # recommended to prefer signed integer types over unsigned integer types
1354
+ # and to avoid uint64 indices unless they are required by an application.
1355
+ # DictionaryEncoding
1356
+ def IndexType(self):
1357
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1358
+ if o != 0:
1359
+ x = self._tab.Indirect(o + self._tab.Pos)
1360
+ obj = Int()
1361
+ obj.Init(self._tab.Bytes, x)
1362
+ return obj
1363
+ return None
1364
+
1365
+ # By default, dictionaries are not ordered, or the order does not have
1366
+ # semantic meaning. In some statistical, applications, dictionary-encoding
1367
+ # is used to represent ordered categorical data, and we provide a way to
1368
+ # preserve that metadata here
1369
+ # DictionaryEncoding
1370
+ def IsOrdered(self):
1371
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1372
+ if o != 0:
1373
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
1374
+ return False
1375
+
1376
+ # DictionaryEncoding
1377
+ def DictionaryKind(self):
1378
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1379
+ if o != 0:
1380
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1381
+ return 0
1382
+
1383
+ def DictionaryEncodingStart(builder):
1384
+ builder.StartObject(4)
1385
+
1386
+ def DictionaryEncodingAddId(builder, id):
1387
+ builder.PrependInt64Slot(0, id, 0)
1388
+
1389
+ def DictionaryEncodingAddIndexType(builder, indexType):
1390
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(indexType), 0)
1391
+
1392
+ def DictionaryEncodingAddIsOrdered(builder, isOrdered):
1393
+ builder.PrependBoolSlot(2, isOrdered, 0)
1394
+
1395
+ def DictionaryEncodingAddDictionaryKind(builder, dictionaryKind):
1396
+ builder.PrependInt16Slot(3, dictionaryKind, 0)
1397
+
1398
+ def DictionaryEncodingEnd(builder):
1399
+ return builder.EndObject()
1400
+
1401
+
1402
+
1403
+ # ----------------------------------------------------------------------
1404
+ # A field represents a named column in a record / row batch or child of a
1405
+ # nested type.
1406
+ class Field(object):
1407
+ __slots__ = ['_tab']
1408
+
1409
+ @classmethod
1410
+ def GetRootAs(cls, buf, offset=0):
1411
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1412
+ x = Field()
1413
+ x.Init(buf, n + offset)
1414
+ return x
1415
+
1416
+ @classmethod
1417
+ def GetRootAsField(cls, buf, offset=0):
1418
+ """This method is deprecated. Please switch to GetRootAs."""
1419
+ return cls.GetRootAs(buf, offset)
1420
+ # Field
1421
+ def Init(self, buf, pos):
1422
+ self._tab = flatbuffers.table.Table(buf, pos)
1423
+
1424
+ # Name is not required, in i.e. a List
1425
+ # Field
1426
+ def Name(self):
1427
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1428
+ if o != 0:
1429
+ return self._tab.String(o + self._tab.Pos)
1430
+ return None
1431
+
1432
+ # Whether or not this field can contain nulls. Should be true in general.
1433
+ # Field
1434
+ def Nullable(self):
1435
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1436
+ if o != 0:
1437
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
1438
+ return False
1439
+
1440
+ # Field
1441
+ def TypeType(self):
1442
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1443
+ if o != 0:
1444
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
1445
+ return 0
1446
+
1447
+ # This is the type of the decoded value if the field is dictionary encoded.
1448
+ # Field
1449
+ def Type(self):
1450
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1451
+ if o != 0:
1452
+ from flatbuffers.table import Table
1453
+ obj = Table(bytearray(), 0)
1454
+ self._tab.Union(obj, o)
1455
+ return obj
1456
+ return None
1457
+
1458
+ # Present only if the field is dictionary encoded.
1459
+ # Field
1460
+ def Dictionary(self):
1461
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
1462
+ if o != 0:
1463
+ x = self._tab.Indirect(o + self._tab.Pos)
1464
+ obj = DictionaryEncoding()
1465
+ obj.Init(self._tab.Bytes, x)
1466
+ return obj
1467
+ return None
1468
+
1469
+ # children apply only to nested data types like Struct, List and Union. For
1470
+ # primitive types children will have length 0.
1471
+ # Field
1472
+ def Children(self, j):
1473
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
1474
+ if o != 0:
1475
+ x = self._tab.Vector(o)
1476
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1477
+ x = self._tab.Indirect(x)
1478
+ obj = Field()
1479
+ obj.Init(self._tab.Bytes, x)
1480
+ return obj
1481
+ return None
1482
+
1483
+ # Field
1484
+ def ChildrenLength(self):
1485
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
1486
+ if o != 0:
1487
+ return self._tab.VectorLen(o)
1488
+ return 0
1489
+
1490
+ # Field
1491
+ def ChildrenIsNone(self):
1492
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
1493
+ return o == 0
1494
+
1495
+ # User-defined metadata
1496
+ # Field
1497
+ def CustomMetadata(self, j):
1498
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
1499
+ if o != 0:
1500
+ x = self._tab.Vector(o)
1501
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1502
+ x = self._tab.Indirect(x)
1503
+ obj = KeyValue()
1504
+ obj.Init(self._tab.Bytes, x)
1505
+ return obj
1506
+ return None
1507
+
1508
+ # Field
1509
+ def CustomMetadataLength(self):
1510
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
1511
+ if o != 0:
1512
+ return self._tab.VectorLen(o)
1513
+ return 0
1514
+
1515
+ # Field
1516
+ def CustomMetadataIsNone(self):
1517
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
1518
+ return o == 0
1519
+
1520
+ def FieldStart(builder):
1521
+ builder.StartObject(7)
1522
+
1523
+ def FieldAddName(builder, name):
1524
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
1525
+
1526
+ def FieldAddNullable(builder, nullable):
1527
+ builder.PrependBoolSlot(1, nullable, 0)
1528
+
1529
+ def FieldAddTypeType(builder, typeType):
1530
+ builder.PrependUint8Slot(2, typeType, 0)
1531
+
1532
+ def FieldAddType(builder, type):
1533
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(type), 0)
1534
+
1535
+ def FieldAddDictionary(builder, dictionary):
1536
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(dictionary), 0)
1537
+
1538
+ def FieldAddChildren(builder, children):
1539
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(children), 0)
1540
+
1541
+ def FieldStartChildrenVector(builder, numElems):
1542
+ return builder.StartVector(4, numElems, 4)
1543
+
1544
+ def FieldAddCustomMetadata(builder, customMetadata):
1545
+ builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(customMetadata), 0)
1546
+
1547
+ def FieldStartCustomMetadataVector(builder, numElems):
1548
+ return builder.StartVector(4, numElems, 4)
1549
+
1550
+ def FieldEnd(builder):
1551
+ return builder.EndObject()
1552
+
1553
+
1554
+
1555
+ # ----------------------------------------------------------------------
1556
+ # A Buffer represents a single contiguous memory segment
1557
+ class Buffer(object):
1558
+ __slots__ = ['_tab']
1559
+
1560
+ @classmethod
1561
+ def SizeOf(cls):
1562
+ return 16
1563
+
1564
+ # Buffer
1565
+ def Init(self, buf, pos):
1566
+ self._tab = flatbuffers.table.Table(buf, pos)
1567
+
1568
+ # The relative offset into the shared memory page where the bytes for this
1569
+ # buffer starts
1570
+ # Buffer
1571
+ def Offset(self): return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
1572
+ # The absolute length (in bytes) of the memory buffer. The memory is found
1573
+ # from offset (inclusive) to offset + length (non-inclusive). When building
1574
+ # messages using the encapsulated IPC message, padding bytes may be written
1575
+ # after a buffer, but such padding bytes do not need to be accounted for in
1576
+ # the size here.
1577
+ # Buffer
1578
+ def Length(self): return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(8))
1579
+
1580
+ def CreateBuffer(builder, offset, length):
1581
+ builder.Prep(8, 16)
1582
+ builder.PrependInt64(length)
1583
+ builder.PrependInt64(offset)
1584
+ return builder.Offset()
1585
+
1586
+
1587
+ # ----------------------------------------------------------------------
1588
+ # A Schema describes the columns in a row batch
1589
+ class Schema(object):
1590
+ __slots__ = ['_tab']
1591
+
1592
+ @classmethod
1593
+ def GetRootAs(cls, buf, offset=0):
1594
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1595
+ x = Schema()
1596
+ x.Init(buf, n + offset)
1597
+ return x
1598
+
1599
+ @classmethod
1600
+ def GetRootAsSchema(cls, buf, offset=0):
1601
+ """This method is deprecated. Please switch to GetRootAs."""
1602
+ return cls.GetRootAs(buf, offset)
1603
+ # Schema
1604
+ def Init(self, buf, pos):
1605
+ self._tab = flatbuffers.table.Table(buf, pos)
1606
+
1607
+ # endianness of the buffer
1608
+ # it is Little Endian by default
1609
+ # if endianness doesn't match the underlying system then the vectors need to be converted
1610
+ # Schema
1611
+ def Endianness(self):
1612
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1613
+ if o != 0:
1614
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
1615
+ return 0
1616
+
1617
+ # Schema
1618
+ def Fields(self, j):
1619
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1620
+ if o != 0:
1621
+ x = self._tab.Vector(o)
1622
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1623
+ x = self._tab.Indirect(x)
1624
+ obj = Field()
1625
+ obj.Init(self._tab.Bytes, x)
1626
+ return obj
1627
+ return None
1628
+
1629
+ # Schema
1630
+ def FieldsLength(self):
1631
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1632
+ if o != 0:
1633
+ return self._tab.VectorLen(o)
1634
+ return 0
1635
+
1636
+ # Schema
1637
+ def FieldsIsNone(self):
1638
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1639
+ return o == 0
1640
+
1641
+ # Schema
1642
+ def CustomMetadata(self, j):
1643
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1644
+ if o != 0:
1645
+ x = self._tab.Vector(o)
1646
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1647
+ x = self._tab.Indirect(x)
1648
+ obj = KeyValue()
1649
+ obj.Init(self._tab.Bytes, x)
1650
+ return obj
1651
+ return None
1652
+
1653
+ # Schema
1654
+ def CustomMetadataLength(self):
1655
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1656
+ if o != 0:
1657
+ return self._tab.VectorLen(o)
1658
+ return 0
1659
+
1660
+ # Schema
1661
+ def CustomMetadataIsNone(self):
1662
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1663
+ return o == 0
1664
+
1665
+ # Features used in the stream/file.
1666
+ # Schema
1667
+ def Features(self, j):
1668
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1669
+ if o != 0:
1670
+ a = self._tab.Vector(o)
1671
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
1672
+ return 0
1673
+
1674
+ # Schema
1675
+ def FeaturesAsNumpy(self):
1676
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1677
+ if o != 0:
1678
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
1679
+ return 0
1680
+
1681
+ # Schema
1682
+ def FeaturesLength(self):
1683
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1684
+ if o != 0:
1685
+ return self._tab.VectorLen(o)
1686
+ return 0
1687
+
1688
+ # Schema
1689
+ def FeaturesIsNone(self):
1690
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1691
+ return o == 0
1692
+
1693
+ def SchemaStart(builder):
1694
+ builder.StartObject(4)
1695
+
1696
+ def SchemaAddEndianness(builder, endianness):
1697
+ builder.PrependInt16Slot(0, endianness, 0)
1698
+
1699
+ def SchemaAddFields(builder, fields):
1700
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(fields), 0)
1701
+
1702
+ def SchemaStartFieldsVector(builder, numElems):
1703
+ return builder.StartVector(4, numElems, 4)
1704
+
1705
+ def SchemaAddCustomMetadata(builder, customMetadata):
1706
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(customMetadata), 0)
1707
+
1708
+ def SchemaStartCustomMetadataVector(builder, numElems):
1709
+ return builder.StartVector(4, numElems, 4)
1710
+
1711
+ def SchemaAddFeatures(builder, features):
1712
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(features), 0)
1713
+
1714
+ def SchemaStartFeaturesVector(builder, numElems):
1715
+ return builder.StartVector(8, numElems, 8)
1716
+
1717
+ def SchemaEnd(builder):
1718
+ return builder.EndObject()
1719
+
1720
+
1721
+
1722
+ # ----------------------------------------------------------------------
1723
+ # Data structures for dense tensors
1724
+ # Shape data for a single axis in a tensor
1725
+ class TensorDim(object):
1726
+ __slots__ = ['_tab']
1727
+
1728
+ @classmethod
1729
+ def GetRootAs(cls, buf, offset=0):
1730
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1731
+ x = TensorDim()
1732
+ x.Init(buf, n + offset)
1733
+ return x
1734
+
1735
+ @classmethod
1736
+ def GetRootAsTensorDim(cls, buf, offset=0):
1737
+ """This method is deprecated. Please switch to GetRootAs."""
1738
+ return cls.GetRootAs(buf, offset)
1739
+ # TensorDim
1740
+ def Init(self, buf, pos):
1741
+ self._tab = flatbuffers.table.Table(buf, pos)
1742
+
1743
+ # Length of dimension
1744
+ # TensorDim
1745
+ def Size(self):
1746
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1747
+ if o != 0:
1748
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
1749
+ return 0
1750
+
1751
+ # Name of the dimension, optional
1752
+ # TensorDim
1753
+ def Name(self):
1754
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1755
+ if o != 0:
1756
+ return self._tab.String(o + self._tab.Pos)
1757
+ return None
1758
+
1759
+ def TensorDimStart(builder):
1760
+ builder.StartObject(2)
1761
+
1762
+ def TensorDimAddSize(builder, size):
1763
+ builder.PrependInt64Slot(0, size, 0)
1764
+
1765
+ def TensorDimAddName(builder, name):
1766
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
1767
+
1768
+ def TensorDimEnd(builder):
1769
+ return builder.EndObject()
1770
+
1771
+
1772
+
1773
+ class Tensor(object):
1774
+ __slots__ = ['_tab']
1775
+
1776
+ @classmethod
1777
+ def GetRootAs(cls, buf, offset=0):
1778
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1779
+ x = Tensor()
1780
+ x.Init(buf, n + offset)
1781
+ return x
1782
+
1783
+ @classmethod
1784
+ def GetRootAsTensor(cls, buf, offset=0):
1785
+ """This method is deprecated. Please switch to GetRootAs."""
1786
+ return cls.GetRootAs(buf, offset)
1787
+ # Tensor
1788
+ def Init(self, buf, pos):
1789
+ self._tab = flatbuffers.table.Table(buf, pos)
1790
+
1791
+ # Tensor
1792
+ def TypeType(self):
1793
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1794
+ if o != 0:
1795
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
1796
+ return 0
1797
+
1798
+ # The type of data contained in a value cell. Currently only fixed-width
1799
+ # value types are supported, no strings or nested types
1800
+ # Tensor
1801
+ def Type(self):
1802
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1803
+ if o != 0:
1804
+ from flatbuffers.table import Table
1805
+ obj = Table(bytearray(), 0)
1806
+ self._tab.Union(obj, o)
1807
+ return obj
1808
+ return None
1809
+
1810
+ # The dimensions of the tensor, optionally named
1811
+ # Tensor
1812
+ def Shape(self, j):
1813
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1814
+ if o != 0:
1815
+ x = self._tab.Vector(o)
1816
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1817
+ x = self._tab.Indirect(x)
1818
+ obj = TensorDim()
1819
+ obj.Init(self._tab.Bytes, x)
1820
+ return obj
1821
+ return None
1822
+
1823
+ # Tensor
1824
+ def ShapeLength(self):
1825
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1826
+ if o != 0:
1827
+ return self._tab.VectorLen(o)
1828
+ return 0
1829
+
1830
+ # Tensor
1831
+ def ShapeIsNone(self):
1832
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1833
+ return o == 0
1834
+
1835
+ # Non-negative byte offsets to advance one value cell along each dimension
1836
+ # If omitted, default to row-major order (C-like).
1837
+ # Tensor
1838
+ def Strides(self, j):
1839
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1840
+ if o != 0:
1841
+ a = self._tab.Vector(o)
1842
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
1843
+ return 0
1844
+
1845
+ # Tensor
1846
+ def StridesAsNumpy(self):
1847
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1848
+ if o != 0:
1849
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
1850
+ return 0
1851
+
1852
+ # Tensor
1853
+ def StridesLength(self):
1854
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1855
+ if o != 0:
1856
+ return self._tab.VectorLen(o)
1857
+ return 0
1858
+
1859
+ # Tensor
1860
+ def StridesIsNone(self):
1861
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
1862
+ return o == 0
1863
+
1864
+ # The location and size of the tensor's data
1865
+ # Tensor
1866
+ def Data(self):
1867
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
1868
+ if o != 0:
1869
+ x = o + self._tab.Pos
1870
+ obj = Buffer()
1871
+ obj.Init(self._tab.Bytes, x)
1872
+ return obj
1873
+ return None
1874
+
1875
+ def TensorStart(builder):
1876
+ builder.StartObject(5)
1877
+
1878
+ def TensorAddTypeType(builder, typeType):
1879
+ builder.PrependUint8Slot(0, typeType, 0)
1880
+
1881
+ def TensorAddType(builder, type):
1882
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(type), 0)
1883
+
1884
+ def TensorAddShape(builder, shape):
1885
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0)
1886
+
1887
+ def TensorStartShapeVector(builder, numElems):
1888
+ return builder.StartVector(4, numElems, 4)
1889
+
1890
+ def TensorAddStrides(builder, strides):
1891
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(strides), 0)
1892
+
1893
+ def TensorStartStridesVector(builder, numElems):
1894
+ return builder.StartVector(8, numElems, 8)
1895
+
1896
+ def TensorAddData(builder, data):
1897
+ builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
1898
+
1899
+ def TensorEnd(builder):
1900
+ return builder.EndObject()
1901
+
1902
+
1903
+
1904
+ # ----------------------------------------------------------------------
1905
+ # EXPERIMENTAL: Data structures for sparse tensors
1906
+ # Coordinate (COO) format of sparse tensor index.
1907
+ #
1908
+ # COO's index list are represented as a NxM matrix,
1909
+ # where N is the number of non-zero values,
1910
+ # and M is the number of dimensions of a sparse tensor.
1911
+ #
1912
+ # indicesBuffer stores the location and size of the data of this indices
1913
+ # matrix. The value type and the stride of the indices matrix is
1914
+ # specified in indicesType and indicesStrides fields.
1915
+ #
1916
+ # For example, let X be a 2x3x4x5 tensor, and it has the following
1917
+ # 6 non-zero values:
1918
+ # ```text
1919
+ # X[0, 1, 2, 0] := 1
1920
+ # X[1, 1, 2, 3] := 2
1921
+ # X[0, 2, 1, 0] := 3
1922
+ # X[0, 1, 3, 0] := 4
1923
+ # X[0, 1, 2, 1] := 5
1924
+ # X[1, 2, 0, 4] := 6
1925
+ # ```
1926
+ # In COO format, the index matrix of X is the following 4x6 matrix:
1927
+ # ```text
1928
+ # [[0, 0, 0, 0, 1, 1],
1929
+ # [1, 1, 1, 2, 1, 2],
1930
+ # [2, 2, 3, 1, 2, 0],
1931
+ # [0, 1, 0, 0, 3, 4]]
1932
+ # ```
1933
+ # When isCanonical is true, the indices is sorted in lexicographical order
1934
+ # (row-major order), and it does not have duplicated entries. Otherwise,
1935
+ # the indices may not be sorted, or may have duplicated entries.
1936
+ class SparseTensorIndexCOO(object):
1937
+ __slots__ = ['_tab']
1938
+
1939
+ @classmethod
1940
+ def GetRootAs(cls, buf, offset=0):
1941
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1942
+ x = SparseTensorIndexCOO()
1943
+ x.Init(buf, n + offset)
1944
+ return x
1945
+
1946
+ @classmethod
1947
+ def GetRootAsSparseTensorIndexCOO(cls, buf, offset=0):
1948
+ """This method is deprecated. Please switch to GetRootAs."""
1949
+ return cls.GetRootAs(buf, offset)
1950
+ # SparseTensorIndexCOO
1951
+ def Init(self, buf, pos):
1952
+ self._tab = flatbuffers.table.Table(buf, pos)
1953
+
1954
+ # The type of values in indicesBuffer
1955
+ # SparseTensorIndexCOO
1956
+ def IndicesType(self):
1957
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1958
+ if o != 0:
1959
+ x = self._tab.Indirect(o + self._tab.Pos)
1960
+ obj = Int()
1961
+ obj.Init(self._tab.Bytes, x)
1962
+ return obj
1963
+ return None
1964
+
1965
+ # Non-negative byte offsets to advance one value cell along each dimension
1966
+ # If omitted, default to row-major order (C-like).
1967
+ # SparseTensorIndexCOO
1968
+ def IndicesStrides(self, j):
1969
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1970
+ if o != 0:
1971
+ a = self._tab.Vector(o)
1972
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
1973
+ return 0
1974
+
1975
+ # SparseTensorIndexCOO
1976
+ def IndicesStridesAsNumpy(self):
1977
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1978
+ if o != 0:
1979
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
1980
+ return 0
1981
+
1982
+ # SparseTensorIndexCOO
1983
+ def IndicesStridesLength(self):
1984
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1985
+ if o != 0:
1986
+ return self._tab.VectorLen(o)
1987
+ return 0
1988
+
1989
+ # SparseTensorIndexCOO
1990
+ def IndicesStridesIsNone(self):
1991
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1992
+ return o == 0
1993
+
1994
+ # The location and size of the indices matrix's data
1995
+ # SparseTensorIndexCOO
1996
+ def IndicesBuffer(self):
1997
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
1998
+ if o != 0:
1999
+ x = o + self._tab.Pos
2000
+ obj = Buffer()
2001
+ obj.Init(self._tab.Bytes, x)
2002
+ return obj
2003
+ return None
2004
+
2005
+ # This flag is true if and only if the indices matrix is sorted in
2006
+ # row-major order, and does not have duplicated entries.
2007
+ # This sort order is the same as of Tensorflow's SparseTensor,
2008
+ # but it is inverse order of SciPy's canonical coo_matrix
2009
+ # (SciPy employs column-major order for its coo_matrix).
2010
+ # SparseTensorIndexCOO
2011
+ def IsCanonical(self):
2012
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2013
+ if o != 0:
2014
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
2015
+ return False
2016
+
2017
+ def SparseTensorIndexCOOStart(builder):
2018
+ builder.StartObject(4)
2019
+
2020
+ def SparseTensorIndexCOOAddIndicesType(builder, indicesType):
2021
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(indicesType), 0)
2022
+
2023
+ def SparseTensorIndexCOOAddIndicesStrides(builder, indicesStrides):
2024
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(indicesStrides), 0)
2025
+
2026
+ def SparseTensorIndexCOOStartIndicesStridesVector(builder, numElems):
2027
+ return builder.StartVector(8, numElems, 8)
2028
+
2029
+ def SparseTensorIndexCOOAddIndicesBuffer(builder, indicesBuffer):
2030
+ builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(indicesBuffer), 0)
2031
+
2032
+ def SparseTensorIndexCOOAddIsCanonical(builder, isCanonical):
2033
+ builder.PrependBoolSlot(3, isCanonical, 0)
2034
+
2035
+ def SparseTensorIndexCOOEnd(builder):
2036
+ return builder.EndObject()
2037
+
2038
+
2039
+
2040
+ # Compressed Sparse format, that is matrix-specific.
2041
+ class SparseMatrixIndexCSX(object):
2042
+ __slots__ = ['_tab']
2043
+
2044
+ @classmethod
2045
+ def GetRootAs(cls, buf, offset=0):
2046
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2047
+ x = SparseMatrixIndexCSX()
2048
+ x.Init(buf, n + offset)
2049
+ return x
2050
+
2051
+ @classmethod
2052
+ def GetRootAsSparseMatrixIndexCSX(cls, buf, offset=0):
2053
+ """This method is deprecated. Please switch to GetRootAs."""
2054
+ return cls.GetRootAs(buf, offset)
2055
+ # SparseMatrixIndexCSX
2056
+ def Init(self, buf, pos):
2057
+ self._tab = flatbuffers.table.Table(buf, pos)
2058
+
2059
+ # Which axis, row or column, is compressed
2060
+ # SparseMatrixIndexCSX
2061
+ def CompressedAxis(self):
2062
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2063
+ if o != 0:
2064
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
2065
+ return 0
2066
+
2067
+ # The type of values in indptrBuffer
2068
+ # SparseMatrixIndexCSX
2069
+ def IndptrType(self):
2070
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2071
+ if o != 0:
2072
+ x = self._tab.Indirect(o + self._tab.Pos)
2073
+ obj = Int()
2074
+ obj.Init(self._tab.Bytes, x)
2075
+ return obj
2076
+ return None
2077
+
2078
+ # indptrBuffer stores the location and size of indptr array that
2079
+ # represents the range of the rows.
2080
+ # The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
2081
+ # The length of this array is 1 + (the number of rows), and the type
2082
+ # of index value is long.
2083
+ #
2084
+ # For example, let X be the following 6x4 matrix:
2085
+ # ```text
2086
+ # X := [[0, 1, 2, 0],
2087
+ # [0, 0, 3, 0],
2088
+ # [0, 4, 0, 5],
2089
+ # [0, 0, 0, 0],
2090
+ # [6, 0, 7, 8],
2091
+ # [0, 9, 0, 0]].
2092
+ # ```
2093
+ # The array of non-zero values in X is:
2094
+ # ```text
2095
+ # values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
2096
+ # ```
2097
+ # And the indptr of X is:
2098
+ # ```text
2099
+ # indptr(X) = [0, 2, 3, 5, 5, 8, 10].
2100
+ # ```
2101
+ # SparseMatrixIndexCSX
2102
+ def IndptrBuffer(self):
2103
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2104
+ if o != 0:
2105
+ x = o + self._tab.Pos
2106
+ obj = Buffer()
2107
+ obj.Init(self._tab.Bytes, x)
2108
+ return obj
2109
+ return None
2110
+
2111
+ # The type of values in indicesBuffer
2112
+ # SparseMatrixIndexCSX
2113
+ def IndicesType(self):
2114
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2115
+ if o != 0:
2116
+ x = self._tab.Indirect(o + self._tab.Pos)
2117
+ obj = Int()
2118
+ obj.Init(self._tab.Bytes, x)
2119
+ return obj
2120
+ return None
2121
+
2122
+ # indicesBuffer stores the location and size of the array that
2123
+ # contains the column indices of the corresponding non-zero values.
2124
+ # The type of index value is long.
2125
+ #
2126
+ # For example, the indices of the above X is:
2127
+ # ```text
2128
+ # indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
2129
+ # ```
2130
+ # Note that the indices are sorted in lexicographical order for each row.
2131
+ # SparseMatrixIndexCSX
2132
+ def IndicesBuffer(self):
2133
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2134
+ if o != 0:
2135
+ x = o + self._tab.Pos
2136
+ obj = Buffer()
2137
+ obj.Init(self._tab.Bytes, x)
2138
+ return obj
2139
+ return None
2140
+
2141
+ def SparseMatrixIndexCSXStart(builder):
2142
+ builder.StartObject(5)
2143
+
2144
+ def SparseMatrixIndexCSXAddCompressedAxis(builder, compressedAxis):
2145
+ builder.PrependInt16Slot(0, compressedAxis, 0)
2146
+
2147
+ def SparseMatrixIndexCSXAddIndptrType(builder, indptrType):
2148
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(indptrType), 0)
2149
+
2150
+ def SparseMatrixIndexCSXAddIndptrBuffer(builder, indptrBuffer):
2151
+ builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(indptrBuffer), 0)
2152
+
2153
+ def SparseMatrixIndexCSXAddIndicesType(builder, indicesType):
2154
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(indicesType), 0)
2155
+
2156
+ def SparseMatrixIndexCSXAddIndicesBuffer(builder, indicesBuffer):
2157
+ builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(indicesBuffer), 0)
2158
+
2159
+ def SparseMatrixIndexCSXEnd(builder):
2160
+ return builder.EndObject()
2161
+
2162
+
2163
+
2164
+ # Compressed Sparse Fiber (CSF) sparse tensor index.
2165
+ class SparseTensorIndexCSF(object):
2166
+ __slots__ = ['_tab']
2167
+
2168
+ @classmethod
2169
+ def GetRootAs(cls, buf, offset=0):
2170
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2171
+ x = SparseTensorIndexCSF()
2172
+ x.Init(buf, n + offset)
2173
+ return x
2174
+
2175
+ @classmethod
2176
+ def GetRootAsSparseTensorIndexCSF(cls, buf, offset=0):
2177
+ """This method is deprecated. Please switch to GetRootAs."""
2178
+ return cls.GetRootAs(buf, offset)
2179
+ # SparseTensorIndexCSF
2180
+ def Init(self, buf, pos):
2181
+ self._tab = flatbuffers.table.Table(buf, pos)
2182
+
2183
+ # CSF is a generalization of compressed sparse row (CSR) index.
2184
+ # See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf)
2185
+ #
2186
+ # CSF index recursively compresses each dimension of a tensor into a set
2187
+ # of prefix trees. Each path from a root to leaf forms one tensor
2188
+ # non-zero index. CSF is implemented with two arrays of buffers and one
2189
+ # arrays of integers.
2190
+ #
2191
+ # For example, let X be a 2x3x4x5 tensor and let it have the following
2192
+ # 8 non-zero values:
2193
+ # ```text
2194
+ # X[0, 0, 0, 1] := 1
2195
+ # X[0, 0, 0, 2] := 2
2196
+ # X[0, 1, 0, 0] := 3
2197
+ # X[0, 1, 0, 2] := 4
2198
+ # X[0, 1, 1, 0] := 5
2199
+ # X[1, 1, 1, 0] := 6
2200
+ # X[1, 1, 1, 1] := 7
2201
+ # X[1, 1, 1, 2] := 8
2202
+ # ```
2203
+ # As a prefix tree this would be represented as:
2204
+ # ```text
2205
+ # 0 1
2206
+ # / \ |
2207
+ # 0 1 1
2208
+ # / / \ |
2209
+ # 0 0 1 1
2210
+ # /| /| | /| |
2211
+ # 1 2 0 2 0 0 1 2
2212
+ # ```
2213
+ # The type of values in indptrBuffers
2214
+ # SparseTensorIndexCSF
2215
+ def IndptrType(self):
2216
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2217
+ if o != 0:
2218
+ x = self._tab.Indirect(o + self._tab.Pos)
2219
+ obj = Int()
2220
+ obj.Init(self._tab.Bytes, x)
2221
+ return obj
2222
+ return None
2223
+
2224
+ # indptrBuffers stores the sparsity structure.
2225
+ # Each two consecutive dimensions in a tensor correspond to a buffer in
2226
+ # indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]`
2227
+ # and `indptrBuffers[dim][i + 1]` signify a range of nodes in
2228
+ # `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node.
2229
+ #
2230
+ # For example, the indptrBuffers for the above X is:
2231
+ # ```text
2232
+ # indptrBuffer(X) = [
2233
+ # [0, 2, 3],
2234
+ # [0, 1, 3, 4],
2235
+ # [0, 2, 4, 5, 8]
2236
+ # ].
2237
+ # ```
2238
+ # SparseTensorIndexCSF
2239
+ def IndptrBuffers(self, j):
2240
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2241
+ if o != 0:
2242
+ x = self._tab.Vector(o)
2243
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
2244
+ obj = Buffer()
2245
+ obj.Init(self._tab.Bytes, x)
2246
+ return obj
2247
+ return None
2248
+
2249
+ # SparseTensorIndexCSF
2250
+ def IndptrBuffersLength(self):
2251
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2252
+ if o != 0:
2253
+ return self._tab.VectorLen(o)
2254
+ return 0
2255
+
2256
+ # SparseTensorIndexCSF
2257
+ def IndptrBuffersIsNone(self):
2258
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2259
+ return o == 0
2260
+
2261
+ # The type of values in indicesBuffers
2262
+ # SparseTensorIndexCSF
2263
+ def IndicesType(self):
2264
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2265
+ if o != 0:
2266
+ x = self._tab.Indirect(o + self._tab.Pos)
2267
+ obj = Int()
2268
+ obj.Init(self._tab.Bytes, x)
2269
+ return obj
2270
+ return None
2271
+
2272
+ # indicesBuffers stores values of nodes.
2273
+ # Each tensor dimension corresponds to a buffer in indicesBuffers.
2274
+ # For example, the indicesBuffers for the above X is:
2275
+ # ```text
2276
+ # indicesBuffer(X) = [
2277
+ # [0, 1],
2278
+ # [0, 1, 1],
2279
+ # [0, 0, 1, 1],
2280
+ # [1, 2, 0, 2, 0, 0, 1, 2]
2281
+ # ].
2282
+ # ```
2283
+ # SparseTensorIndexCSF
2284
+ def IndicesBuffers(self, j):
2285
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2286
+ if o != 0:
2287
+ x = self._tab.Vector(o)
2288
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
2289
+ obj = Buffer()
2290
+ obj.Init(self._tab.Bytes, x)
2291
+ return obj
2292
+ return None
2293
+
2294
+ # SparseTensorIndexCSF
2295
+ def IndicesBuffersLength(self):
2296
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2297
+ if o != 0:
2298
+ return self._tab.VectorLen(o)
2299
+ return 0
2300
+
2301
+ # SparseTensorIndexCSF
2302
+ def IndicesBuffersIsNone(self):
2303
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2304
+ return o == 0
2305
+
2306
+ # axisOrder stores the sequence in which dimensions were traversed to
2307
+ # produce the prefix tree.
2308
+ # For example, the axisOrder for the above X is:
2309
+ # ```text
2310
+ # axisOrder(X) = [0, 1, 2, 3].
2311
+ # ```
2312
+ # SparseTensorIndexCSF
2313
+ def AxisOrder(self, j):
2314
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2315
+ if o != 0:
2316
+ a = self._tab.Vector(o)
2317
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
2318
+ return 0
2319
+
2320
+ # SparseTensorIndexCSF
2321
+ def AxisOrderAsNumpy(self):
2322
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2323
+ if o != 0:
2324
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
2325
+ return 0
2326
+
2327
+ # SparseTensorIndexCSF
2328
+ def AxisOrderLength(self):
2329
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2330
+ if o != 0:
2331
+ return self._tab.VectorLen(o)
2332
+ return 0
2333
+
2334
+ # SparseTensorIndexCSF
2335
+ def AxisOrderIsNone(self):
2336
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2337
+ return o == 0
2338
+
2339
+ def SparseTensorIndexCSFStart(builder):
2340
+ builder.StartObject(5)
2341
+
2342
+ def SparseTensorIndexCSFAddIndptrType(builder, indptrType):
2343
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(indptrType), 0)
2344
+
2345
+ def SparseTensorIndexCSFAddIndptrBuffers(builder, indptrBuffers):
2346
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(indptrBuffers), 0)
2347
+
2348
+ def SparseTensorIndexCSFStartIndptrBuffersVector(builder, numElems):
2349
+ return builder.StartVector(16, numElems, 8)
2350
+
2351
+ def SparseTensorIndexCSFAddIndicesType(builder, indicesType):
2352
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(indicesType), 0)
2353
+
2354
+ def SparseTensorIndexCSFAddIndicesBuffers(builder, indicesBuffers):
2355
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(indicesBuffers), 0)
2356
+
2357
+ def SparseTensorIndexCSFStartIndicesBuffersVector(builder, numElems):
2358
+ return builder.StartVector(16, numElems, 8)
2359
+
2360
+ def SparseTensorIndexCSFAddAxisOrder(builder, axisOrder):
2361
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(axisOrder), 0)
2362
+
2363
+ def SparseTensorIndexCSFStartAxisOrderVector(builder, numElems):
2364
+ return builder.StartVector(4, numElems, 4)
2365
+
2366
+ def SparseTensorIndexCSFEnd(builder):
2367
+ return builder.EndObject()
2368
+
2369
+
2370
+
2371
+ class SparseTensor(object):
2372
+ __slots__ = ['_tab']
2373
+
2374
+ @classmethod
2375
+ def GetRootAs(cls, buf, offset=0):
2376
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2377
+ x = SparseTensor()
2378
+ x.Init(buf, n + offset)
2379
+ return x
2380
+
2381
+ @classmethod
2382
+ def GetRootAsSparseTensor(cls, buf, offset=0):
2383
+ """This method is deprecated. Please switch to GetRootAs."""
2384
+ return cls.GetRootAs(buf, offset)
2385
+ # SparseTensor
2386
+ def Init(self, buf, pos):
2387
+ self._tab = flatbuffers.table.Table(buf, pos)
2388
+
2389
+ # SparseTensor
2390
+ def TypeType(self):
2391
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2392
+ if o != 0:
2393
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
2394
+ return 0
2395
+
2396
+ # The type of data contained in a value cell.
2397
+ # Currently only fixed-width value types are supported,
2398
+ # no strings or nested types.
2399
+ # SparseTensor
2400
+ def Type(self):
2401
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2402
+ if o != 0:
2403
+ from flatbuffers.table import Table
2404
+ obj = Table(bytearray(), 0)
2405
+ self._tab.Union(obj, o)
2406
+ return obj
2407
+ return None
2408
+
2409
+ # The dimensions of the tensor, optionally named.
2410
+ # SparseTensor
2411
+ def Shape(self, j):
2412
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2413
+ if o != 0:
2414
+ x = self._tab.Vector(o)
2415
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2416
+ x = self._tab.Indirect(x)
2417
+ obj = TensorDim()
2418
+ obj.Init(self._tab.Bytes, x)
2419
+ return obj
2420
+ return None
2421
+
2422
+ # SparseTensor
2423
+ def ShapeLength(self):
2424
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2425
+ if o != 0:
2426
+ return self._tab.VectorLen(o)
2427
+ return 0
2428
+
2429
+ # SparseTensor
2430
+ def ShapeIsNone(self):
2431
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2432
+ return o == 0
2433
+
2434
+ # The number of non-zero values in a sparse tensor.
2435
+ # SparseTensor
2436
+ def NonZeroLength(self):
2437
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2438
+ if o != 0:
2439
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
2440
+ return 0
2441
+
2442
+ # SparseTensor
2443
+ def SparseIndexType(self):
2444
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2445
+ if o != 0:
2446
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
2447
+ return 0
2448
+
2449
+ # Sparse tensor index
2450
+ # SparseTensor
2451
+ def SparseIndex(self):
2452
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2453
+ if o != 0:
2454
+ from flatbuffers.table import Table
2455
+ obj = Table(bytearray(), 0)
2456
+ self._tab.Union(obj, o)
2457
+ return obj
2458
+ return None
2459
+
2460
+ # The location and size of the tensor's data
2461
+ # SparseTensor
2462
+ def Data(self):
2463
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2464
+ if o != 0:
2465
+ x = o + self._tab.Pos
2466
+ obj = Buffer()
2467
+ obj.Init(self._tab.Bytes, x)
2468
+ return obj
2469
+ return None
2470
+
2471
+ def SparseTensorStart(builder):
2472
+ builder.StartObject(7)
2473
+
2474
+ def SparseTensorAddTypeType(builder, typeType):
2475
+ builder.PrependUint8Slot(0, typeType, 0)
2476
+
2477
+ def SparseTensorAddType(builder, type):
2478
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(type), 0)
2479
+
2480
+ def SparseTensorAddShape(builder, shape):
2481
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0)
2482
+
2483
+ def SparseTensorStartShapeVector(builder, numElems):
2484
+ return builder.StartVector(4, numElems, 4)
2485
+
2486
+ def SparseTensorAddNonZeroLength(builder, nonZeroLength):
2487
+ builder.PrependInt64Slot(3, nonZeroLength, 0)
2488
+
2489
+ def SparseTensorAddSparseIndexType(builder, sparseIndexType):
2490
+ builder.PrependUint8Slot(4, sparseIndexType, 0)
2491
+
2492
+ def SparseTensorAddSparseIndex(builder, sparseIndex):
2493
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(sparseIndex), 0)
2494
+
2495
+ def SparseTensorAddData(builder, data):
2496
+ builder.PrependStructSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
2497
+
2498
+ def SparseTensorEnd(builder):
2499
+ return builder.EndObject()
2500
+
2501
+
2502
+
2503
+ # ----------------------------------------------------------------------
2504
+ # Data structures for describing a table row batch (a collection of
2505
+ # equal-length Arrow arrays)
2506
+ # Metadata about a field at some level of a nested type tree (but not
2507
+ # its children).
2508
+ #
2509
+ # For example, a List<Int16> with values `[[1, 2, 3], null, [4], [5, 6], null]`
2510
+ # would have {length: 5, null_count: 2} for its List node, and {length: 6,
2511
+ # null_count: 0} for its Int16 node, as separate FieldNode structs
2512
+ class FieldNode(object):
2513
+ __slots__ = ['_tab']
2514
+
2515
+ @classmethod
2516
+ def SizeOf(cls):
2517
+ return 16
2518
+
2519
+ # FieldNode
2520
+ def Init(self, buf, pos):
2521
+ self._tab = flatbuffers.table.Table(buf, pos)
2522
+
2523
+ # The number of value slots in the Arrow array at this level of a nested
2524
+ # tree
2525
+ # FieldNode
2526
+ def Length(self): return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
2527
+ # The number of observed nulls. Fields with null_count == 0 may choose not
2528
+ # to write their physical validity bitmap out as a materialized buffer,
2529
+ # instead setting the length of the bitmap buffer to 0.
2530
+ # FieldNode
2531
+ def NullCount(self): return self._tab.Get(flatbuffers.number_types.Int64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(8))
2532
+
2533
+ def CreateFieldNode(builder, length, nullCount):
2534
+ builder.Prep(8, 16)
2535
+ builder.PrependInt64(nullCount)
2536
+ builder.PrependInt64(length)
2537
+ return builder.Offset()
2538
+
2539
+
2540
+ # Optional compression for the memory buffers constituting IPC message
2541
+ # bodies. Intended for use with RecordBatch but could be used for other
2542
+ # message types
2543
+ class BodyCompression(object):
2544
+ __slots__ = ['_tab']
2545
+
2546
+ @classmethod
2547
+ def GetRootAs(cls, buf, offset=0):
2548
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2549
+ x = BodyCompression()
2550
+ x.Init(buf, n + offset)
2551
+ return x
2552
+
2553
+ @classmethod
2554
+ def GetRootAsBodyCompression(cls, buf, offset=0):
2555
+ """This method is deprecated. Please switch to GetRootAs."""
2556
+ return cls.GetRootAs(buf, offset)
2557
+ # BodyCompression
2558
+ def Init(self, buf, pos):
2559
+ self._tab = flatbuffers.table.Table(buf, pos)
2560
+
2561
+ # Compressor library.
2562
+ # For LZ4_FRAME, each compressed buffer must consist of a single frame.
2563
+ # BodyCompression
2564
+ def Codec(self):
2565
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2566
+ if o != 0:
2567
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
2568
+ return 0
2569
+
2570
+ # Indicates the way the record batch body was compressed
2571
+ # BodyCompression
2572
+ def Method(self):
2573
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2574
+ if o != 0:
2575
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
2576
+ return 0
2577
+
2578
+ def BodyCompressionStart(builder):
2579
+ builder.StartObject(2)
2580
+
2581
+ def BodyCompressionAddCodec(builder, codec):
2582
+ builder.PrependInt8Slot(0, codec, 0)
2583
+
2584
+ def BodyCompressionAddMethod(builder, method):
2585
+ builder.PrependInt8Slot(1, method, 0)
2586
+
2587
+ def BodyCompressionEnd(builder):
2588
+ return builder.EndObject()
2589
+
2590
+
2591
+
2592
+ # A data header describing the shared memory layout of a "record" or "row"
2593
+ # batch. Some systems call this a "row batch" internally and others a "record
2594
+ # batch".
2595
+ class RecordBatch(object):
2596
+ __slots__ = ['_tab']
2597
+
2598
+ @classmethod
2599
+ def GetRootAs(cls, buf, offset=0):
2600
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2601
+ x = RecordBatch()
2602
+ x.Init(buf, n + offset)
2603
+ return x
2604
+
2605
+ @classmethod
2606
+ def GetRootAsRecordBatch(cls, buf, offset=0):
2607
+ """This method is deprecated. Please switch to GetRootAs."""
2608
+ return cls.GetRootAs(buf, offset)
2609
+ # RecordBatch
2610
+ def Init(self, buf, pos):
2611
+ self._tab = flatbuffers.table.Table(buf, pos)
2612
+
2613
+ # number of records / rows. The arrays in the batch should all have this
2614
+ # length
2615
+ # RecordBatch
2616
+ def Length(self):
2617
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2618
+ if o != 0:
2619
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
2620
+ return 0
2621
+
2622
+ # Nodes correspond to the pre-ordered flattened logical schema
2623
+ # RecordBatch
2624
+ def Nodes(self, j):
2625
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2626
+ if o != 0:
2627
+ x = self._tab.Vector(o)
2628
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
2629
+ obj = FieldNode()
2630
+ obj.Init(self._tab.Bytes, x)
2631
+ return obj
2632
+ return None
2633
+
2634
+ # RecordBatch
2635
+ def NodesLength(self):
2636
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2637
+ if o != 0:
2638
+ return self._tab.VectorLen(o)
2639
+ return 0
2640
+
2641
+ # RecordBatch
2642
+ def NodesIsNone(self):
2643
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2644
+ return o == 0
2645
+
2646
+ # Buffers correspond to the pre-ordered flattened buffer tree
2647
+ #
2648
+ # The number of buffers appended to this list depends on the schema. For
2649
+ # example, most primitive arrays will have 2 buffers, 1 for the validity
2650
+ # bitmap and 1 for the values. For struct arrays, there will only be a
2651
+ # single buffer for the validity (nulls) bitmap
2652
+ # RecordBatch
2653
+ def Buffers(self, j):
2654
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2655
+ if o != 0:
2656
+ x = self._tab.Vector(o)
2657
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
2658
+ obj = Buffer()
2659
+ obj.Init(self._tab.Bytes, x)
2660
+ return obj
2661
+ return None
2662
+
2663
+ # RecordBatch
2664
+ def BuffersLength(self):
2665
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2666
+ if o != 0:
2667
+ return self._tab.VectorLen(o)
2668
+ return 0
2669
+
2670
+ # RecordBatch
2671
+ def BuffersIsNone(self):
2672
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2673
+ return o == 0
2674
+
2675
+ # Optional compression of the message body
2676
+ # RecordBatch
2677
+ def Compression(self):
2678
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2679
+ if o != 0:
2680
+ x = self._tab.Indirect(o + self._tab.Pos)
2681
+ obj = BodyCompression()
2682
+ obj.Init(self._tab.Bytes, x)
2683
+ return obj
2684
+ return None
2685
+
2686
+ # Some types such as Utf8View are represented using a variable number of buffers.
2687
+ # For each such Field in the pre-ordered flattened logical schema, there will be
2688
+ # an entry in variadicBufferCounts to indicate the number of number of variadic
2689
+ # buffers which belong to that Field in the current RecordBatch.
2690
+ #
2691
+ # For example, the schema
2692
+ # col1: Struct<alpha: Int32, beta: BinaryView, gamma: Float64>
2693
+ # col2: Utf8View
2694
+ # contains two Fields with variadic buffers so variadicBufferCounts will have
2695
+ # two entries, the first counting the variadic buffers of `col1.beta` and the
2696
+ # second counting `col2`'s.
2697
+ #
2698
+ # This field may be omitted if and only if the schema contains no Fields with
2699
+ # a variable number of buffers, such as BinaryView and Utf8View.
2700
+ # RecordBatch
2701
+ def VariadicBufferCounts(self, j):
2702
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2703
+ if o != 0:
2704
+ a = self._tab.Vector(o)
2705
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
2706
+ return 0
2707
+
2708
+ # RecordBatch
2709
+ def VariadicBufferCountsAsNumpy(self):
2710
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2711
+ if o != 0:
2712
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int64Flags, o)
2713
+ return 0
2714
+
2715
+ # RecordBatch
2716
+ def VariadicBufferCountsLength(self):
2717
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2718
+ if o != 0:
2719
+ return self._tab.VectorLen(o)
2720
+ return 0
2721
+
2722
+ # RecordBatch
2723
+ def VariadicBufferCountsIsNone(self):
2724
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2725
+ return o == 0
2726
+
2727
+ def RecordBatchStart(builder):
2728
+ builder.StartObject(5)
2729
+
2730
+ def RecordBatchAddLength(builder, length):
2731
+ builder.PrependInt64Slot(0, length, 0)
2732
+
2733
+ def RecordBatchAddNodes(builder, nodes):
2734
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(nodes), 0)
2735
+
2736
+ def RecordBatchStartNodesVector(builder, numElems):
2737
+ return builder.StartVector(16, numElems, 8)
2738
+
2739
+ def RecordBatchAddBuffers(builder, buffers):
2740
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(buffers), 0)
2741
+
2742
+ def RecordBatchStartBuffersVector(builder, numElems):
2743
+ return builder.StartVector(16, numElems, 8)
2744
+
2745
+ def RecordBatchAddCompression(builder, compression):
2746
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(compression), 0)
2747
+
2748
+ def RecordBatchAddVariadicBufferCounts(builder, variadicBufferCounts):
2749
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(variadicBufferCounts), 0)
2750
+
2751
+ def RecordBatchStartVariadicBufferCountsVector(builder, numElems):
2752
+ return builder.StartVector(8, numElems, 8)
2753
+
2754
+ def RecordBatchEnd(builder):
2755
+ return builder.EndObject()
2756
+
2757
+
2758
+
2759
+ # For sending dictionary encoding information. Any Field can be
2760
+ # dictionary-encoded, but in this case none of its children may be
2761
+ # dictionary-encoded.
2762
+ # There is one vector / column per dictionary, but that vector / column
2763
+ # may be spread across multiple dictionary batches by using the isDelta
2764
+ # flag
2765
+ class DictionaryBatch(object):
2766
+ __slots__ = ['_tab']
2767
+
2768
+ @classmethod
2769
+ def GetRootAs(cls, buf, offset=0):
2770
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2771
+ x = DictionaryBatch()
2772
+ x.Init(buf, n + offset)
2773
+ return x
2774
+
2775
+ @classmethod
2776
+ def GetRootAsDictionaryBatch(cls, buf, offset=0):
2777
+ """This method is deprecated. Please switch to GetRootAs."""
2778
+ return cls.GetRootAs(buf, offset)
2779
+ # DictionaryBatch
2780
+ def Init(self, buf, pos):
2781
+ self._tab = flatbuffers.table.Table(buf, pos)
2782
+
2783
+ # DictionaryBatch
2784
+ def Id(self):
2785
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2786
+ if o != 0:
2787
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
2788
+ return 0
2789
+
2790
+ # DictionaryBatch
2791
+ def Data(self):
2792
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2793
+ if o != 0:
2794
+ x = self._tab.Indirect(o + self._tab.Pos)
2795
+ obj = RecordBatch()
2796
+ obj.Init(self._tab.Bytes, x)
2797
+ return obj
2798
+ return None
2799
+
2800
+ # If isDelta is true the values in the dictionary are to be appended to a
2801
+ # dictionary with the indicated id. If isDelta is false this dictionary
2802
+ # should replace the existing dictionary.
2803
+ # DictionaryBatch
2804
+ def IsDelta(self):
2805
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2806
+ if o != 0:
2807
+ return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
2808
+ return False
2809
+
2810
+ def DictionaryBatchStart(builder):
2811
+ builder.StartObject(3)
2812
+
2813
+ def DictionaryBatchAddId(builder, id):
2814
+ builder.PrependInt64Slot(0, id, 0)
2815
+
2816
+ def DictionaryBatchAddData(builder, data):
2817
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
2818
+
2819
+ def DictionaryBatchAddIsDelta(builder, isDelta):
2820
+ builder.PrependBoolSlot(2, isDelta, 0)
2821
+
2822
+ def DictionaryBatchEnd(builder):
2823
+ return builder.EndObject()
2824
+
2825
+
2826
+
2827
+ class Message(object):
2828
+ __slots__ = ['_tab']
2829
+
2830
+ @classmethod
2831
+ def GetRootAs(cls, buf, offset=0):
2832
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2833
+ x = Message()
2834
+ x.Init(buf, n + offset)
2835
+ return x
2836
+
2837
+ @classmethod
2838
+ def GetRootAsMessage(cls, buf, offset=0):
2839
+ """This method is deprecated. Please switch to GetRootAs."""
2840
+ return cls.GetRootAs(buf, offset)
2841
+ # Message
2842
+ def Init(self, buf, pos):
2843
+ self._tab = flatbuffers.table.Table(buf, pos)
2844
+
2845
+ # Message
2846
+ def Version(self):
2847
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2848
+ if o != 0:
2849
+ return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
2850
+ return 0
2851
+
2852
+ # Message
2853
+ def HeaderType(self):
2854
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2855
+ if o != 0:
2856
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
2857
+ return 0
2858
+
2859
+ # Message
2860
+ def Header(self):
2861
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2862
+ if o != 0:
2863
+ from flatbuffers.table import Table
2864
+ obj = Table(bytearray(), 0)
2865
+ self._tab.Union(obj, o)
2866
+ return obj
2867
+ return None
2868
+
2869
+ # Message
2870
+ def BodyLength(self):
2871
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2872
+ if o != 0:
2873
+ return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
2874
+ return 0
2875
+
2876
+ # Message
2877
+ def CustomMetadata(self, j):
2878
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2879
+ if o != 0:
2880
+ x = self._tab.Vector(o)
2881
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2882
+ x = self._tab.Indirect(x)
2883
+ obj = KeyValue()
2884
+ obj.Init(self._tab.Bytes, x)
2885
+ return obj
2886
+ return None
2887
+
2888
+ # Message
2889
+ def CustomMetadataLength(self):
2890
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2891
+ if o != 0:
2892
+ return self._tab.VectorLen(o)
2893
+ return 0
2894
+
2895
+ # Message
2896
+ def CustomMetadataIsNone(self):
2897
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2898
+ return o == 0
2899
+
2900
+ def MessageStart(builder):
2901
+ builder.StartObject(5)
2902
+
2903
+ def MessageAddVersion(builder, version):
2904
+ builder.PrependInt16Slot(0, version, 0)
2905
+
2906
+ def MessageAddHeaderType(builder, headerType):
2907
+ builder.PrependUint8Slot(1, headerType, 0)
2908
+
2909
+ def MessageAddHeader(builder, header):
2910
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(header), 0)
2911
+
2912
+ def MessageAddBodyLength(builder, bodyLength):
2913
+ builder.PrependInt64Slot(3, bodyLength, 0)
2914
+
2915
+ def MessageAddCustomMetadata(builder, customMetadata):
2916
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(customMetadata), 0)
2917
+
2918
+ def MessageStartCustomMetadataVector(builder, numElems):
2919
+ return builder.StartVector(4, numElems, 4)
2920
+
2921
+ def MessageEnd(builder):
2922
+ return builder.EndObject()
2923
+
2924
+
2925
+