Class SlidingTimeWindowAccessStrategy
- java.lang.Object
-
- org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy
-
- All Implemented Interfaces:
AccessStrategy
public class SlidingTimeWindowAccessStrategy extends java.lang.Object implements AccessStrategy
Used inUDTF.beforeStart(UDFParameters, UDTFConfigurations).When the access strategy of a UDTF is set to an instance of this class, the method
UDTF.transform(RowWindow, PointCollector)of the UDTF will be called to transform the original data. You need to override the method in your own UDTF class.Sliding time window is a kind of time-based window. To partition the raw query data set into sliding time windows, you need to give the following 4 parameters:
- display window begin: determines the start time of the first window
- display window end: if the start time of current window + sliding step > display window end, then current window is the last window that your UDTF can process
- time interval: determines the time range of a window
- sliding step: the start time of the next window = the start time of current window + sliding step
Each call of the method
UDTF.transform(RowWindow, PointCollector)processes one time window and can generate any number of data points. Note that the transform method will still be called when there is no data point in a window. Note that the time range of the last few windows may be less than the specified time interval.Sample code:
Style 1:
{@code- See Also:
UDTF,UDTFConfigurations
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.iotdb.udf.api.customizer.strategy.AccessStrategy
AccessStrategy.AccessStrategyType
-
-
Constructor Summary
Constructors Constructor Description SlidingTimeWindowAccessStrategy(long timeInterval)Sliding step will be set to the same as the time interval, display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.SlidingTimeWindowAccessStrategy(long timeInterval, long slidingStep)Display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.SlidingTimeWindowAccessStrategy(long timeInterval, long slidingStep, long displayWindowBegin, long displayWindowEnd)SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString)Deprecated since v0.14.SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString, java.lang.String slidingStepString)Deprecated.SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString, java.lang.String slidingStepString, java.lang.String displayWindowBeginString, java.lang.String displayWindowEndString)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheck()Used by the system to check the access strategy.AccessStrategy.AccessStrategyTypegetAccessStrategyType()Returns the actual access strategy type.longgetDisplayWindowBegin()longgetDisplayWindowEnd()longgetSlidingStep()longgetTimeInterval()java.time.ZoneIdgetZoneId()voidsetZoneId(java.time.ZoneId zoneId)
-
-
-
Constructor Detail
-
SlidingTimeWindowAccessStrategy
@Deprecated public SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString, java.lang.String slidingStepString, java.lang.String displayWindowBeginString, java.lang.String displayWindowEndString)Deprecated.Deprecated since v0.14.- Parameters:
timeIntervalString- time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported units: y, mo, w, d, h, m, s, ms, us, ns.slidingStepString- sliding step in string. examples: 12d8m9ns, 1y1mo, etc. supported units: y, mo, w, d, h, m, s, ms, us, ns.displayWindowBeginString- display window begin in string. format: 2011-12-03T10:15:30 or 2011-12-03T10:15:30+01:00.displayWindowEndString- display window end in string. format: 2011-12-03T10:15:30 or 2011-12-03T10:15:30+01:00.- Throws:
java.lang.UnsupportedOperationException- deprecated since v0.14
-
SlidingTimeWindowAccessStrategy
@Deprecated public SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString, java.lang.String slidingStepString)Deprecated.Deprecated since v0.14.Display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.
- Parameters:
timeIntervalString- time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported units: y, mo, w, d, h, m, s, ms, us, ns.slidingStepString- sliding step in string. examples: 12d8m9ns, 1y1mo, etc. supported units: y, mo, w, d, h, m, s, ms, us, ns.- Throws:
java.lang.UnsupportedOperationException- deprecated since v0.14
-
SlidingTimeWindowAccessStrategy
public SlidingTimeWindowAccessStrategy(java.lang.String timeIntervalString)
Deprecated since v0.14.Sliding step will be set to the same as the time interval, display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.
- Parameters:
timeIntervalString- time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported units: y, mo, w, d, h, m, s, ms, us, ns.- Throws:
java.lang.UnsupportedOperationException- deprecated since v0.14
-
SlidingTimeWindowAccessStrategy
public SlidingTimeWindowAccessStrategy(long timeInterval, long slidingStep, long displayWindowBegin, long displayWindowEnd)- Parameters:
timeInterval- 0 < timeIntervalslidingStep- 0 < slidingStepdisplayWindowBegin- displayWindowBegin < displayWindowEnddisplayWindowEnd- displayWindowBegin < displayWindowEnd
-
SlidingTimeWindowAccessStrategy
public SlidingTimeWindowAccessStrategy(long timeInterval, long slidingStep)Display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.- Parameters:
timeInterval- 0 < timeIntervalslidingStep- 0 < slidingStep
-
SlidingTimeWindowAccessStrategy
public SlidingTimeWindowAccessStrategy(long timeInterval)
Sliding step will be set to the same as the time interval, display window begin will be set to the same as the minimum timestamp of the query result set, and display window end will be set to the same as the maximum timestamp of the query result set.- Parameters:
timeInterval- 0 < timeInterval
-
-
Method Detail
-
check
public void check()
Description copied from interface:AccessStrategyUsed by the system to check the access strategy.- Specified by:
checkin interfaceAccessStrategy
-
getTimeInterval
public long getTimeInterval()
-
getSlidingStep
public long getSlidingStep()
-
getDisplayWindowBegin
public long getDisplayWindowBegin()
-
getDisplayWindowEnd
public long getDisplayWindowEnd()
-
getZoneId
public java.time.ZoneId getZoneId()
-
setZoneId
public void setZoneId(java.time.ZoneId zoneId)
-
getAccessStrategyType
public AccessStrategy.AccessStrategyType getAccessStrategyType()
Description copied from interface:AccessStrategyReturns the actual access strategy type.- Specified by:
getAccessStrategyTypein interfaceAccessStrategy- Returns:
- the actual access strategy type
-
-