@Override public void flush() { synchronized (buffers) { if (buffers.isEmpty()) { return; } flushRequested = !buffers.isEmpty(); notifyDataAvailable(); } }
@Override public void flush() { final boolean notifyDataAvailable; synchronized (buffers) { if (buffers.isEmpty()) { return; } // if there is more then 1 buffer, we already notified the reader // (at the latest when adding the second buffer) notifyDataAvailable = !flushRequested && buffers.size() == 1; flushRequested = true; } if (notifyDataAvailable) { notifyDataAvailable(); } }
@Override public void flush() { final boolean notifyDataAvailable; synchronized (buffers) { if (buffers.isEmpty()) { return; } // if there is more then 1 buffer, we already notified the reader // (at the latest when adding the second buffer) notifyDataAvailable = !flushRequested && buffers.size() == 1; flushRequested = true; } if (notifyDataAvailable) { notifyDataAvailable(); } }
private void maybeNotifyDataAvailable() { // Notify only when we added first finished buffer. if (getNumberOfFinishedBuffers() == 1) { notifyDataAvailable(); } }
@Override public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { synchronized (buffers) { checkState(!isReleased); checkState(readView == null, "Subpartition %s of is being (or already has been) consumed, " + "but pipelined subpartitions can only be consumed once.", index, parent.getPartitionId()); LOG.debug("Creating read view for subpartition {} of partition {}.", index, parent.getPartitionId()); readView = new PipelinedSubpartitionView(this, availabilityListener); if (!buffers.isEmpty()) { notifyDataAvailable(); } } return readView; }
@Override public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { final boolean notifyDataAvailable; synchronized (buffers) { checkState(!isReleased); checkState(readView == null, "Subpartition %s of is being (or already has been) consumed, " + "but pipelined subpartitions can only be consumed once.", index, parent.getPartitionId()); LOG.debug("{}: Creating read view for subpartition {} of partition {}.", parent.getOwningTaskName(), index, parent.getPartitionId()); readView = new PipelinedSubpartitionView(this, availabilityListener); notifyDataAvailable = !buffers.isEmpty(); } if (notifyDataAvailable) { notifyDataAvailable(); } return readView; }
@Override public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException { final boolean notifyDataAvailable; synchronized (buffers) { checkState(!isReleased); checkState(readView == null, "Subpartition %s of is being (or already has been) consumed, " + "but pipelined subpartitions can only be consumed once.", index, parent.getPartitionId()); LOG.debug("{}: Creating read view for subpartition {} of partition {}.", parent.getOwningTaskName(), index, parent.getPartitionId()); readView = new PipelinedSubpartitionView(this, availabilityListener); notifyDataAvailable = !buffers.isEmpty(); } if (notifyDataAvailable) { notifyDataAvailable(); } return readView; }
private boolean add(BufferConsumer bufferConsumer, boolean finish) { checkNotNull(bufferConsumer); final boolean notifyDataAvailable; synchronized (buffers) { if (isFinished || isReleased) { bufferConsumer.close(); return false; } // Add the bufferConsumer and update the stats buffers.add(bufferConsumer); updateStatistics(bufferConsumer); increaseBuffersInBacklog(bufferConsumer); notifyDataAvailable = shouldNotifyDataAvailable() || finish; isFinished |= finish; } if (notifyDataAvailable) { notifyDataAvailable(); } return true; }
private boolean add(BufferConsumer bufferConsumer, boolean finish) { checkNotNull(bufferConsumer); final boolean notifyDataAvailable; synchronized (buffers) { if (isFinished || isReleased) { bufferConsumer.close(); return false; } // Add the bufferConsumer and update the stats buffers.add(bufferConsumer); updateStatistics(bufferConsumer); increaseBuffersInBacklog(bufferConsumer); notifyDataAvailable = shouldNotifyDataAvailable() || finish; isFinished |= finish; } if (notifyDataAvailable) { notifyDataAvailable(); } return true; }