Class AggregateResult
- java.lang.Object
-
- org.apache.iotdb.db.query.aggregation.AggregateResult
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
AvgAggrResult,CountAggrResult,ExtremeAggrResult,FirstValueAggrResult,LastValueAggrResult,MaxTimeAggrResult,MaxValueAggrResult,MinTimeAggrResult,MinValueAggrResult,SumAggrResult
public abstract class AggregateResult extends java.lang.Object implements java.lang.Cloneable
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanhasCandidateResultprotected org.apache.iotdb.tsfile.file.metadata.enums.TSDataTyperesultDataTypestatic intTIME_LENGTH_FOR_FIRST_VALUEprotected longtimestampFor [COUNT, AVG, SUM], it is the start time of the aggregation window.
-
Constructor Summary
Constructors Constructor Description AggregateResult(org.apache.iotdb.tsfile.file.metadata.enums.TSDataType resultDataType, AggregationType aggregationType)construct.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AggregateResultclone()static AggregateResultdeserializeFrom(java.nio.ByteBuffer buffer)protected abstract voiddeserializeSpecificFields(java.nio.ByteBuffer buffer)AggregationTypegetAggregationType()protected org.apache.iotdb.tsfile.utils.BinarygetBinaryValue()protected booleangetBooleanValue()doublegetDoubleAbsValue()doublegetDoubleValue()floatgetFloatAbsValue()floatgetFloatValue()intgetIntAbsValue()intgetIntValue()longgetLongAbsValue()longgetLongValue()abstract java.lang.ObjectgetResult()org.apache.iotdb.tsfile.file.metadata.enums.TSDataTypegetResultDataType()longgetTime()protected java.lang.ObjectgetValue()protected booleanhasCandidateResult()abstract booleanhasFinalResult()Judge if aggregation results have been calculated.booleanisAscending()Whether the AggregationResult accepts data in time ascending order, if it returns false, the data should be passed in time descending order.abstract voidmerge(AggregateResult another)Merge another aggregateResult into thisvoidreset()voidserialize(java.nio.ByteBuffer byteBuffer)protected abstract voidserializeSpecificFields(java.io.OutputStream outputStream)voidserializeTo(java.io.OutputStream outputStream)voidsetBinaryValue(org.apache.iotdb.tsfile.utils.Binary binaryValue)voidsetBooleanValue(boolean booleanValue)voidsetDoubleValue(double doubleValue)voidsetFloatValue(float floatValue)voidsetIntValue(int intValue)voidsetLongValue(long longValue)voidsetTime(long timestamp)protected voidsetValue(java.lang.Object v)set an object.java.lang.StringtoString()abstract voidupdateResultFromPageData(org.apache.iotdb.tsfile.read.common.IBatchDataIterator batchIterator)Aggregate results cannot be calculated using Statistics directly, using the data in each page.abstract voidupdateResultFromPageData(org.apache.iotdb.tsfile.read.common.IBatchDataIterator batchIterator, long minBound, long maxBound)Aggregate results cannot be calculated using Statistics directly, using the data in each page.abstract voidupdateResultFromStatistics(org.apache.iotdb.tsfile.file.metadata.statistics.Statistics statistics)Calculate the aggregation using Statisticsabstract voidupdateResultUsingTimestamps(long[] timestamps, int length, IReaderByTimestamp dataReader)This method calculates the aggregation using common timestamps of the cross series filter.abstract voidupdateResultUsingValues(long[] timestamps, int length, ValueIterator valueIterator)This method calculates the aggregation using values that have been calculated
-
-
-
Field Detail
-
TIME_LENGTH_FOR_FIRST_VALUE
public static final int TIME_LENGTH_FOR_FIRST_VALUE
- See Also:
- Constant Field Values
-
resultDataType
protected org.apache.iotdb.tsfile.file.metadata.enums.TSDataType resultDataType
-
timestamp
protected long timestamp
For [COUNT, AVG, SUM], it is the start time of the aggregation window.For [MAX_VALUE, MIN_VALUE, EXTREME, FIRST_VALUE, LAST_VALUE], it is the timestamp of the current value.
For [MAX_TIME, MIN_TIME], it is always null.
-
hasCandidateResult
protected boolean hasCandidateResult
-
-
Constructor Detail
-
AggregateResult
public AggregateResult(org.apache.iotdb.tsfile.file.metadata.enums.TSDataType resultDataType, AggregationType aggregationType)construct.- Parameters:
resultDataType- result data type.
-
-
Method Detail
-
getResult
public abstract java.lang.Object getResult()
-
updateResultFromStatistics
public abstract void updateResultFromStatistics(org.apache.iotdb.tsfile.file.metadata.statistics.Statistics statistics) throws QueryProcessExceptionCalculate the aggregation using Statistics- Parameters:
statistics- chunkStatistics or pageStatistics- Throws:
QueryProcessException
-
updateResultFromPageData
public abstract void updateResultFromPageData(org.apache.iotdb.tsfile.read.common.IBatchDataIterator batchIterator) throws java.io.IOException, QueryProcessExceptionAggregate results cannot be calculated using Statistics directly, using the data in each page. This method is used in global aggregation query.- Parameters:
batchIterator- the data in Page- Throws:
java.io.IOExceptionQueryProcessException
-
updateResultFromPageData
public abstract void updateResultFromPageData(org.apache.iotdb.tsfile.read.common.IBatchDataIterator batchIterator, long minBound, long maxBound) throws java.io.IOExceptionAggregate results cannot be calculated using Statistics directly, using the data in each page. This method is used in GROUP BY aggregation query.- Parameters:
batchIterator- the data in PageminBound- calculate points whose time >= boundmaxBound- calculate points whose time < bound- Throws:
java.io.IOException
-
updateResultUsingTimestamps
public abstract void updateResultUsingTimestamps(long[] timestamps, int length, IReaderByTimestamp dataReader) throws java.io.IOExceptionThis method calculates the aggregation using common timestamps of the cross series filter.- Throws:
java.io.IOException- TsFile data read error
-
updateResultUsingValues
public abstract void updateResultUsingValues(long[] timestamps, int length, ValueIterator valueIterator)This method calculates the aggregation using values that have been calculated
-
hasFinalResult
public abstract boolean hasFinalResult()
Judge if aggregation results have been calculated. In other words, if the aggregated result does not need to compute the remaining data, it returns true.- Returns:
- If the aggregation result has been calculated return true, else return false.
-
merge
public abstract void merge(AggregateResult another)
Merge another aggregateResult into this
-
deserializeFrom
public static AggregateResult deserializeFrom(java.nio.ByteBuffer buffer)
-
deserializeSpecificFields
protected abstract void deserializeSpecificFields(java.nio.ByteBuffer buffer)
-
serialize
public void serialize(java.nio.ByteBuffer byteBuffer) throws java.io.IOException- Throws:
java.io.IOException
-
serializeTo
public void serializeTo(java.io.OutputStream outputStream) throws java.io.IOException- Throws:
java.io.IOException
-
serializeSpecificFields
protected abstract void serializeSpecificFields(java.io.OutputStream outputStream) throws java.io.IOException- Throws:
java.io.IOException
-
reset
public void reset()
-
getValue
protected java.lang.Object getValue()
-
setValue
protected void setValue(java.lang.Object v)
set an object.- Parameters:
v- object value
-
getResultDataType
public org.apache.iotdb.tsfile.file.metadata.enums.TSDataType getResultDataType()
-
getBooleanValue
protected boolean getBooleanValue()
-
setBooleanValue
public void setBooleanValue(boolean booleanValue)
-
getIntValue
public int getIntValue()
-
getIntAbsValue
public int getIntAbsValue()
-
setIntValue
public void setIntValue(int intValue)
-
getLongValue
public long getLongValue()
-
getLongAbsValue
public long getLongAbsValue()
-
setLongValue
public void setLongValue(long longValue)
-
getFloatValue
public float getFloatValue()
-
getFloatAbsValue
public float getFloatAbsValue()
-
setFloatValue
public void setFloatValue(float floatValue)
-
getDoubleValue
public double getDoubleValue()
-
getDoubleAbsValue
public double getDoubleAbsValue()
-
setDoubleValue
public void setDoubleValue(double doubleValue)
-
getBinaryValue
protected org.apache.iotdb.tsfile.utils.Binary getBinaryValue()
-
setBinaryValue
public void setBinaryValue(org.apache.iotdb.tsfile.utils.Binary binaryValue)
-
setTime
public void setTime(long timestamp)
-
getTime
public long getTime()
-
hasCandidateResult
protected boolean hasCandidateResult()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getAggregationType
public AggregationType getAggregationType()
-
isAscending
public boolean isAscending()
Whether the AggregationResult accepts data in time ascending order, if it returns false, the data should be passed in time descending order.
-
clone
public AggregateResult clone()
- Overrides:
clonein classjava.lang.Object
-
-