@Override public Throwable getFailureCause() { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { return spilled.getFailureCause(); } else { return parent.getFailureCause(); } }
@Override public boolean isReleased() { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { return spilled.isReleased(); } else { return parent.isReleased() || isReleased.get(); } }
@Override public void notifySubpartitionConsumed() throws IOException { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { spilled.notifySubpartitionConsumed(); } else { parent.onConsumedSubpartition(); } }
if (spilled != null) { if (current != null) { return new BufferAndBacklog(current, spilled.isAvailable(), newBacklog, spilled.nextBufferIsEvent()); } else { return spilled.getNextBuffer();
@Override public ResultSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { synchronized (buffers) { if (!isFinished) { throw new IllegalStateException("Subpartition has not been finished yet, " + "but blocking subpartitions can only be consumed after they have " + "been finished."); } if (readView != null) { throw new IllegalStateException("Subpartition is being or already has been " + "consumed, but we currently allow subpartitions to only be consumed once."); } if (spillWriter != null) { readView = new SpilledSubpartitionView( this, parent.getBufferProvider().getMemorySegmentSize(), spillWriter, getTotalNumberOfBuffers(), availabilityListener); } else { readView = new SpillableSubpartitionView( this, buffers, ioManager, parent.getBufferProvider().getMemorySegmentSize(), availabilityListener); } return readView; } }
@Override public void releaseAllResources() throws IOException { if (isReleased.compareAndSet(false, true)) { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { spilled.releaseAllResources(); } } }
@Override public boolean nextBufferIsEvent() { synchronized (this) { if (nextBuffer == null) { try { nextBuffer = requestAndFillBuffer(); } catch (Exception e) { // we can ignore this here (we will get it again once getNextBuffer() is called) return false; } } return nextBuffer != null && !nextBuffer.isBuffer(); } }
@Override public Buffer getNextBuffer() throws IOException, InterruptedException { synchronized (buffers) { if (isReleased.get()) { return null; } else if (nextBuffer != null) { Buffer current = nextBuffer; nextBuffer = buffers.poll(); if (nextBuffer != null) { listener.notifyBuffersAvailable(1); } return current; } } // else: spilled SpilledSubpartitionView spilled = spilledView; if (spilled != null) { return spilled.getNextBuffer(); } else { throw new IllegalStateException("No in-memory buffers available, but also nothing spilled."); } }
@Override public boolean isAvailable() { synchronized (buffers) { if (nextBuffer != null) { return true; } else if (spilledView == null) { return false; } } // else: spilled return spilledView.isAvailable(); }
@Override public boolean nextBufferIsEvent() { synchronized (buffers) { if (isReleased.get()) { return false; } else if (nextBuffer != null) { return !nextBuffer.isBuffer(); } } // else: spilled checkState(spilledView != null, "No in-memory buffers available, but also nothing spilled."); return spilledView.nextBufferIsEvent(); }
if (spilled != null) { if (current != null) { return new BufferAndBacklog(current, spilled.isAvailable(), newBacklog, spilled.nextBufferIsEvent()); } else { return spilled.getNextBuffer();
@Override public ResultSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { synchronized (buffers) { if (!isFinished) { throw new IllegalStateException("Subpartition has not been finished yet, " + "but blocking subpartitions can only be consumed after they have " + "been finished."); } if (readView != null) { throw new IllegalStateException("Subpartition is being or already has been " + "consumed, but we currently allow subpartitions to only be consumed once."); } if (spillWriter != null) { readView = new SpilledSubpartitionView( this, parent.getBufferProvider().getMemorySegmentSize(), spillWriter, getTotalNumberOfBuffers(), availabilityListener); } else { readView = new SpillableSubpartitionView( this, buffers, ioManager, parent.getBufferProvider().getMemorySegmentSize(), availabilityListener); } return readView; } }
@Override public void releaseAllResources() throws IOException { if (isReleased.compareAndSet(false, true)) { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { spilled.releaseAllResources(); } // we are never giving this buffer out in getNextBuffer(), so we need to clean it up synchronized (buffers) { if (nextBuffer != null) { nextBuffer.close(); nextBuffer = null; } } } }
@Override public boolean nextBufferIsEvent() { synchronized (this) { if (nextBuffer == null) { try { nextBuffer = requestAndFillBuffer(); } catch (Exception e) { // we can ignore this here (we will get it again once getNextBuffer() is called) return false; } } return nextBuffer != null && !nextBuffer.isBuffer(); } }
@Override public boolean isAvailable() { synchronized (buffers) { if (nextBuffer != null) { return true; } else if (spilledView == null) { return false; } } // else: spilled return spilledView.isAvailable(); }
@Override public boolean nextBufferIsEvent() { synchronized (buffers) { if (isReleased.get()) { return false; } else if (nextBuffer != null) { return !nextBuffer.isBuffer(); } } // else: spilled checkState(spilledView != null, "No in-memory buffers available, but also nothing spilled."); return spilledView.nextBufferIsEvent(); }
if (spilled != null) { if (current != null) { return new BufferAndBacklog(current, spilled.isAvailable(), newBacklog, spilled.nextBufferIsEvent()); } else { return spilled.getNextBuffer();
@Override public ResultSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { synchronized (buffers) { if (!isFinished) { throw new IllegalStateException("Subpartition has not been finished yet, " + "but blocking subpartitions can only be consumed after they have " + "been finished."); } if (readView != null) { throw new IllegalStateException("Subpartition is being or already has been " + "consumed, but we currently allow subpartitions to only be consumed once."); } if (spillWriter != null) { readView = new SpilledSubpartitionView( this, parent.getBufferProvider().getMemorySegmentSize(), spillWriter, getTotalNumberOfBuffers(), availabilityListener); } else { readView = new SpillableSubpartitionView( this, buffers, ioManager, parent.getBufferProvider().getMemorySegmentSize(), availabilityListener); } return readView; } }
@Override public boolean isReleased() { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { return spilled.isReleased(); } else { return parent.isReleased() || isReleased.get(); } }
@Override public void notifySubpartitionConsumed() throws IOException { SpilledSubpartitionView spilled = spilledView; if (spilled != null) { spilled.notifySubpartitionConsumed(); } else { parent.onConsumedSubpartition(); } }