org.openrdf.sesame.sailimpl.nativerdf.datastore
Class DataStore

java.lang.Object
  extended byorg.openrdf.sesame.sailimpl.nativerdf.datastore.DataStore

public class DataStore
extends Object

Class that provides indexed storage and retrieval of RDF values.


Constructor Summary
DataStore(File dataDir, String filePrefix)
           
 
Method Summary
 void clear()
          Removes all values from the DataStore.
 void close()
          Closes the DataStore, releasing any file references, etc.
 void commitTransaction()
          Commits a transaction, applying all updates that have been performed during the transaction.
 byte[] getData(int id)
          Gets the value for the specified ID.
 byte[] getData(int id, boolean dirtyReads)
          Gets the value for the specified ID, optionally searching the non-commited data.
 int getID(byte[] queryData)
          Gets the ID for the specified value.
 int getID(byte[] queryData, boolean dirtyReads)
          Gets the ID for the specified value, optionally search the non-committed data.
 int getMaxID()
          Returns the maximum ID value.
static void main(String[] args)
           
 void rollbackTransaction()
          Rolls back all updates that have been performed in the current transaction and closes it.
 void startTransaction()
          Starts a transaction.
 int storeData(byte[] data)
          Stores the supplied value and returns the ID that has been assigned to it.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataStore

public DataStore(File dataDir,
                 String filePrefix)
          throws IOException
Method Detail

getData

public byte[] getData(int id)
               throws IOException
Gets the value for the specified ID.

Parameters:
id - A value ID.
Returns:
The value for the ID, or null no such value could be found.
Throws:
IOException - If an I/O error occurred.

getData

public byte[] getData(int id,
                      boolean dirtyReads)
               throws IOException
Gets the value for the specified ID, optionally searching the non-commited data.

Parameters:
id - A value ID.
dirtyReads - Flag indicating whether the non-commited data should be searched.
Returns:
The value for the ID, or null if no such value could be found.
Throws:
IOException - If an I/O error occurred.

getID

public int getID(byte[] queryData)
          throws IOException
Gets the ID for the specified value.

Parameters:
queryData - A value.
Returns:
The ID for the specified value, or 0 if no such ID could be found.
Throws:
IOException - If an I/O error occurred.

getID

public int getID(byte[] queryData,
                 boolean dirtyReads)
          throws IOException
Gets the ID for the specified value, optionally search the non-committed data.

Parameters:
queryData - A value.
dirtyReads - Flag indicating whether the non-commited data should be searched.
Returns:
The ID for the specified value, or 0 if no such ID could be found.
Throws:
IOException - If an I/O error occurred.

getMaxID

public int getMaxID()
             throws IOException
Returns the maximum ID value.

Throws:
IOException

startTransaction

public void startTransaction()
                      throws IOException
Starts a transaction. This prepares the DataStore for upcoming updates to the stored data.

Throws:
IOException - If an I/O error occurred.

commitTransaction

public void commitTransaction()
                       throws IOException
Commits a transaction, applying all updates that have been performed during the transaction.

Throws:
IOException - If an I/O error occurred.

rollbackTransaction

public void rollbackTransaction()
                         throws IOException
Rolls back all updates that have been performed in the current transaction and closes it.

Throws:
IOException - If an I/O error occurred.

storeData

public int storeData(byte[] data)
              throws IOException
Stores the supplied value and returns the ID that has been assigned to it. In case the data to store is already present, the ID of this existing data is returned. This method can only be called as part of a transaction.

Parameters:
data - The data to store.
Returns:
The ID that has been assigned to the value.
Throws:
IOException - If an I/O error occurred.
See Also:
startTransaction(), commitTransaction()

clear

public void clear()
           throws IOException
Removes all values from the DataStore. This method can only be called as part of a transaction. The DataStore will not be cleared until the transaction is committed.

Throws:
IOException - If an I/O error occurred.
See Also:
startTransaction(), commitTransaction()

close

public void close()
           throws IOException
Closes the DataStore, releasing any file references, etc. In case a transaction is currently open, it will be rolled back. Once closed, the DataStore can no longer be used.

Throws:
IOException - If an I/O error occurred.

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.