# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

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

# An external source of tabular data
class Source(object):
    __slots__ = ['_tab']

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

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

    # An identifiier for the relation. The identifier should be unique over the
    # entire plan. Optional.
    # Source
    def Id(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vast_flatbuf.org.apache.arrow.computeir.flatbuf.RelId import RelId
            obj = RelId()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Source
    def Name(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # An optional expression used to filter out rows directly from the source.
    #
    # Useful for consumers that implement predicate pushdown.
    #
    # A missing filter value indicates no filter, i.e., all rows are
    # returned from the source.
    # Source
    def Filter(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vast_flatbuf.org.apache.arrow.computeir.flatbuf.Expression import Expression
            obj = Expression()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Schemas are explicitly optional
    # Source
    def Schema(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.Schema import Schema
            obj = Schema()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # An optional list of field indices indicating which columns should be read
    # from the source. Columns excluded from this listing will instead be replaced
    # with all-null placeholders to guarantee that the schema of the source is
    # unaffected by this projection.
    #
    # A missing value indicates all columns should be read.
    #
    # The behavior of an empty list is undefined.
    # Source
    def Projection(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 vast_flatbuf.org.apache.arrow.computeir.flatbuf.FieldIndex import FieldIndex
            obj = FieldIndex()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

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

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

def Start(builder): builder.StartObject(5)
def SourceStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddId(builder, id): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(id), 0)
def SourceAddId(builder, id):
    """This method is deprecated. Please switch to AddId."""
    return AddId(builder, id)
def AddName(builder, name): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def SourceAddName(builder, name):
    """This method is deprecated. Please switch to AddName."""
    return AddName(builder, name)
def AddFilter(builder, filter): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(filter), 0)
def SourceAddFilter(builder, filter):
    """This method is deprecated. Please switch to AddFilter."""
    return AddFilter(builder, filter)
def AddSchema(builder, schema): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(schema), 0)
def SourceAddSchema(builder, schema):
    """This method is deprecated. Please switch to AddSchema."""
    return AddSchema(builder, schema)
def AddProjection(builder, projection): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(projection), 0)
def SourceAddProjection(builder, projection):
    """This method is deprecated. Please switch to AddProjection."""
    return AddProjection(builder, projection)
def StartProjectionVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def SourceStartProjectionVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartProjectionVector(builder, numElems)
def End(builder): return builder.EndObject()
def SourceEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)