|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.relation.accesspath.AbstractArrayBuffer<E>
public abstract class AbstractArrayBuffer<E>
A thread-safe buffer backed by a fixed capacity array. Concrete
implementations must empty the buffer in flush(int, Object[]).
| Field Summary | |
|---|---|
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 static boolean |
DEBUG
|
protected IElementFilter<E> |
filter
An optional filter for keeping elements out of the buffer. |
protected static boolean |
INFO
|
protected static org.apache.log4j.Logger |
log
|
protected int |
size
|
| Constructor Summary | |
|---|---|
protected |
AbstractArrayBuffer(int capacity,
Class cls,
IElementFilter<E> filter)
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
protected static final boolean INFO
protected static final boolean DEBUG
protected final int capacity
protected final Class cls
protected final IElementFilter<E> filter
protected int size
protected E[] buffer
| Constructor Detail |
|---|
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.| Method Detail |
|---|
public boolean isEmpty()
size() reports zero(0).
isEmpty in interface IBuffer<E>public int size()
size in interface IBuffer<E>protected boolean accept(E e)
e - Some element.
true iff the buffer accepts the element.public void add(E e)
IBuffer
add in interface IBuffer<E>e - The elementpublic long flush()
IBufferIRelation 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 IMutableRelationpublic void reset()
IBufferIBuffer.flush(). Any data in the buffer will be discarded.
reset in interface IBuffer<E>
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).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||