# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

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

# Compressed Sparse format, that is matrix-specific.
class SparseMatrixIndexCSX(object):
    __slots__ = ['_tab']

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

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

    # Which axis, row or column, is compressed
    # SparseMatrixIndexCSX
    def CompressedAxis(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

    # The type of values in indptrBuffer
    # SparseMatrixIndexCSX
    def IndptrType(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vast_flatbuf.org.apache.arrow.flatbuf.Int import Int
            obj = Int()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # indptrBuffer stores the location and size of indptr array that
    # represents the range of the rows.
    # The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
    # The length of this array is 1 + (the number of rows), and the type
    # of index value is long.
    #
    # For example, let X be the following 6x4 matrix:
    # ```text
    #   X := [[0, 1, 2, 0],
    #         [0, 0, 3, 0],
    #         [0, 4, 0, 5],
    #         [0, 0, 0, 0],
    #         [6, 0, 7, 8],
    #         [0, 9, 0, 0]].
    # ```
    # The array of non-zero values in X is:
    # ```text
    #   values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
    # ```
    # And the indptr of X is:
    # ```text
    #   indptr(X) = [0, 2, 3, 5, 5, 8, 10].
    # ```
    # SparseMatrixIndexCSX
    def IndptrBuffer(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = o + self._tab.Pos
            from vast_flatbuf.org.apache.arrow.flatbuf.Buffer import Buffer
            obj = Buffer()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # The type of values in indicesBuffer
    # SparseMatrixIndexCSX
    def IndicesType(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.Int import Int
            obj = Int()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # indicesBuffer stores the location and size of the array that
    # contains the column indices of the corresponding non-zero values.
    # The type of index value is long.
    #
    # For example, the indices of the above X is:
    # ```text
    #   indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
    # ```
    # Note that the indices are sorted in lexicographical order for each row.
    # SparseMatrixIndexCSX
    def IndicesBuffer(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = o + self._tab.Pos
            from vast_flatbuf.org.apache.arrow.flatbuf.Buffer import Buffer
            obj = Buffer()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def Start(builder): builder.StartObject(5)
def SparseMatrixIndexCSXStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddCompressedAxis(builder, compressedAxis): builder.PrependInt16Slot(0, compressedAxis, 0)
def SparseMatrixIndexCSXAddCompressedAxis(builder, compressedAxis):
    """This method is deprecated. Please switch to AddCompressedAxis."""
    return AddCompressedAxis(builder, compressedAxis)
def AddIndptrType(builder, indptrType): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(indptrType), 0)
def SparseMatrixIndexCSXAddIndptrType(builder, indptrType):
    """This method is deprecated. Please switch to AddIndptrType."""
    return AddIndptrType(builder, indptrType)
def AddIndptrBuffer(builder, indptrBuffer): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(indptrBuffer), 0)
def SparseMatrixIndexCSXAddIndptrBuffer(builder, indptrBuffer):
    """This method is deprecated. Please switch to AddIndptrBuffer."""
    return AddIndptrBuffer(builder, indptrBuffer)
def AddIndicesType(builder, indicesType): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(indicesType), 0)
def SparseMatrixIndexCSXAddIndicesType(builder, indicesType):
    """This method is deprecated. Please switch to AddIndicesType."""
    return AddIndicesType(builder, indicesType)
def AddIndicesBuffer(builder, indicesBuffer): builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(indicesBuffer), 0)
def SparseMatrixIndexCSXAddIndicesBuffer(builder, indicesBuffer):
    """This method is deprecated. Please switch to AddIndicesBuffer."""
    return AddIndicesBuffer(builder, indicesBuffer)
def End(builder): return builder.EndObject()
def SparseMatrixIndexCSXEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)