Package com.coyotegulch.jisp
Interface ObjectIndex
-
- All Known Implementing Classes:
BTreeIndex,HashIndex
public interface ObjectIndexObjectIndexdefines the concept of anindexthat associateskeyvalues with references to serializable objects. Concrete subclasses ofObjectIndexassume that an object'sposition(as given by alongvalue) is constant, regardless of the actual meaning of that position. In general, the position represents the * location (file pointer) of aSerializableobject in anIndexedObjectDatabase. ** Use the
IndexedObjectDatabase.attachIndexmethod to attach anObjectIndex* to a database. A database updates all attached indexes when it writes or removes objects * from its file.- See Also:
ObjectIndex,IndexedObjectDatabase
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longfindKey(KeyObject key)Find the position of the object associated with a given key.voidinsertKey(KeyObject key, long pos)Insert a key into the database, associating a record position with the given key.voidremoveKey(KeyObject key)Removes the given key from the index.voidreplaceKey(KeyObject key, long pos)Replace the reference pos for the given key.voidstoreKey(KeyObject key, long pos)If the key already exists, replace the reference pos for the given key.
-
-
-
Method Detail
-
insertKey
void insertKey(KeyObject key, long pos) throws java.io.IOException, java.lang.ClassNotFoundException
Insert a key into the database, associating a record position with the given key. Throws aDuplicateKeyexception if the key already exists.- Parameters:
key- A key identifying the record to be read.pos- File position of record associated with key- Throws:
java.io.IOException- when an I/O exception is thrown by an underlying java.io.* classjava.lang.ClassNotFoundException- for a casting error, usually when a persistent object or index does match the expected typeDuplicateKey- when inserting a duplicate key into an index that does not support duplicates- See Also:
DuplicateKey,KeyObject
-
replaceKey
void replaceKey(KeyObject key, long pos) throws java.io.IOException, java.lang.ClassNotFoundException
Replace the reference pos for the given key. Throws aKeyNotFoundexception if the requested key does not exist in the index.- Parameters:
key- A key identifying the record to be read.pos- File position of record associated with key- Throws:
java.io.IOException- when an I/O exception is thrown by an underlying java.io.* classjava.lang.ClassNotFoundException- for a casting error, usually when a persistent object or index does match the expected typeKeyNotFound- when the specified key can not be found in the index- See Also:
KeyNotFound,KeyObject
-
storeKey
void storeKey(KeyObject key, long pos) throws java.io.IOException, java.lang.ClassNotFoundException
If the key already exists, replace the reference pos for the given key. Otherwise, insert a key into the database, associating a record position with the given key.- Parameters:
key- A key identifying the record to be read.pos- File position of record associated with key- Throws:
java.io.IOException- when an I/O exception is thrown by an underlying java.io.* classjava.lang.ClassNotFoundException- for a casting error, usually when a persistent object or index does match the expected type- See Also:
KeyObject
-
findKey
long findKey(KeyObject key) throws java.io.IOException, java.lang.ClassNotFoundException
Find the position of the object associated with a given key.- Parameters:
key- A key identifying the record to be read.- Returns:
- The position of the record associated with
key. - Throws:
java.io.IOException- when an I/O exception is thrown by an underlying java.io.* classjava.lang.ClassNotFoundException- for a casting error, usually when a persistent object or index does match the expected typeKeyNotFound- when the specified key can not be found in the index- See Also:
KeyNotFound,KeyObject
-
removeKey
void removeKey(KeyObject key) throws java.io.IOException, java.lang.ClassNotFoundException
Removes the given key from the index.- Parameters:
key- A key identifying the record to be read.- Throws:
java.io.IOException- when an I/O exception is thrown by an underlying java.io.* classjava.lang.ClassNotFoundException- for a casting error, usually when a persistent object or index does match the expected typeKeyNotFound- when the specified key can not be found in the index- See Also:
KeyNotFound,KeyObject
-
-