public class OutputStatsBuffer<E> extends Object implements IBlockingBuffer<E>
SinkTransitionMetadata
.Constructor and Description |
---|
OutputStatsBuffer(IBlockingBuffer<E> b,
BOpStats stats) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Throwable cause)
Signal abnormal termination of the process writing on the buffer.
|
void |
add(E e)
Tracks
BOpStats.unitsOut and BOpStats.chunksOut . |
void |
close()
Signal that no more data will be written on this buffer (this is required
in order for the iterator to know when no more data will be made
available).
|
long |
flush()
This is a NOP since the
IBlockingBuffer.iterator() is the only way to consume
data written on the buffer. |
Future |
getFuture()
The
Future for the worker task. |
boolean |
isEmpty()
True iff there are no elements in the buffer.
|
boolean |
isOpen()
Return
true if the buffer is open. |
IAsynchronousIterator<E> |
iterator()
Return an iterator reading from the buffer.
|
void |
reset()
Reset the state of the buffer, including the counter whose value is
reported by
IBuffer.flush() . |
void |
setFuture(Future future)
Set the
Future for the source processing writing on the
IBlockingBuffer (the producer). |
int |
size()
The #of elements currently in the buffer.
|
public OutputStatsBuffer(IBlockingBuffer<E> b, BOpStats stats)
public IAsynchronousIterator<E> iterator()
IBlockingBuffer
IBlockingBuffer
by concurrent
processes in which case the order is not predictable without additional
synchronization.iterator
in interface IBlockingBuffer<E>
public void setFuture(Future future)
IBlockingBuffer
Future
for the source processing writing on the
IBlockingBuffer
(the producer).
Note: You should always wrap the task as a FutureTask
and set the
Future
on the IBlockingBuffer
before you start the
consumer. This ensures that the producer will be cancelled if the
consumer is interrupted.
setFuture
in interface IBlockingBuffer<E>
future
- The Future
.public void abort(Throwable cause)
IRunnableBuffer
abort
in interface IRunnableBuffer<E>
cause
- The exception thrown by the processing writing on the buffer.public void close()
IRunnableBuffer
close
in interface IRunnableBuffer<E>
public Future getFuture()
IRunnableBuffer
Future
for the worker task.getFuture
in interface IRunnableBuffer<E>
Future
-or- null
if no Future
has been set.public boolean isOpen()
IRunnableBuffer
true
if the buffer is open.isOpen
in interface IRunnableBuffer<E>
public long flush()
IBlockingBuffer
IBlockingBuffer.iterator()
is the only way to consume
data written on the buffer.public void add(E e)
BOpStats.unitsOut
and BOpStats.chunksOut
.
Note: BOpStats.chunksOut
will report the #of chunks added to this
buffer. However, the buffer MAY combine chunks either on add() or when
drained by the iterator so the actual #of chunks read back from the
iterator MAY differ.
Add an element to the buffer.
Note: This method is constrained to throw the specified exception if the
buffer has been IRunnableBuffer.close()
d.
public boolean isEmpty()
IBuffer
public void reset()
IBuffer
IBuffer.flush()
. Any data in the buffer will be discarded.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.