Class SparklineGenerateEmptyBucketsOperator
- All Implemented Interfaces:
Closeable,AutoCloseable,Operator,Releasable
@timestamp columns. Let's take an example:
| STATS mi=SPARKLINE( MAX(int), @timestamp, 3, "2025-01-01", "2025-01-03"),
md=SPARKLINE(MIN(double), @timestamp, 3, "2025-01-01", "2025-01-03")
BY hostname
That's going to produce output like:
┌───────────────┬──────────────────┬──────────┐
│ MIN(int) │ MAX(double) │ hostname │
├───────────────┼──────────────────┼──────────┤
│ [10, 20, 30] │ [1.0, 2.0, 3.0] │ yay │
│ [42, 0, 99] │ [4.2, 0.0, 9.9] │ server │
└───────────────┴──────────────────┴──────────┘
To get there the original ESQL is rewritten into:
| STATS mi=MAX(int), md=MIN(double), BY @timestamp=DATE_TRUNC(1 day, @timestamp), hostname
| STATS TOP(@timestamp, 3, "asc", mi), TOP(@timestamp, 3, "asc", md), TOP(@timestamp, 3, "asc")
BY hostname
| SPARKLINE_GENERATE_EMPTY_BUCKETS <-- you are here
The first STATS is just pretty normal agg. Imagine it returns something like:
┌───────────────┬──────────────────┬────────────┬──────────┐
│ MIN(int) │ MAX(double) │ @timestamp │ hostname │
├───────────────┼──────────────────┼────────────┼──────────┤
│ 10 │ 1.0 │ 2025-01-01 │ yay │
│ 20 │ 2.0 │ 2025-01-02 │ yay │
│ 30 │ 3.0 │ 2025-01-03 │ yay │
│ 42 │ 4.2 │ 2025-01-01 │ server │
│ 99 │ 9.9 │ 2025-01-03 │ server │
└───────────────┴──────────────────┴────────────┴──────────┘
The second STATS collects the results into the arrays that the output
layout expects. But have a look:
┌───────────────┬──────────────────┬──────────────────────────────────────┬──────────┐
│ MIN(int) │ MAX(double) │ @timestamp │ hostname │
├───────────────┼──────────────────┼──────────────────────────────────────┼──────────┤
│ [10, 20, 30] │ [1.0, 2.0, 3.0] │ [2025-01-01, 2025-01-02, 2025-01-03] │ yay │
│ [42, 99] │ [4.2, 9.9] │ [2025-01-01, 2025-01-03] │ server │
└───────────────┴──────────────────┴──────────────────────────────────────┴──────────┘
See?! The second row is complete - ready! It's what we want! Well, it has a
@timestamp we don't want, but it's close! But the second row is trouble.
It's missing the value for 2025-01-02. You can tell which day is missing
by looking at the timestamp. This operator fills in the 0. It'll consume the
data above and make:
┌───────────────┬──────────────────┬──────────┐
│ MIN(int) │ MAX(double) │ hostname │
├───────────────┼──────────────────┼──────────┤
│ [10, 20, 30] │ [1.0, 2.0, 3.0] │ yay │
│ [42, 0, 99] │ [4.2, 0.0, 9.9] │ server │
└───────────────┴──────────────────┴──────────┘
And that is exactly what we want.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordNested classes/interfaces inherited from interface org.elasticsearch.compute.operator.Operator
Operator.OperatorFactory, Operator.Status -
Field Summary
Fields inherited from interface org.elasticsearch.compute.operator.Operator
MIN_TARGET_PAGE_SIZE, NOT_BLOCKED, TARGET_PAGE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionSparklineGenerateEmptyBucketsOperator(DriverContext driverContext, int numValueColumns, Rounding.Prepared dateBucketRounding, long minDate, long maxDate) -
Method Summary
Modifier and TypeMethodDescriptionvoidadds an input page to the operator.booleanReturns true if the operator can produce more output pages without requiring additional input pages.voidclose()notifies the operator that it won't be used anymore (i.e.voidfinish()notifies the operator that it won't receive any more input pagesreturns non-null if output page available.booleanwhether the operator has finished processing all input pages and made the corresponding output pages availablebooleanwhether the given operator can accept more input pagestoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.compute.operator.Operator
isBlocked, status, tryPromote
-
Constructor Details
-
SparklineGenerateEmptyBucketsOperator
public SparklineGenerateEmptyBucketsOperator(DriverContext driverContext, int numValueColumns, Rounding.Prepared dateBucketRounding, long minDate, long maxDate)
-
-
Method Details
-
needsInput
public boolean needsInput()Description copied from interface:Operatorwhether the given operator can accept more input pages- Specified by:
needsInputin interfaceOperator
-
addInput
Description copied from interface:Operatoradds an input page to the operator. only called when needsInput() == true and isFinished() == false -
finish
public void finish()Description copied from interface:Operatornotifies the operator that it won't receive any more input pages -
isFinished
public boolean isFinished()Description copied from interface:Operatorwhether the operator has finished processing all input pages and made the corresponding output pages available- Specified by:
isFinishedin interfaceOperator
-
canProduceMoreDataWithoutExtraInput
public boolean canProduceMoreDataWithoutExtraInput()Description copied from interface:OperatorReturns true if the operator can produce more output pages without requiring additional input pages. This is useful for operators that buffer data or have internal state that can produce multiple output pages.Operators that do not buffer data should return
false- they cannot produce pages out of thin air. Examples of operators that may returntrue:- Operators with internal buffers (e.g.,
AsyncOperatorwith pending results) - Operators processing a single input page into multiple output pages
- Aggregation operators that buffer partial results
- Specified by:
canProduceMoreDataWithoutExtraInputin interfaceOperator- Returns:
trueif the operator has buffered data that can produce output,falseotherwise
- Operators with internal buffers (e.g.,
-
getOutput
Description copied from interface:Operatorreturns non-null if output page available. Only called when isFinished() == false -
close
public void close()Description copied from interface:Operatornotifies the operator that it won't be used anymore (i.e. none of the other methods called), and its resources can be cleaned up- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceOperator- Specified by:
closein interfaceReleasable
-
toString
-