# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

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

class Message(object):
    __slots__ = ['_tab']

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

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

    # Message
    def Version(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
        return 0

    # Message
    def HeaderType(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

    # Message
    def Header(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            from flatbuffers.table import Table
            obj = Table(bytearray(), 0)
            self._tab.Union(obj, o)
            return obj
        return None

    # Message
    def BodyLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
        return 0

    # Message
    def CustomMetadata(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from vastdb.vast_flatbuf.org.apache.arrow.flatbuf.KeyValue import KeyValue
            obj = KeyValue()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Message
    def CustomMetadataLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Message
    def CustomMetadataIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        return o == 0

def Start(builder): builder.StartObject(5)
def MessageStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddVersion(builder, version): builder.PrependInt16Slot(0, version, 0)
def MessageAddVersion(builder, version):
    """This method is deprecated. Please switch to AddVersion."""
    return AddVersion(builder, version)
def AddHeaderType(builder, headerType): builder.PrependUint8Slot(1, headerType, 0)
def MessageAddHeaderType(builder, headerType):
    """This method is deprecated. Please switch to AddHeaderType."""
    return AddHeaderType(builder, headerType)
def AddHeader(builder, header): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(header), 0)
def MessageAddHeader(builder, header):
    """This method is deprecated. Please switch to AddHeader."""
    return AddHeader(builder, header)
def AddBodyLength(builder, bodyLength): builder.PrependInt64Slot(3, bodyLength, 0)
def MessageAddBodyLength(builder, bodyLength):
    """This method is deprecated. Please switch to AddBodyLength."""
    return AddBodyLength(builder, bodyLength)
def AddCustomMetadata(builder, customMetadata): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(customMetadata), 0)
def MessageAddCustomMetadata(builder, customMetadata):
    """This method is deprecated. Please switch to AddCustomMetadata."""
    return AddCustomMetadata(builder, customMetadata)
def StartCustomMetadataVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def MessageStartCustomMetadataVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartCustomMetadataVector(builder, numElems)
def End(builder): return builder.EndObject()
def MessageEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)