Source:
public ListenableFuture<?> startMemoryRevoke() { checkState(spillEnabled, "Spill not enabled, no revokable memory should be reserved"); if (state == State.CONSUMING_INPUT) { long indexSizeBeforeCompaction = index.getEstimatedSize().toBytes(); index.compact(); long indexSizeAfterCompaction = index.getEstimatedSize().toBytes(); if (indexSizeAfterCompaction < indexSizeBeforeCompaction * 0.8) { finishMemoryRevoke = Optional.of(() -> { }); return immediateFuture(null); } finishMemoryRevoke = Optional.of(() -> { index.clear(); operatorContext.setMemoryReservation(index.getEstimatedSize().toBytes()); operatorContext.setRevocableMemoryReservation(0L); state = State.SPILLING_INPUT; }); return spillIndex(); } else if (state == State.LOOKUP_SOURCE_BUILT) { finishMemoryRevoke = Optional.of(() -> { lookupSourceFactory.setPartitionSpilledLookupSource(partitionIndex, spilledLookupSourceHandle); lookupSourceNotNeeded = Optional.empty(); index.clear(); operatorContext.setMemoryReservation(index.getEstimatedSize().toBytes()); operatorContext.setRevocableMemoryReservation(0L); lookupSourceChecksum = OptionalLong.of(lookupSourceSupplier.checksum()); lookupSourceSupplier = null; state = State.LOOKUP_SOURCE_SPILLED; }); return spillIndex(); } else if (operatorContext.getReservedRevocableBytes() == 0) { finishMemoryRevoke = Optional.of(() -> { }); return immediateFuture(null); } throw new IllegalStateException(format("Remaining %s revocable bytes which I don't know how to revoke", operatorContext.getReservedRevocableBytes())); }

Target:
public ListenableFuture<?> startMemoryRevoke() { checkState(spillEnabled, "Spill not enabled, no revokable memory should be reserved"); if (state == State.CONSUMING_INPUT) { long indexSizeBeforeCompaction = index.getEstimatedSize().toBytes(); index.compact(); long indexSizeAfterCompaction = index.getEstimatedSize().toBytes(); if (indexSizeAfterCompaction < indexSizeBeforeCompaction * INDEX_COMPACTION_ON_REVOCATION_TARGET) { finishMemoryRevoke = Optional.of(() -> {}); return immediateFuture(null); } finishMemoryRevoke = Optional.of(() -> { index.clear(); operatorContext.setMemoryReservation(index.getEstimatedSize().toBytes()); operatorContext.setRevocableMemoryReservation(0L); lookupSourceFactory.setPartitionSpilledLookupSourceHandle(partitionIndex, spilledLookupSourceHandle); state = State.SPILLING_INPUT; }); return spillIndex(); } else if (state == State.LOOKUP_SOURCE_BUILT) { finishMemoryRevoke = Optional.of(() -> { lookupSourceFactory.setPartitionSpilledLookupSourceHandle(partitionIndex, spilledLookupSourceHandle); lookupSourceNotNeeded = Optional.empty(); index.clear(); operatorContext.setMemoryReservation(index.getEstimatedSize().toBytes()); operatorContext.setRevocableMemoryReservation(0L); lookupSourceChecksum = OptionalLong.of(lookupSourceSupplier.checksum()); lookupSourceSupplier = null; state = State.INPUT_SPILLED; }); return spillIndex(); } else if (operatorContext.getReservedRevocableBytes() == 0) { finishMemoryRevoke = Optional.of(() -> {}); return immediateFuture(null); } throw new IllegalStateException(format("State %s can not have revocable memory, but has %s revocable bytes", state, operatorContext.getReservedRevocableBytes())); }