@Override public long getJoinPosition(int position, Page hashChannelsPage, Page allChannelsPage) { return lookupSource.getJoinPosition(position, hashChannelsPage, allChannelsPage); }
@Override public void appendTo(long position, PageBuilder pageBuilder, int outputChannelOffset) { values.appendTo(position, pageBuilder, outputChannelOffset); }
@Override public void close() { lookupSource.close(); }
@Override public long getJoinPositionCount() { return lookupSource.getJoinPositionCount(); }
@Override public long getNextJoinPosition(long currentPosition) { return values.getNextJoinPosition(currentPosition, -1, EMPTY_PAGE); }
@Override public long getInMemorySizeInBytes() { return lookupSource.getInMemorySizeInBytes(); }
@Override public int getChannelCount() { return lookupSources[0].getChannelCount(); }
private boolean joinCurrentPosition() { // while we have a position to join against... while (joinPosition >= 0) { pageBuilder.declarePosition(); // write probe columns probe.appendTo(pageBuilder); // write build columns lookupSource.appendTo(joinPosition, pageBuilder, probe.getChannelCount()); // get next join position for this row joinPosition = lookupSource.getNextJoinPosition(joinPosition); if (pageBuilder.isFull()) { return false; } } return true; }
/** * Produce rows matching join condition for the current probe position. If this method was called previously * for the current probe position, calling this again will produce rows that wasn't been produced in previous * invocations. * * @return true if all eligible rows have been produced; false otherwise */ private boolean joinCurrentPosition(LookupSource lookupSource, DriverYieldSignal yieldSignal) { // while we have a position on lookup side to join against... while (joinPosition >= 0) { if (lookupSource.isJoinPositionEligible(joinPosition, probe.getPosition(), probe.getPage())) { currentProbePositionProducedRow = true; pageBuilder.appendRow(probe, lookupSource, joinPosition); joinSourcePositions++; } // get next position on lookup side for this probe row joinPosition = lookupSource.getNextJoinPosition(joinPosition, probe.getPosition(), probe.getPage()); if (yieldSignal.isSet() || tryBuildPage()) { return false; } } return true; }
@Override public boolean isJoinPositionEligible(long currentJoinPosition, int probePosition, Page allProbeChannelsPage) { return lookupSource.isJoinPositionEligible(currentJoinPosition, probePosition, allProbeChannelsPage); }
@Override public boolean isEmpty() { return lookupSource.isEmpty(); }
public OuterPositionTracker(Supplier<LookupSource> lookupSourceSupplier) { this.lookupSourceSupplier = lookupSourceSupplier; try (LookupSource lookupSource = lookupSourceSupplier.get()) { this.visitedPositions = new boolean[toIntExact(lookupSource.getJoinPositionCount())]; } }
@Override public long getNextJoinPosition(long currentJoinPosition, int probePosition, Page allProbeChannelsPage) { return lookupSource.getNextJoinPosition(currentJoinPosition, probePosition, allProbeChannelsPage); }
private void finishInput() { checkState(state == State.CONSUMING_INPUT); if (lookupSourceFactoryDestroyed.isDone()) { close(); return; } LookupSourceSupplier partition = buildLookupSource(); if (spillEnabled) { localRevocableMemoryContext.setBytes(partition.get().getInMemorySizeInBytes()); } else { localUserMemoryContext.setBytes(partition.get().getInMemorySizeInBytes()); } lookupSourceNotNeeded = Optional.of(lookupSourceFactory.lendPartitionLookupSource(partitionIndex, partition)); state = State.LOOKUP_SOURCE_BUILT; }
@Override public int getChannelCount() { return lookupSource.getChannelCount(); }
@Override public boolean isJoinPositionEligible(long currentJoinPosition, int probePosition, Page allProbeChannelsPage) { int partition = decodePartition(currentJoinPosition); long joinPosition = decodeJoinPosition(currentJoinPosition); LookupSource lookupSource = lookupSources[partition]; return lookupSource.isJoinPositionEligible(joinPosition, probePosition, allProbeChannelsPage); }
@Override public long getJoinPosition(int position, Page hashChannelsPage, Page allChannelsPage, long rawHash) { return lookupSource.getJoinPosition(position, hashChannelsPage, allChannelsPage, rawHash); }
@Override public synchronized boolean appendToNext(PageBuilder pageBuilder, int outputChannelOffset) { while (currentPosition < visitedPositions.length) { if (!visitedPositions[currentPosition]) { lookupSource.appendTo(currentPosition, pageBuilder, outputChannelOffset); currentPosition++; return true; } currentPosition++; } return false; } }
@Override public void close() { lookupSource.close(); }
public SharedLookupOuterPositionIterator(LookupSource lookupSource, boolean[] visitedPositions) { this.lookupSource = requireNonNull(lookupSource, "lookupSource is null"); this.visitedPositions = requireNonNull(visitedPositions, "visitedPositions is null"); checkArgument(lookupSource.getJoinPositionCount() == visitedPositions.length); }