com.bigdata.relation.rule.eval
Class AbstractSolutionBuffer<R>

java.lang.Object
  extended by com.bigdata.relation.accesspath.AbstractArrayBuffer<ISolution<R>[]>
      extended by com.bigdata.relation.rule.eval.AbstractSolutionBuffer<R>
Type Parameters:
R - The generic type of the [R]elation elements.
All Implemented Interfaces:
IBuffer<ISolution<R>[]>
Direct Known Subclasses:
AbstractSolutionBuffer.DeleteSolutionBuffer, AbstractSolutionBuffer.InsertSolutionBuffer, RDFJoinNexus.InsertSPOAndJustificationBuffer

public abstract class AbstractSolutionBuffer<R>
extends AbstractArrayBuffer<ISolution<R>[]>

Base class for IBuffer whose target is a mutation (insert, delete, or update) of some IMutableRelation. Note that this buffers chunks of ISolutions NOT relation elements.

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

Nested Class Summary
static class AbstractSolutionBuffer.DeleteSolutionBuffer<E>
          Buffer writes on IMutableRelation.delete(IChunkedOrderedIterator) when it is flushed.
static class AbstractSolutionBuffer.InsertSolutionBuffer<E>
          Buffer writes on IMutableRelation#insert(IChunkedIterator) when it is flushed.
 
Field Summary
 
Fields inherited from class com.bigdata.relation.accesspath.AbstractArrayBuffer
buffer, capacity, cls, filter, size
 
Constructor Summary
protected AbstractSolutionBuffer(int capacity, IMutableRelation<R> relation)
           
 
Method Summary
protected abstract  long flush(IChunkedOrderedIterator<ISolution<R>> itr)
          Concrete implementations must process the ISolutions, causing the appropriate mutation on the target IRelation.
protected  long flush(int n, ISolution<R>[][] a)
          Combines chunks of solutions together into a single chunk and then delegates to flush(IChunkedOrderedIterator).
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

AbstractSolutionBuffer

protected AbstractSolutionBuffer(int capacity,
                                 IMutableRelation<R> relation)
Parameters:
capacity -
Method Detail

getRelation

protected IMutableRelation<R> getRelation()

flush

protected final long flush(int n,
                           ISolution<R>[][] a)
Combines chunks of solutions together into a single chunk and then delegates to flush(IChunkedOrderedIterator).

Note: Combining chunks together is a huge performance win if the source chunks tend to be small (100). For example, this is true for scale-out joins such as LUBM U1 EDS. There the performance gain is better than 20:1.

Specified by:
flush in class AbstractArrayBuffer<ISolution<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<ISolution<R>> itr)
Concrete implementations must process the ISolutions, causing the appropriate mutation on the target IRelation.

Note: The ISolutions generally appear in an arbitrary order. They can either be resolved to IRelation elements or be sorted into ordered ISolution chunks using a SolutionComparator.

Parameters:
itr - The iterator (the order of the elements is unknown).
Returns:
The #of elements that were modified in the backing relation when the buffer was flushed


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