org.trippi.impl.base
Class SynchronizedTriplestoreWriter

java.lang.Object
  extended by org.trippi.impl.base.SynchronizedTriplestoreReader
      extended by org.trippi.impl.base.SynchronizedTriplestoreWriter
All Implemented Interfaces:
TriplestoreReader, TriplestoreWriter

public class SynchronizedTriplestoreWriter
extends SynchronizedTriplestoreReader
implements TriplestoreWriter

A SynchronizedTriplestoreReader that also implements TriplestoreWriter with concurrent buffered write access.

Author:
cwilper@cs.cornell.edu

Constructor Summary
SynchronizedTriplestoreWriter(SynchronizedTriplestoreSession session, AliasManager aliasManager, int flushSize)
          Construct.
 
Method Summary
 void add(java.util.List triples, boolean flush)
          Immediately add all triples in the list to the store, then return.
 void add(org.jrdf.graph.Triple triple, boolean flush)
          Immediately add the given triple to the store, then return.
 void add(TripleIterator iter, boolean flush)
          Immediately add all triples in the iterator to the store, then return.
 void delete(java.util.List triples, boolean flush)
          Remove a series of triples from the store.
 void delete(org.jrdf.graph.Triple triple, boolean flush)
          Immediately delete the given triple from the store, then return.
 void delete(TripleIterator iter, boolean flush)
          Remove a series of triples from the store.
 java.util.List findBufferedUpdates(org.jrdf.graph.SubjectNode subject, org.jrdf.graph.PredicateNode predicate, org.jrdf.graph.ObjectNode object, int updateType)
          Returns an unmodifiable List of TripleUpdates currently in queue.
 void flushBuffer()
          Flush the buffer (write the changes to the triplestore).
 int getBufferSize()
          Get the current size of the buffer.
 void setFlushErrorHandler(FlushErrorHandler h)
          Set the (optional) handler that will recieve failed flush notification.
 
Methods inherited from class org.trippi.impl.base.SynchronizedTriplestoreReader
close, countTriples, countTriples, countTriples, countTuples, finalize, findTriples, findTriples, findTriples, findTuples, getAliasMap, listTripleLanguages, listTupleLanguages, setAliasMap
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.trippi.TriplestoreReader
close, countTriples, countTriples, countTriples, countTuples, findTriples, findTriples, findTriples, findTuples, getAliasMap, listTripleLanguages, listTupleLanguages, setAliasMap
 

Constructor Detail

SynchronizedTriplestoreWriter

public SynchronizedTriplestoreWriter(SynchronizedTriplestoreSession session,
                                     AliasManager aliasManager,
                                     int flushSize)
Construct.

Method Detail

add

public void add(java.util.List triples,
                boolean flush)
         throws TrippiException
Immediately add all triples in the list to the store, then return.

Specified by:
add in interface TriplestoreWriter
Parameters:
triples - a list of Triple objects
flush - whether to flush the buffer before returning
Throws:
TrippiException

add

public void add(TripleIterator iter,
                boolean flush)
         throws java.io.IOException,
                TrippiException
Immediately add all triples in the iterator to the store, then return.

Specified by:
add in interface TriplestoreWriter
Parameters:
iter - an iterator over the triples
flush - whether to flush the buffer before returning
Throws:
java.io.IOException
TrippiException

add

public void add(org.jrdf.graph.Triple triple,
                boolean flush)
         throws TrippiException
Immediately add the given triple to the store, then return.

Specified by:
add in interface TriplestoreWriter
Parameters:
triple - the Triple to add
flush - whether to flush the buffer before returning
Throws:
TrippiException

delete

public void delete(java.util.List triples,
                   boolean flush)
            throws java.io.IOException,
                   TrippiException
Remove a series of triples from the store. This implementation actually buffers the triples for asychronous deletion, which will occur in the updater thread when bufferSize or dormantSeconds is reached. However, if flush is true, the buffer will be flushed in this thread before returning.

Specified by:
delete in interface TriplestoreWriter
Parameters:
triples - a list of Triple objects
flush - whether to flush the buffer before returning
Throws:
java.io.IOException
TrippiException

delete

public void delete(TripleIterator iter,
                   boolean flush)
            throws java.io.IOException,
                   TrippiException
Description copied from interface: TriplestoreWriter
Remove a series of triples from the store.

Specified by:
delete in interface TriplestoreWriter
Parameters:
iter - an iterator over the triples
flush - whether to flush the buffer before returning
Throws:
java.io.IOException
TrippiException

delete

public void delete(org.jrdf.graph.Triple triple,
                   boolean flush)
            throws java.io.IOException,
                   TrippiException
Immediately delete the given triple from the store, then return.

Specified by:
delete in interface TriplestoreWriter
Parameters:
triple - the Triple to delete
flush - whether to flush the buffer before returning
Throws:
java.io.IOException
TrippiException

flushBuffer

public void flushBuffer()
Description copied from interface: TriplestoreWriter
Flush the buffer (write the changes to the triplestore).

Specified by:
flushBuffer in interface TriplestoreWriter

setFlushErrorHandler

public void setFlushErrorHandler(FlushErrorHandler h)
Description copied from interface: TriplestoreWriter
Set the (optional) handler that will recieve failed flush notification. Applications can use this to ensure that the contents of the buffer are not lost when a flushing error occurs.

Specified by:
setFlushErrorHandler in interface TriplestoreWriter

getBufferSize

public int getBufferSize()
Description copied from interface: TriplestoreWriter
Get the current size of the buffer.

Specified by:
getBufferSize in interface TriplestoreWriter

findBufferedUpdates

public java.util.List findBufferedUpdates(org.jrdf.graph.SubjectNode subject,
                                          org.jrdf.graph.PredicateNode predicate,
                                          org.jrdf.graph.ObjectNode object,
                                          int updateType)
Description copied from interface: TriplestoreWriter
Returns an unmodifiable List of TripleUpdates currently in queue.

Specified by:
findBufferedUpdates in interface TriplestoreWriter
Returns:
unmodifiable List of TripleUpdates currently in queue