public SetBuilderOperator( OperatorContext operatorContext, SetSupplier setSupplier, int setChannel, Optional<Integer> hashChannel, int expectedPositions, JoinCompiler joinCompiler) { this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); this.setSupplier = requireNonNull(setSupplier, "setProvider is null"); this.setChannel = setChannel; this.hashChannel = requireNonNull(hashChannel, "hashChannel is null"); // Set builder is has a single channel which goes in channel 0, if hash is present, add a hachBlock to channel 1 Optional<Integer> channelSetHashChannel = hashChannel.isPresent() ? Optional.of(1) : Optional.empty(); this.channelSetBuilder = new ChannelSetBuilder( setSupplier.getType(), channelSetHashChannel, expectedPositions, requireNonNull(operatorContext, "operatorContext is null"), requireNonNull(joinCompiler, "joinCompiler is null")); }
@Override public void addInput(Page page) { requireNonNull(page, "page is null"); checkState(!isFinished(), "Operator is already finished"); Block sourceBlock = page.getBlock(setChannel); Page sourcePage = hashChannel.isPresent() ? new Page(sourceBlock, page.getBlock(hashChannel.get())) : new Page(sourceBlock); unfinishedWork = channelSetBuilder.addPage(sourcePage); processUnfinishedWork(); }
@VisibleForTesting public int getCapacity() { return channelSetBuilder.getCapacity(); } }
public SetBuilderOperator( OperatorContext operatorContext, SetSupplier setSupplier, int setChannel, Optional<Integer> hashChannel, int expectedPositions) { this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); this.setSupplier = requireNonNull(setSupplier, "setProvider is null"); this.setChannel = setChannel; this.hashChannel = requireNonNull(hashChannel, "hashChannel is null"); // Set builder is has a single channel which goes in channel 0, if hash is present, add a hachBlock to channel 1 Optional<Integer> channelSetHashChannel = hashChannel.isPresent() ? Optional.of(1) : Optional.empty(); this.channelSetBuilder = new ChannelSetBuilder( setSupplier.getType(), channelSetHashChannel, expectedPositions, requireNonNull(operatorContext, "operatorContext is null")); }
@Override public void addInput(Page page) { requireNonNull(page, "page is null"); checkState(!isFinished(), "Operator is already finished"); Block sourceBlock = page.getBlock(setChannel); Page sourcePage = hashChannel.isPresent() ? new Page(sourceBlock, page.getBlock(hashChannel.get())) : new Page(sourceBlock); channelSetBuilder.addPage(sourcePage); }
@Override public void finish() { if (finished) { return; } ChannelSet channelSet = channelSetBuilder.build(); setSupplier.setChannelSet(channelSet); operatorContext.recordGeneratedOutput(channelSet.getEstimatedSizeInBytes(), channelSet.size()); finished = true; }
private boolean processUnfinishedWork() { // Processes the unfinishedWork for this page by adding the data to the hash table. If this page // can't be fully consumed (e.g. rehashing fails), the unfinishedWork will be left with non-empty value. checkState(unfinishedWork != null, "unfinishedWork is empty"); boolean done = unfinishedWork.process(); if (done) { unfinishedWork = null; } // We need to update the memory reservation again since the page builder memory may also be increasing. channelSetBuilder.updateMemoryReservation(); return done; }
@Override public void finish() { if (finished) { return; } ChannelSet channelSet = channelSetBuilder.build(); setSupplier.setChannelSet(channelSet); operatorContext.recordOutput(channelSet.getEstimatedSizeInBytes(), channelSet.size()); finished = true; }