# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A data header describing the shared memory layout of a "record" or "row"
# batch. Some systems call this a "row batch" internally and others a "record
# batch".
class RecordBatch(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = RecordBatch()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsRecordBatch(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # RecordBatch
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # number of records / rows. The arrays in the batch should all have this
    # length
    # RecordBatch
    def Length(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
        return 0

    # Nodes correspond to the pre-ordered flattened logical schema
    # RecordBatch
    def Nodes(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
            from vast_flatbuf.org.apache.arrow.flatbuf.FieldNode import FieldNode
            obj = FieldNode()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # RecordBatch
    def NodesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # RecordBatch
    def NodesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # Buffers correspond to the pre-ordered flattened buffer tree
    #
    # The number of buffers appended to this list depends on the schema. For
    # example, most primitive arrays will have 2 buffers, 1 for the validity
    # bitmap and 1 for the values. For struct arrays, there will only be a
    # single buffer for the validity (nulls) bitmap
    # RecordBatch
    def Buffers(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 16
            from vast_flatbuf.org.apache.arrow.flatbuf.Buffer import Buffer
            obj = Buffer()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # RecordBatch
    def BuffersLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # RecordBatch
    def BuffersIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # Optional compression of the message body
    # RecordBatch
    def Compression(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vast_flatbuf.org.apache.arrow.flatbuf.BodyCompression import BodyCompression
            obj = BodyCompression()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def Start(builder): builder.StartObject(4)
def RecordBatchStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddLength(builder, length): builder.PrependInt64Slot(0, length, 0)
def RecordBatchAddLength(builder, length):
    """This method is deprecated. Please switch to AddLength."""
    return AddLength(builder, length)
def AddNodes(builder, nodes): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(nodes), 0)
def RecordBatchAddNodes(builder, nodes):
    """This method is deprecated. Please switch to AddNodes."""
    return AddNodes(builder, nodes)
def StartNodesVector(builder, numElems): return builder.StartVector(16, numElems, 8)
def RecordBatchStartNodesVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartNodesVector(builder, numElems)
def AddBuffers(builder, buffers): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(buffers), 0)
def RecordBatchAddBuffers(builder, buffers):
    """This method is deprecated. Please switch to AddBuffers."""
    return AddBuffers(builder, buffers)
def StartBuffersVector(builder, numElems): return builder.StartVector(16, numElems, 8)
def RecordBatchStartBuffersVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartBuffersVector(builder, numElems)
def AddCompression(builder, compression): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(compression), 0)
def RecordBatchAddCompression(builder, compression):
    """This method is deprecated. Please switch to AddCompression."""
    return AddCompression(builder, compression)
def End(builder): return builder.EndObject()
def RecordBatchEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)