public class TimeWindowFunction extends java.lang.Object implements WindowFunction
| Modifier and Type | Class and Description |
|---|---|
static class |
TimeWindowFunction.Builder |
| Constructor and Description |
|---|
TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit)
Constructor with zero offset
|
TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
boolean addWindowStartTimeColumn,
boolean addWindowEndTimeColumn)
Constructor with zero offset, and supports adding columns containing the start and/or end times of the window
|
TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
long offset,
java.util.concurrent.TimeUnit offsetUnit)
Constructor with optional offset
|
TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
long offset,
java.util.concurrent.TimeUnit offsetUnit,
boolean addWindowStartTimeColumn,
boolean addWindowEndTimeColumn,
boolean excludeEmptyWindows)
Constructor with optional offset
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.util.List<java.util.List<Writable>>> |
applyToSequence(java.util.List<java.util.List<Writable>> sequence)
Apply the windowing function to the given sequence
|
Schema |
getInputSchema() |
long |
getWindowEndTimeForTime(long time)
Calculates the end time of the window for which the specified time belongs, in unix epoch (millisecond) format.
|
long |
getWindowStartTimeForTime(long time)
Calculates the start time of the window for which the specified time belongs, in unix epoch (millisecond) format
For example, if the window size is 1 hour with offset 0, then a time 10:17 would return 10:00, as the 1 hour window is for 10:00:00.000 to 10:59:59.999 inclusive, or 10:00:00.000 (inclusive) to 11:00:00.000 (exclusive) |
void |
setInputSchema(Schema schema) |
java.lang.String |
toString() |
Schema |
transform(Schema inputSchema)
Get the output schema, given the input schema.
|
public TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit)
timeColumn - Name of the column that contains the time values (must be a time column)windowSize - Numerical quantity for the size of the time window (used in conjunction with windowSizeUnit)windowSizeUnit - Unit of the time windowpublic TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
boolean addWindowStartTimeColumn,
boolean addWindowEndTimeColumn)
timeColumn - Name of the column that contains the time values (must be a time column)windowSize - Numerical quantity for the size of the time window (used in conjunction with windowSizeUnit)windowSizeUnit - Unit of the time windowaddWindowStartTimeColumn - If true: add a time column (name: "windowStartTime") that contains the start time
of the windowaddWindowStartTimeColumn - If true: add a time column (name: "windowEndTime") that contains the end time
of the windowpublic TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
long offset,
java.util.concurrent.TimeUnit offsetUnit)
timeColumn - Name of the column that contains the time values (must be a time column)windowSize - Numerical quantity for the size of the time window (used in conjunction with windowSizeUnit)windowSizeUnit - Unit of the time windowoffset - Optional offset amount, to shift start/end of the time window forward or backoffsetUnit - Optional offset unit for the offset amount.public TimeWindowFunction(java.lang.String timeColumn,
long windowSize,
java.util.concurrent.TimeUnit windowSizeUnit,
long offset,
java.util.concurrent.TimeUnit offsetUnit,
boolean addWindowStartTimeColumn,
boolean addWindowEndTimeColumn,
boolean excludeEmptyWindows)
timeColumn - Name of the column that contains the time values (must be a time column)windowSize - Numerical quantity for the size of the time window (used in conjunction with windowSizeUnit)windowSizeUnit - Unit of the time windowoffset - Optional offset amount, to shift start/end of the time window forward or backoffsetUnit - Optional offset unit for the offset amount.addWindowStartTimeColumn - If true: add a column (at the end) with the window start timeaddWindowEndTimeColumn - If true: add a column (at the end) with the window end timeexcludeEmptyWindows - If true: exclude any windows that don't have any values in thempublic void setInputSchema(Schema schema)
setInputSchema in interface WindowFunctionpublic Schema getInputSchema()
getInputSchema in interface WindowFunctionpublic Schema transform(Schema inputSchema)
WindowFunctiontransform in interface WindowFunctioninputSchema - Schema of the input datapublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<java.util.List<java.util.List<Writable>>> applyToSequence(java.util.List<java.util.List<Writable>> sequence)
WindowFunctionapplyToSequence in interface WindowFunctionsequence - the input sequencepublic long getWindowStartTimeForTime(long time)
time - Time at which to determine the window start time (milliseconds epoch format)public long getWindowEndTimeForTime(long time)
getWindowStartTimeForTime(long) + interval (in milliseconds).time - Time at which to determine the window start time