Class BatchData

  • Direct Known Subclasses:
    DescReadBatchData, SignalBatchData

    public class BatchData
    extends java.lang.Object
    BatchData is a self-defined data structure which is optimized for different type of values. This class can be viewed as a collection which is more efficient than ArrayList.

    This class records a time list and a value list, which could be replaced by TVList in the future

    When you use BatchData in query process, it does not contain duplicated timestamps. The batch data may be empty.

    If you get a batch data, you can iterate the data as the following codes:

    while (batchData.hasCurrent()) { long time = batchData.currentTime(); Object value = batchData.currentValue(); batchData.next(); }

    • Field Detail

      • capacity

        protected int capacity
      • readCurListIndex

        protected int readCurListIndex
      • readCurArrayIndex

        protected int readCurArrayIndex
      • writeCurListIndex

        protected int writeCurListIndex
      • writeCurArrayIndex

        protected int writeCurArrayIndex
      • count

        protected int count
      • timeRet

        protected java.util.List<long[]> timeRet
      • booleanRet

        protected java.util.List<boolean[]> booleanRet
      • intRet

        protected java.util.List<int[]> intRet
      • longRet

        protected java.util.List<long[]> longRet
      • floatRet

        protected java.util.List<float[]> floatRet
      • doubleRet

        protected java.util.List<double[]> doubleRet
      • binaryRet

        protected java.util.List<Binary[]> binaryRet
    • Constructor Detail

      • BatchData

        public BatchData()
      • BatchData

        public BatchData​(TSDataType type)
        BatchData Constructor.
        Parameters:
        type - Data type to record for this BatchData
    • Method Detail

      • isEmpty

        public boolean isEmpty()
      • hasCurrent

        public boolean hasCurrent()
      • next

        public void next()
      • currentTime

        public long currentTime()
      • currentValue

        public java.lang.Object currentValue()
        get current value.
        Returns:
        current value
      • setDataType

        public void setDataType​(TSDataType dataType)
      • init

        public void init​(TSDataType type)
        initialize batch data.
        Parameters:
        type - TSDataType
      • putBoolean

        public void putBoolean​(long t,
                               boolean v)
        put boolean data.
        Parameters:
        t - timestamp
        v - boolean data
      • putInt

        public void putInt​(long t,
                           int v)
        put int data.
        Parameters:
        t - timestamp
        v - int data
      • putLong

        public void putLong​(long t,
                            long v)
        put long data.
        Parameters:
        t - timestamp
        v - long data
      • putFloat

        public void putFloat​(long t,
                             float v)
        put float data.
        Parameters:
        t - timestamp
        v - float data
      • putDouble

        public void putDouble​(long t,
                              double v)
        put double data.
        Parameters:
        t - timestamp
        v - double data
      • putBinary

        public void putBinary​(long t,
                              Binary v)
        put binary data.
        Parameters:
        t - timestamp
        v - binary data.
      • putVector

        public void putVector​(long t,
                              TsPrimitiveType[] v)
        put vector data.
        Parameters:
        t - timestamp
        v - vector data.
      • getBoolean

        public boolean getBoolean()
      • setBoolean

        public void setBoolean​(boolean v)
      • getInt

        public int getInt()
      • setInt

        public void setInt​(int v)
      • getLong

        public long getLong()
      • setLong

        public void setLong​(long v)
      • getFloat

        public float getFloat()
      • setFloat

        public void setFloat​(float v)
      • getDouble

        public double getDouble()
      • setDouble

        public void setDouble​(double v)
      • getBinary

        public Binary getBinary()
      • setBinary

        public void setBinary​(Binary v)
      • setTime

        public void setTime​(long v)
      • putAnObject

        public void putAnObject​(long t,
                                java.lang.Object v)
        put an object.
        Parameters:
        t - timestamp
        v - object
      • length

        public int length()
      • getTimeByIndex

        public long getTimeByIndex​(int idx)
        Get the idx th timestamp by the time ascending order
      • getLongByIndex

        public long getLongByIndex​(int idx)
        Get the idx th long value by the time ascending order
      • getDoubleByIndex

        public double getDoubleByIndex​(int idx)
        Get the idx th double value by the time ascending order
      • getIntByIndex

        public int getIntByIndex​(int idx)
        Get the idx th int value by the time ascending order
      • getFloatByIndex

        public float getFloatByIndex​(int idx)
        Get the idx th float value by the time ascending order
      • getBinaryByIndex

        public Binary getBinaryByIndex​(int idx)
        Get the idx th binary value by the time ascending order
      • getBooleanByIndex

        public boolean getBooleanByIndex​(int idx)
        Get the idx th boolean value by the time ascending order
      • getVectorByIndex

        public TsPrimitiveType[] getVectorByIndex​(int idx)
        Get the idx th vector value by the time ascending order
      • getLastPairBeforeOrEqualTimestamp

        public TimeValuePair getLastPairBeforeOrEqualTimestamp​(long queryTime)
      • getValueInTimestamp

        public java.lang.Object getValueInTimestamp​(long time)
      • getMaxTimestamp

        public long getMaxTimestamp()
      • getMinTimestamp

        public long getMinTimestamp()
      • getBatchDataIterator

        public org.apache.iotdb.tsfile.read.common.BatchData.BatchDataIterator getBatchDataIterator()
      • getBatchDataIterator

        public IBatchDataIterator getBatchDataIterator​(int subIndex)
        Only used for the batch data of vector time series.
      • serializeData

        public void serializeData​(java.io.DataOutputStream outputStream)
                           throws java.io.IOException
        For any implementation of BatchData, the data serializing sequence must equal the one of writing, otherwise after deserializing the sequence will be reversed
        Throws:
        java.io.IOException
      • resetBatchData

        public void resetBatchData()
        This method is used to reset batch data when more than one group by aggregation functions visit the same batch data
      • resetBatchData

        public void resetBatchData​(int readCurArrayIndex,
                                   int readCurListIndex)
      • getReadCurListIndex

        public int getReadCurListIndex()
      • getReadCurArrayIndex

        public int getReadCurArrayIndex()
      • flip

        public BatchData flip()
        When put data, the writeIndex increases while the readIndex remains 0. For ascending read, we could read from 0 to writeIndex. So no need to flip.