Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder;
import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder;
import org.apache.pinot.segment.spi.AggregationFunctionType;
import org.apache.pinot.spi.query.QueryThreadContext;


public class FunnelEventsFunctionEvalAggregationFunction
Expand Down Expand Up @@ -396,11 +397,14 @@ public PriorityQueue<FunnelStepEventWithExtraFields> deserializeIntermediateResu
protected void fillWindow(PriorityQueue<FunnelStepEventWithExtraFields> stepEvents,
ArrayDeque<FunnelStepEventWithExtraFields> slidingWindow) {
// Ensure for the sliding window, the first event is the first step
int numEventsProcessed = 0;
while ((!slidingWindow.isEmpty()) && slidingWindow.peek().getFunnelStepEvent().getStep() != 0) {
slidingWindow.pollFirst();
}
if (slidingWindow.isEmpty()) {
while (!stepEvents.isEmpty() && stepEvents.peek().getFunnelStepEvent().getStep() != 0) {
QueryThreadContext.checkTerminationAndSampleUsagePeriodically(numEventsProcessed++,
"FunnelEventsFunctionEvalAggregationFunction#fillWindow");
stepEvents.poll();
}
if (stepEvents.isEmpty()) {
Expand All @@ -412,6 +416,8 @@ protected void fillWindow(PriorityQueue<FunnelStepEventWithExtraFields> stepEven
long windowStart = slidingWindow.peek().getFunnelStepEvent().getTimestamp();
long windowEnd = windowStart + _windowSize;
while (!stepEvents.isEmpty() && (stepEvents.peek().getFunnelStepEvent().getTimestamp() < windowEnd)) {
QueryThreadContext.checkTerminationAndSampleUsagePeriodically(numEventsProcessed++,
"FunnelEventsFunctionEvalAggregationFunction#fillWindow");
if (_maxStepDuration > 0) {
// When maxStepDuration > 0, we need to check if the event_to_add has a timestamp within the max duration
// from the last event in the sliding window. If not, we break the loop.
Expand Down Expand Up @@ -464,7 +470,10 @@ public ObjectArrayList<String> extractFinalResult(PriorityQueue<FunnelStepEventW

int maxStep = 0;
long previousTimestamp = -1;
int numEventsProcessed = 0;
for (FunnelStepEventWithExtraFields event : slidingWindow) {
QueryThreadContext.checkTerminationAndSampleUsagePeriodically(numEventsProcessed++,
"FunnelEventsFunctionEvalAggregationFunction#extractFinalResult");
int currentEventStep = event.getFunnelStepEvent().getStep();
// If the same condition holds for the sequence of events, then such repeating event interrupts further
// processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.pinot.segment.local.customobject.AvgPair;
import org.apache.pinot.segment.local.customobject.QuantileDigest;
import org.apache.pinot.segment.spi.AggregationFunctionType;
import org.apache.pinot.spi.query.QueryThreadContext;
import org.apache.pinot.spi.utils.CommonConstants;


Expand Down Expand Up @@ -218,7 +219,10 @@ private DoubleArrayList getStepDurationResults(Map<Integer, List<Object>> valueA
protected Integer processWindow(ArrayDeque<FunnelStepEvent> slidingWindow) {
int maxStep = 0;
long previousTimestamp = -1;
int numEventsProcessed = 0;
for (FunnelStepEvent event : slidingWindow) {
QueryThreadContext.checkTerminationAndSampleUsagePeriodically(numEventsProcessed++,
"FunnelStepDurationStatsAggregationFunction#processWindow");
int currentEventStep = event.getStep();
// If the same condition holds for the sequence of events, then such repeating event interrupts further
// processing.
Expand Down
Loading