|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unister.semweb.drums.api.DRUMS<Data>
Data
- an implementation of AbstractKVStorable
, e.g. GeneralStorable
public class DRUMS<Data extends AbstractKVStorable>
An instance of this class provides access to a DRUMS-table. The instance allows managing the storage of
AbstractKVStorable
s. Use the static methods in DRUMSInstantiator
to get an instance of DRUMS
.
Use the method insertOrMerge(AbstractKVStorable...)
to insert or merge records.
To update records use the method update(AbstractKVStorable...)
.
Single selects can be performed by the method #select(byte[])
.
To perform range selects, a DRUMSReader
should be instantiated (getReader()
.
The whole table is scanned best, using an DRUMSIterator
(getIterator()
.
Nested Class Summary | |
---|---|
static class |
DRUMS.AccessMode
the accessmode for DRUMS |
Method Summary | |
---|---|
void |
close()
Closes the DRUMS. |
void |
disableForceMode()
Disable the force mode of DRUMS. |
void |
enableForceMode()
Enables the force mode of DRUMS. |
int |
findElementInReadBuffer(java.nio.ByteBuffer workingBuffer,
byte[] key,
int indexInChunk)
Searches for the given key in workingBuffer, beginning at the given index. |
BucketContainer<Data> |
getBucketContainer()
|
java.lang.String |
getDatabaseDirectory()
|
int |
getElementKeySize()
|
int |
getElementSize()
|
DRUMSParameterSet<Data> |
getGlobalParameters()
|
AbstractHashFunction |
getHashFunction()
|
DRUMSIterator<Data> |
getIterator()
Instantiates a new DRUMSIterator and returns it. |
Data |
getPrototype()
|
DRUMSReader<Data> |
getReader()
Returns a DRUMSReader . |
SyncManager<Data> |
getSyncManager()
|
void |
insertOrMerge(Data... toPersist)
Adds or merges the given data. |
void |
join()
Joins all the DRUMS-table. |
java.util.List<Data> |
read(int bucketId,
int elementOffset,
int numberToRead)
Reads numberToRead elements (or less if there are not enough elements) from the bucket with the
given bucketId beginning at the element offset. |
java.util.List<Data> |
searchForData(HeaderIndexFile<Data> indexFile,
byte[]... keys)
Searches for the AbstractKVStorable -records corresponding the given keys within the given indexFile. |
java.util.List<Data> |
select(byte[]... keys)
Selects all existing records to the keys in the given array. |
void |
setHashFunction(AbstractHashFunction hashfunction)
sets a new HashFunction. |
void |
setSynchronizerFactory(ISynchronizerFactory<Data> factory)
Expert method. |
long |
size()
|
void |
update(Data... records)
Updates the given data. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void setSynchronizerFactory(ISynchronizerFactory<Data> factory)
SynchronizerFactory
.
factory
- public BucketContainer<Data> getBucketContainer()
BucketContainer
public SyncManager<Data> getSyncManager()
SyncManager
public void insertOrMerge(Data... toPersist) throws DRUMSException, java.lang.InterruptedException
Data#merge(AbstractKVStorable)
.
toPersist
- data to insert or update
DRUMSException
- if an unexpected error occurs
java.lang.InterruptedException
- if the call blocks and the current thread is interruptedpublic void update(Data... records) throws java.io.IOException
UpdateOnlySynchronizer
, which by itself uses the Data's implemented update-function
(Data#update(AbstractKVStorable)
) to update elements. If you want to merge objects, use
#insertOrMerge(Data ...)
instead.
records
- the data to update
java.io.IOException
public java.util.List<Data> select(byte[]... keys) throws DRUMSException
keys
- the keys to look for
DRUMSException
public java.util.List<Data> read(int bucketId, int elementOffset, int numberToRead) throws FileLockException, java.io.IOException
numberToRead
elements (or less if there are not enough elements) from the bucket with the
given bucketId
beginning at the element offset.
bucketId
- the id of the bucket where to read the elements fromelementOffset
- the byte offset, where to start readingnumberToRead
- the number of elements to read
FileLockException
java.io.IOException
public java.util.List<Data> searchForData(HeaderIndexFile<Data> indexFile, byte[]... keys) throws java.io.IOException
AbstractKVStorable
-records corresponding the given keys within the given indexFile. This
is done by using the IndexForHeaderIndexFile
from the given HeaderIndexFile
. If you want to do
this in a more sequential way, try to use the method read(int, int, int)
or use an DRUMSIterator
. (getIterator()
)
indexFile
- HeaderIndexFile
, where to search for the keyskeys
- the keys to search for
ArrayList
which contains the found records. Can be less than the number of requested keys.
java.io.IOException
public long size() throws FileLockException, java.io.IOException
java.io.IOException
FileLockException
public int findElementInReadBuffer(java.nio.ByteBuffer workingBuffer, byte[] key, int indexInChunk)
workingBuffer
- the ByteBuffer to work onkey
- the key to findindexInChunk
- the start position of reading the workingBuffer
public DRUMSIterator<Data> getIterator()
DRUMSIterator
and returns it.
DRUMSIterator
public DRUMSReader<Data> getReader() throws FileLockException, java.io.IOException
DRUMSReader
. If the DRUMSReader
was not instantiated yet, it will be instantiated. If
there exists an instance, but the files were already closed, the files will be reopened.
DRUMSReader
-instance
java.io.IOException
FileLockException
public void join() throws java.lang.InterruptedException
java.lang.InterruptedException
public void close() throws java.lang.InterruptedException
java.lang.InterruptedException
public void enableForceMode()
public void disableForceMode()
public int getElementSize()
public int getElementKeySize()
public AbstractHashFunction getHashFunction()
public void setHashFunction(AbstractHashFunction hashfunction)
hashfunction
- the hash-function to setpublic java.lang.String getDatabaseDirectory()
public Data getPrototype()
public DRUMSParameterSet<Data> getGlobalParameters()
DRUMSParameterSet
that are used within the DRUMS
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |