public abstract class AbstractArrayBuffer<E> extends Object implements IBuffer<E>
flush(int, Object[])
.Modifier and Type | Field and Description |
---|---|
protected E[] |
buffer |
protected int |
capacity
The capacity of the backing buffer.
|
protected Class |
cls
The component type of the backing byte, used when a new instance is
allocated.
|
protected IElementFilter<E> |
filter
An optional filter for keeping elements out of the buffer.
|
protected int |
size |
Modifier | Constructor and Description |
---|---|
protected |
AbstractArrayBuffer(int capacity,
Class cls,
IElementFilter<E> filter) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(E e)
Filters elements allowed into the buffer.
|
void |
add(E e)
Add 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 long |
flush(int n,
E[] a)
This method is automatically invoked if the buffer is flushed and it is
non-empty.
|
boolean |
isEmpty()
If
size() reports zero(0). |
void |
reset()
Reset the state of the buffer, including the counter whose value is
reported by
IBuffer.flush() . |
int |
size()
The approximate #of elements in the buffer.
|
protected final int capacity
protected final Class cls
protected final IElementFilter<E> filter
protected int size
protected E[] buffer
protected AbstractArrayBuffer(int capacity, Class cls, IElementFilter<E> filter)
capacity
- The capacity of the backing buffer.cls
- Array instances of this component type will be allocated.filter
- An optional filter for keeping elements out of the buffer.public boolean isEmpty()
size()
reports zero(0).public int size()
protected boolean accept(E e)
e
- Some element.true
iff the buffer accepts the element.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.protected abstract long flush(int n, E[] a)
n
- The #of elements in the array.a
- The array of elements.flush()
, this is not a
cumulative counter, but the #of modified elements in the relation
for this operation only).Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.