com.bigdata.relation.accesspath
Class AbstractElementBuffer<R>

java.lang.Object
  extended by com.bigdata.relation.accesspath.AbstractArrayBuffer<R>
      extended by com.bigdata.relation.accesspath.AbstractElementBuffer<R>
Type Parameters:
R - The generic type of the [R]elation elements.
All Implemented Interfaces:
IBuffer<R>
Direct Known Subclasses:
AbstractElementBuffer.DeleteBuffer, AbstractElementBuffer.InsertBuffer

public abstract class AbstractElementBuffer<R>
extends AbstractArrayBuffer<R>

Base class for IBuffer of IRelation elements whose target is a mutation (insert, delete, or update) of some IMutableRelation.

Version:
$Id: AbstractElementBuffer.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
IMutableRelation

Nested Class Summary
static class AbstractElementBuffer.DeleteBuffer<R>
          Buffer writes on IMutableRelation.delete(IChunkedOrderedIterator) when it is flushed.
static class AbstractElementBuffer.InsertBuffer<R>
          Buffer writes on IMutableRelation.insert(IChunkedOrderedIterator) when it is flushed.
 
Field Summary
 
Fields inherited from class com.bigdata.relation.accesspath.AbstractArrayBuffer
buffer, capacity, cls, DEBUG, filter, INFO, log, size
 
Constructor Summary
protected AbstractElementBuffer(int capacity, IMutableRelation<R> relation, IKeyOrder<R> keyOrder, IElementFilter<R> filter)
           
 
Method Summary
protected abstract  long flush(IChunkedOrderedIterator<R> itr)
          Concrete implementations must process the elements, causing the appropriate mutation on the target IRelation.
protected  long flush(int n, R[] a)
          Delegates to flush(IChunkedOrderedIterator)
protected  IKeyOrder<R> getKeyOrder()
          The natural order in which the elements will appear in the buffer -or- null if you do not have a strong guarentee for that order (from the ctor).
protected  IMutableRelation<R> getRelation()
           
 
Methods inherited from class com.bigdata.relation.accesspath.AbstractArrayBuffer
accept, add, flush, isEmpty, reset, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractElementBuffer

protected AbstractElementBuffer(int capacity,
                                IMutableRelation<R> relation,
                                IKeyOrder<R> keyOrder,
                                IElementFilter<R> filter)
Parameters:
capacity - The buffer capacity.
relation - The target relation.
keyOrder - The natural order in which the elements will appear in the buffer -or- null if you do not have a strong guarantee for that order.
filter - An optional filter for keeping elements out of the buffer.
Method Detail

getRelation

protected IMutableRelation<R> getRelation()

getKeyOrder

protected IKeyOrder<R> getKeyOrder()
The natural order in which the elements will appear in the buffer -or- null if you do not have a strong guarentee for that order (from the ctor).


flush

protected final long flush(int n,
                           R[] a)
Delegates to flush(IChunkedOrderedIterator)

Specified by:
flush in class AbstractArrayBuffer<R>
Parameters:
n - The #of elements in the array.
a - The array of elements.
Returns:
The #of elements that were modified in the backing relation when the buffer was flushed (unlike AbstractArrayBuffer.flush(), this is not a cumulative counter, but the #of modified elements in the relation for this operation only).

flush

protected abstract long flush(IChunkedOrderedIterator<R> itr)
Concrete implementations must process the elements, causing the appropriate mutation on the target IRelation.

Note: The elements generally appear in an arbitrary order and need to be sorted into ordered chunks using IKeyOrder.getComparator() for the desired natural order(s).

Parameters:
itr -
Returns:
The #of elements that were modified in the backing relation when the buffer was flushed


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.