public abstract class AbstractUnsynchronizedArrayBuffer<E> extends Object implements IBuffer<E>
This implementation is NOT thread-safe.
Constructor and Description |
---|
AbstractUnsynchronizedArrayBuffer(int capacity,
Class<? extends E> cls) |
AbstractUnsynchronizedArrayBuffer(int capacity,
Class<? extends E> cls,
IElementFilter<E> filter) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(E e)
Applies the optional filter to restrict elements allowed into the buffer.
|
void |
add(E e)
Not thread-safe.
|
boolean |
add2(E e)
Adds an element to the buffer.
|
long |
flush()
Flush the buffer and return the #of elements written on the backing
IRelation since the counter was last IBuffer.reset() (the
mutationCount). |
protected abstract void |
handleChunk(E[] chunk)
Dispatch a chunk.
|
boolean |
isEmpty()
If
size() reports zero(0). |
protected void |
overflow()
Adds all references in the internal buffer to the target buffer, resets
the #of elements in the internal buffer to ZERO (0), and clears the
internal array - it will be reallocated again on demand.
|
void |
reset()
Reset the state of the buffer, including the counter whose value is
reported by
IBuffer.flush() . |
int |
size()
The exact #of elements currently in the buffer.
|
public AbstractUnsynchronizedArrayBuffer(int capacity, Class<? extends E> cls)
capacity
- The capacity of the backing buffer.cls
- The component type for the backing array.public AbstractUnsynchronizedArrayBuffer(int capacity, Class<? extends E> cls, IElementFilter<E> filter)
capacity
- The capacity of the backing buffer.cls
- The component type for the backing array.filter
- Filter to keep elements out of the buffer (optional).public final boolean isEmpty()
size()
reports zero(0).public final int size()
protected boolean accept(E e)
e
- A element.public final void add(E e)
public boolean add2(E e)
e
- An element.true
iff adding the element caused the buffer to
overflow()
protected void overflow()
protected abstract void handleChunk(E[] chunk)
chunk
- A chunk.public long flush()
IBuffer
IRelation
since the counter was last IBuffer.reset()
(the
mutationCount).
Note: If the buffer does not write on an IRelation
then it SHOULD
return ZERO(0).
flush
in interface IBuffer<E>
IRelation
.
See IMutableRelation
public void reset()
IBuffer
IBuffer.flush()
. Any data in the buffer will be discarded.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.