com.unister.semweb.drums.api
Class DRUMSReader<Data extends AbstractKVStorable>

java.lang.Object
  extended by com.unister.semweb.drums.api.DRUMSReader<Data>
Type Parameters:
Data - an implementation of AbstractKVStorable, e.g. GeneralStorable

public class DRUMSReader<Data extends AbstractKVStorable>
extends java.lang.Object

This class represents an efficient direct access reader. It holds all files opened for reading. Only use this Reader, when there are no write-operations during reading. All files will be locked. Be careful: Opening all files may cost a lot of memory, because all indices are loaded.

Please use the factory-method DRUMS.getReader() get an instance of this class.

Author:
Martin Nettling

Method Summary
 void closeFiles()
          Closes all files
 java.util.List<Data> get(byte[]... keys)
          Takes a list of keys and searches for that in all buckets.
 java.util.List<Data> get(long... keys)
          Takes a list of keys and searches for that in all buckets.
 Data getNextElement(byte[] key)
          Returns the element which has exact the key or is the next largest element after this key
 Data getPreviousElement(byte[] key)
          Returns the element which has exact the key or is the next smallest element after this key
 java.util.List<Data> getRange(byte[] lowerKey, byte[] upperKey)
          Returns all elements between lowerKey and upperKey this function is still BUGGY.
 void openFiles()
          Opens all files used by the underlying HashFunction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openFiles

public void openFiles()
               throws FileLockException,
                      java.io.IOException
Opens all files used by the underlying HashFunction. The pointers are stored in files.

Throws:
FileLockException
java.io.IOException

getRange

public java.util.List<Data> getRange(byte[] lowerKey,
                                     byte[] upperKey)
                                                         throws java.io.IOException
Returns all elements between lowerKey and upperKey this function is still BUGGY.

TODO: fix this function. @Nils Why is this function buggy?

Parameters:
lowerKey -
upperKey -
Returns:
a list containing all elements between lowerKey and upperKey
Throws:
java.io.IOException

getPreviousElement

public Data getPreviousElement(byte[] key)
                                                   throws java.io.IOException
Returns the element which has exact the key or is the next smallest element after this key

Parameters:
key -
Returns:
the first element, which can be found before the given key
Throws:
java.io.IOException

getNextElement

public Data getNextElement(byte[] key)
                                               throws java.io.IOException
Returns the element which has exact the key or is the next largest element after this key

Parameters:
key -
Returns:
the first element, which can be found after the given key
Throws:
java.io.IOException

get

public java.util.List<Data> get(long... keys)
                                                    throws DRUMSException,
                                                           java.io.IOException
Takes a list of keys and searches for that in all buckets.

Parameters:
keys -
Returns:
ArrayList
Throws:
DRUMSException
java.io.IOException

get

public java.util.List<Data> get(byte[]... keys)
                                                    throws DRUMSException,
                                                           java.io.IOException
Takes a list of keys and searches for that in all buckets.

Parameters:
keys -
Returns:
ArrayList
Throws:
DRUMSException
java.io.IOException

closeFiles

public void closeFiles()
Closes all files