|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdbm.helper.RecordManagerImpl
jdbm.recman.BaseRecordManager
public final class BaseRecordManager
This class manages records, which are uninterpreted blobs of data. The set of operations is simple and straightforward: you communicate with the class using long "rowids" and byte[] data blocks. Rowids are returned on inserts and you can stash them away someplace safe to be able to get back to them. Data blocks can be as long as you wish, and may have lengths different from the original when updating.
Operations are synchronized, so that only one of them will happen concurrently even if you hammer away from multiple threads. Operations are made atomic by keeping a transaction log which is recovered after a crash, so the operations specified by this interface all have ACID properties.
You identify a file by just the name. The package attaches .db for the database file, and .lg for the transaction log. The transaction log is synchronized regularly and then restarted, so don't worry if you see the size going up and down.
Field Summary | |
---|---|
static boolean |
DEBUG
Static debugging flag |
static int |
NAME_DIRECTORY_ROOT
Reserved slot for name directory. |
static int |
STORE_VERSION_NUMBER_ROOT
Reserved slot for version number |
Fields inherited from interface jdbm.RecordManager |
---|
NULL_RECID |
Constructor Summary | |
---|---|
BaseRecordManager(java.lang.String filename)
Creates a record manager for the indicated file |
Method Summary | ||
---|---|---|
void |
clearCache()
Empty cache. |
|
void |
close()
Closes the record manager. |
|
void |
commit()
Commit (make persistent) all changes since beginning of transaction. |
|
void |
defrag()
Defragments storage, so it consumes less space. |
|
void |
delete(long logRowId)
Deletes a record. |
|
void |
disableTransactions()
Switches off transactioning for the record manager. |
|
|
fetch(long recid,
Serializer<A> serializer)
Fetches a record using a custom serializer. |
|
|
fetch(long recid,
Serializer<A> serializer,
boolean disableCache)
Fetches a record using a custom serializer and optionaly disabled cache |
|
long |
getNamedObject(java.lang.String name)
Obtain the record id of a named object. |
|
long |
getRoot(int id)
|
|
int |
getRootCount()
|
|
|
insert(A obj,
Serializer<A> serializer)
Inserts a new record using a custom serializer. |
|
boolean |
isAppendToEnd()
if true, new records alwayes saved to end of file and free space is not reclaimed. |
|
void |
rollback()
Rollback (cancel) all changes since beginning of transaction. |
|
void |
setAppendToEnd(boolean appendToEnd)
if true, new records alwayes saved to end of file and free space is not reclaimed. |
|
void |
setCompress(boolean b)
Enable or disable compression of blocks with Deflate algorithm |
|
void |
setNamedObject(java.lang.String name,
long recid)
Set the record id of a named object. |
|
void |
setRoot(int id,
long rowid)
|
|
|
update(long recid,
A obj,
Serializer<A> serializer)
Updates a record using a custom serializer. |
Methods inherited from class jdbm.helper.RecordManagerImpl |
---|
fetch, hashMap, hashMap, hashMap, insert, storeMap, storeMap, treeMap, treeMap, treeMap, treeMap, treeMap, treeMap, update |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean DEBUG
public static final int NAME_DIRECTORY_ROOT
public static final int STORE_VERSION_NUMBER_ROOT
Constructor Detail |
---|
public BaseRecordManager(java.lang.String filename) throws java.io.IOException
java.io.IOException
- when the file cannot be opened or is not
a valid file content-wise.Method Detail |
---|
public boolean isAppendToEnd()
public void setAppendToEnd(boolean appendToEnd)
public void disableTransactions()
Only call this method directly after opening the file, otherwise the results will be undefined.
public void setCompress(boolean b)
b
- public void close() throws java.io.IOException
java.io.IOException
- when one of the underlying I/O operations fails.public <A> long insert(A obj, Serializer<A> serializer) throws java.io.IOException
obj
- the object for the new record.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations fails.public void delete(long logRowId) throws java.io.IOException
RecordManager
logRowId
- the rowid for the record that should be deleted.
java.io.IOException
- when one of the underlying I/O operations fails.public <A> void update(long recid, A obj, Serializer<A> serializer) throws java.io.IOException
RecordManager
recid
- the recid for the record that is to be updated.obj
- the new object for the record.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations failspublic <A> A fetch(long recid, Serializer<A> serializer) throws java.io.IOException
RecordManager
recid
- the recid for the record that must be fetched.serializer
- a custom serializer
java.io.IOException
- when one of the underlying I/O operations fails.public <A> A fetch(long recid, Serializer<A> serializer, boolean disableCache) throws java.io.IOException
RecordManager
recid
- the recid for the record that must be fetched.serializer
- a custom serializerdisableCache
- true to disable any caching mechanism
java.io.IOException
- when one of the underlying I/O operations fails.public int getRootCount()
public long getRoot(int id) throws java.io.IOException
java.io.IOException
public void setRoot(int id, long rowid) throws java.io.IOException
java.io.IOException
public long getNamedObject(java.lang.String name) throws java.io.IOException
RecordManager
java.io.IOException
public void setNamedObject(java.lang.String name, long recid) throws java.io.IOException
RecordManager
java.io.IOException
public void commit() throws java.io.IOException
RecordManager
java.io.IOException
public void rollback() throws java.io.IOException
RecordManager
java.io.IOException
public void clearCache() throws java.io.IOException
RecordManager
java.io.IOException
public void defrag() throws java.io.IOException
RecordManager
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |