public class BatchData extends 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(); }
| Modifier and Type | Class and Description |
|---|---|
static class |
BatchData.BatchDataType |
| Modifier and Type | Field and Description |
|---|---|
protected BatchData.BatchDataType |
batchDataType |
protected List<Binary[]> |
binaryRet |
protected List<boolean[]> |
booleanRet |
protected int |
capacity |
protected static int |
CAPACITY_THRESHOLD |
protected int |
count |
protected TSDataType |
dataType |
protected List<double[]> |
doubleRet |
protected List<float[]> |
floatRet |
protected List<int[]> |
intRet |
protected List<long[]> |
longRet |
protected int |
readCurArrayIndex |
protected int |
readCurListIndex |
protected List<long[]> |
timeRet |
protected List<TsPrimitiveType[][]> |
vectorRet |
protected int |
writeCurArrayIndex |
protected int |
writeCurListIndex |
| Constructor and Description |
|---|
BatchData() |
BatchData(TSDataType type)
BatchData Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
currentTime() |
TsPrimitiveType |
currentTsPrimitiveType() |
Object |
currentValue()
get current value.
|
BatchData |
flip()
When put data, the writeIndex increases while the readIndex remains 0.
|
org.apache.iotdb.tsfile.read.common.BatchData.BatchDataIterator |
getBatchDataIterator() |
IBatchDataIterator |
getBatchDataIterator(int subIndex)
Only used for the batch data of vector time series.
|
BatchData.BatchDataType |
getBatchDataType() |
Binary |
getBinary() |
Binary |
getBinaryByIndex(int idx)
Get the idx th binary value by the time ascending order
|
boolean |
getBoolean() |
boolean |
getBooleanByIndex(int idx)
Get the idx th boolean value by the time ascending order
|
TSDataType |
getDataType() |
double |
getDouble() |
double |
getDoubleByIndex(int idx)
Get the idx th double value by the time ascending order
|
float |
getFloat() |
float |
getFloatByIndex(int idx)
Get the idx th float value by the time ascending order
|
int |
getInt() |
int |
getIntByIndex(int idx)
Get the idx th int value by the time ascending order
|
TimeValuePair |
getLastPairBeforeOrEqualTimestamp(long queryTime) |
long |
getLong() |
long |
getLongByIndex(int idx)
Get the idx th long value by the time ascending order
|
long |
getMaxTimestamp() |
long |
getMinTimestamp() |
int |
getReadCurArrayIndex() |
int |
getReadCurListIndex() |
long |
getTimeByIndex(int idx)
Get the idx th timestamp by the time ascending order
|
Object |
getValueInTimestamp(long time) |
TsPrimitiveType[] |
getVector() |
TsPrimitiveType[] |
getVectorByIndex(int idx)
Get the idx th vector value by the time ascending order
|
boolean |
hasCurrent() |
void |
init(TSDataType type)
initialize batch data.
|
boolean |
isEmpty() |
int |
length() |
void |
next() |
void |
putAnObject(long t,
Object v)
put an object.
|
void |
putBinary(long t,
Binary v)
put binary data.
|
void |
putBoolean(long t,
boolean v)
put boolean data.
|
void |
putDouble(long t,
double v)
put double data.
|
void |
putFloat(long t,
float v)
put float data.
|
void |
putInt(long t,
int v)
put int data.
|
void |
putLong(long t,
long v)
put long data.
|
void |
putVector(long t,
TsPrimitiveType[] v)
put vector data.
|
void |
resetBatchData()
This method is used to reset batch data when more than one group by aggregation functions visit
the same batch data
|
void |
resetBatchData(int readCurArrayIndex,
int readCurListIndex) |
void |
serializeData(DataOutputStream outputStream)
For any implementation of BatchData, the data serializing sequence must equal the one of
writing, otherwise after deserializing the sequence will be reversed
|
void |
setBinary(Binary v) |
void |
setBoolean(boolean v) |
void |
setDataType(TSDataType dataType) |
void |
setDouble(double v) |
void |
setFloat(float v) |
void |
setInt(int v) |
void |
setLong(long v) |
void |
setTime(long v) |
void |
setVector(TsPrimitiveType[] v) |
protected static final int CAPACITY_THRESHOLD
protected int capacity
protected TSDataType dataType
protected BatchData.BatchDataType batchDataType
protected int readCurListIndex
protected int readCurArrayIndex
protected int writeCurListIndex
protected int writeCurArrayIndex
protected int count
protected List<long[]> timeRet
protected List<boolean[]> booleanRet
protected List<int[]> intRet
protected List<long[]> longRet
protected List<float[]> floatRet
protected List<double[]> doubleRet
protected List<TsPrimitiveType[][]> vectorRet
public BatchData()
public BatchData(TSDataType type)
type - Data type to record for this BatchDatapublic boolean isEmpty()
public boolean hasCurrent()
public void next()
public long currentTime()
public Object currentValue()
public TsPrimitiveType currentTsPrimitiveType()
public TSDataType getDataType()
public void setDataType(TSDataType dataType)
public BatchData.BatchDataType getBatchDataType()
public void init(TSDataType type)
type - TSDataTypepublic void putBoolean(long t,
boolean v)
t - timestampv - boolean datapublic void putInt(long t,
int v)
t - timestampv - int datapublic void putLong(long t,
long v)
t - timestampv - long datapublic void putFloat(long t,
float v)
t - timestampv - float datapublic void putDouble(long t,
double v)
t - timestampv - double datapublic void putBinary(long t,
Binary v)
t - timestampv - binary data.public void putVector(long t,
TsPrimitiveType[] v)
t - timestampv - vector data.public boolean getBoolean()
public void setBoolean(boolean v)
public int getInt()
public void setInt(int v)
public long getLong()
public void setLong(long v)
public float getFloat()
public void setFloat(float v)
public double getDouble()
public void setDouble(double v)
public Binary getBinary()
public void setBinary(Binary v)
public TsPrimitiveType[] getVector()
public void setVector(TsPrimitiveType[] v)
public void setTime(long v)
public void putAnObject(long t,
Object v)
t - timestampv - objectpublic int length()
public long getTimeByIndex(int idx)
public long getLongByIndex(int idx)
public double getDoubleByIndex(int idx)
public int getIntByIndex(int idx)
public float getFloatByIndex(int idx)
public Binary getBinaryByIndex(int idx)
public boolean getBooleanByIndex(int idx)
public TsPrimitiveType[] getVectorByIndex(int idx)
public TimeValuePair getLastPairBeforeOrEqualTimestamp(long queryTime)
public Object getValueInTimestamp(long time)
public long getMaxTimestamp()
public long getMinTimestamp()
public org.apache.iotdb.tsfile.read.common.BatchData.BatchDataIterator getBatchDataIterator()
public IBatchDataIterator getBatchDataIterator(int subIndex)
public void serializeData(DataOutputStream outputStream) throws IOException
IOExceptionpublic void resetBatchData()
public void resetBatchData(int readCurArrayIndex,
int readCurListIndex)
public int getReadCurListIndex()
public int getReadCurArrayIndex()
public BatchData flip()
Copyright © 2022 The Apache Software Foundation. All rights reserved.