public TestingCrossJoinOperator( OperatorContext operatorContext, Lifespan lifespan) { this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); this.lifespan = requireNonNull(lifespan, "lifespan is null"); multiplierFuture = Futures.transform(buildStates.get(lifespan).getPagesFuture(), buildPages -> { requireNonNull(buildPages, "buildPages is null"); return buildPages.stream() .mapToInt(Page::getPositionCount) .sum(); }, directExecutor()); }
@Override public synchronized void noMoreOperators(Lifespan lifespan) { checkArgument(!driverGroupsWithNoMoreOperators.contains(lifespan)); buildStates.get(lifespan).setNoNewBuilds(); driverGroupsWithNoMoreOperators.add(lifespan); }
@Override public Page getOutput() { Page result = pages.poll(); if (isFinished() && pages.isEmpty()) { buildStates.get(lifespan).decrementPendingLookupCount(); } return result; } }
public void setNoNewLookups() { if (!grouped) { get(Lifespan.taskWide()).setNoNewLookups(); } }
@Override public ListenableFuture<?> isBlocked() { if (!finishing) { return NOT_BLOCKED; } return buildStates.get(lifespan).getLookupDoneFuture(); }
@Override public Operator createOperator(DriverContext driverContext) { checkState(!overallNoMoreOperators, "noMoreOperators() has been called"); checkState(!driverGroupsWithNoMoreOperators.contains(driverContext.getLifespan()), "noMoreOperators(lifespan) has been called"); OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, TestingCrossJoinOperator.class.getSimpleName()); buildStates.get(driverContext.getLifespan()).incrementPendingLookupCount(); return new TestingCrossJoinOperator(operatorContext, driverContext.getLifespan()); }
@Override public Operator createOperator(DriverContext driverContext) { checkState(!overallNoMoreOperators, "noMoreOperators() has been called"); checkState(!driverGroupsWithNoMoreOperators.contains(driverContext.getLifespan()), "noMoreOperators(lifespan) has been called"); OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, TestingBuildOperator.class.getSimpleName()); buildStates.get(driverContext.getLifespan()).incrementPendingBuildCount(); return new TestingBuildOperator(operatorContext, driverContext.getLifespan()); }
@Override public boolean isFinished() { return finishing && buildStates.get(lifespan).getLookupDoneFuture().isDone(); }
@Override public void finish() { if (finishing) { return; } finishing = true; buildStates.get(lifespan).addBuildResult(pages); }
public void setNoNewLookups(Lifespan lifespan) { // If it's grouped execution, knowing no new probe operators will be created for a group // should be immediately propagated to build state, so that corresponding build // can move forward (e.g. clean up). // On the other hand, if there's a single build, knowing no new probe operators will be // created for a group has no immediate use. if (grouped) { get(lifespan).setNoNewLookups(); } }