public synchronized void setNoNewBuilds() { if (noNewBuilds) { return; } checkState(!pagesFuture.isDone()); noNewBuilds = true; checkAllBuildsDone(); }
synchronized void setNoNewLookups() { if (noNewLookups) { return; } checkState(!lookupDoneFuture.isDone()); noNewLookups = true; checkAllLookupsDone(); }
@Override public Page getOutput() { Page result = pages.poll(); if (isFinished() && pages.isEmpty()) { buildStates.get(lifespan).decrementPendingLookupCount(); } return result; } }
@Override public ListenableFuture<?> isBlocked() { if (!finishing) { return NOT_BLOCKED; } return buildStates.get(lifespan).getLookupDoneFuture(); }
@Override public synchronized void noMoreOperators(Lifespan lifespan) { checkArgument(!driverGroupsWithNoMoreOperators.contains(lifespan)); buildStates.get(lifespan).setNoNewBuilds(); driverGroupsWithNoMoreOperators.add(lifespan); }
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 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()); }
public synchronized void decrementPendingLookupCount() { checkState(!lookupDoneFuture.isDone()); pendingLookupCount--; checkAllLookupsDone(); }
@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 synchronized void addBuildResult(List<Page> newPages) { checkState(!pagesFuture.isDone()); pages.addAll(newPages); pendingBuildCount--; checkAllBuildsDone(); }
public synchronized BuildState get(Lifespan lifespan) { if (grouped) { return buildStatesMap.computeIfAbsent(lifespan, ignored -> new BuildState()); } else { return buildStatesMap.computeIfAbsent(Lifespan.taskWide(), ignored -> new BuildState()); } }