Class BatchData
- java.lang.Object
-
- org.apache.iotdb.tsfile.read.common.BatchData
-
- Direct Known Subclasses:
DescReadBatchData,SignalBatchData
public class BatchData extends java.lang.ObjectBatchDatais 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(); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBatchData.BatchDataType
-
Field Summary
Fields Modifier and Type Field Description protected BatchData.BatchDataTypebatchDataTypeprotected java.util.List<Binary[]>binaryRetprotected java.util.List<boolean[]>booleanRetprotected intcapacityprotected static intCAPACITY_THRESHOLDprotected intcountprotected TSDataTypedataTypeprotected java.util.List<double[]>doubleRetprotected java.util.List<float[]>floatRetprotected java.util.List<int[]>intRetprotected java.util.List<long[]>longRetprotected intreadCurArrayIndexprotected intreadCurListIndexprotected java.util.List<long[]>timeRetprotected java.util.List<TsPrimitiveType[][]>vectorRetprotected intwriteCurArrayIndexprotected intwriteCurListIndex
-
Constructor Summary
Constructors Constructor Description BatchData()BatchData(TSDataType type)BatchData Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcurrentTime()TsPrimitiveTypecurrentTsPrimitiveType()java.lang.ObjectcurrentValue()get current value.BatchDataflip()When put data, the writeIndex increases while the readIndex remains 0.org.apache.iotdb.tsfile.read.common.BatchData.BatchDataIteratorgetBatchDataIterator()IBatchDataIteratorgetBatchDataIterator(int subIndex)Only used for the batch data of vector time series.BatchData.BatchDataTypegetBatchDataType()BinarygetBinary()BinarygetBinaryByIndex(int idx)Get the idx th binary value by the time ascending orderbooleangetBoolean()booleangetBooleanByIndex(int idx)Get the idx th boolean value by the time ascending orderTSDataTypegetDataType()doublegetDouble()doublegetDoubleByIndex(int idx)Get the idx th double value by the time ascending orderfloatgetFloat()floatgetFloatByIndex(int idx)Get the idx th float value by the time ascending orderintgetInt()intgetIntByIndex(int idx)Get the idx th int value by the time ascending orderTimeValuePairgetLastPairBeforeOrEqualTimestamp(long queryTime)longgetLong()longgetLongByIndex(int idx)Get the idx th long value by the time ascending orderlonggetMaxTimestamp()longgetMinTimestamp()intgetReadCurArrayIndex()intgetReadCurListIndex()longgetTimeByIndex(int idx)Get the idx th timestamp by the time ascending orderjava.lang.ObjectgetValueInTimestamp(long time)TsPrimitiveType[]getVector()TsPrimitiveType[]getVectorByIndex(int idx)Get the idx th vector value by the time ascending orderbooleanhasCurrent()voidinit(TSDataType type)initialize batch data.booleanisEmpty()intlength()voidnext()voidputAnObject(long t, java.lang.Object v)put an object.voidputBinary(long t, Binary v)put binary data.voidputBoolean(long t, boolean v)put boolean data.voidputDouble(long t, double v)put double data.voidputFloat(long t, float v)put float data.voidputInt(long t, int v)put int data.voidputLong(long t, long v)put long data.voidputVector(long t, TsPrimitiveType[] v)put vector data.voidresetBatchData()This method is used to reset batch data when more than one group by aggregation functions visit the same batch datavoidresetBatchData(int readCurArrayIndex, int readCurListIndex)voidserializeData(java.io.DataOutputStream outputStream)For any implementation of BatchData, the data serializing sequence must equal the one of writing, otherwise after deserializing the sequence will be reversedvoidsetBinary(Binary v)voidsetBoolean(boolean v)voidsetDataType(TSDataType dataType)voidsetDouble(double v)voidsetFloat(float v)voidsetInt(int v)voidsetLong(long v)voidsetTime(long v)voidsetVector(TsPrimitiveType[] v)
-
-
-
Field Detail
-
CAPACITY_THRESHOLD
protected static final int CAPACITY_THRESHOLD
- See Also:
- Constant Field Values
-
capacity
protected int capacity
-
dataType
protected TSDataType dataType
-
batchDataType
protected BatchData.BatchDataType batchDataType
-
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
-
vectorRet
protected java.util.List<TsPrimitiveType[][]> vectorRet
-
-
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
-
currentTsPrimitiveType
public TsPrimitiveType currentTsPrimitiveType()
-
getDataType
public TSDataType getDataType()
-
setDataType
public void setDataType(TSDataType dataType)
-
getBatchDataType
public BatchData.BatchDataType getBatchDataType()
-
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- timestampv- boolean data
-
putInt
public void putInt(long t, int v)put int data.- Parameters:
t- timestampv- int data
-
putLong
public void putLong(long t, long v)put long data.- Parameters:
t- timestampv- long data
-
putFloat
public void putFloat(long t, float v)put float data.- Parameters:
t- timestampv- float data
-
putDouble
public void putDouble(long t, double v)put double data.- Parameters:
t- timestampv- double data
-
putBinary
public void putBinary(long t, Binary v)put binary data.- Parameters:
t- timestampv- binary data.
-
putVector
public void putVector(long t, TsPrimitiveType[] v)put vector data.- Parameters:
t- timestampv- 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)
-
getVector
public TsPrimitiveType[] getVector()
-
setVector
public void setVector(TsPrimitiveType[] v)
-
setTime
public void setTime(long v)
-
putAnObject
public void putAnObject(long t, java.lang.Object v)put an object.- Parameters:
t- timestampv- 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.IOExceptionFor 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.
-
-