|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.cdegroot.db.recman.RecordManager
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.
Constructor Summary | |
RecordManager(String filename)
Creates a record manager for the indicated file |
Method Summary | |
void |
close()
Closes the record manager. |
void |
delete(long recid)
Deletes a record. |
void |
disableTransactions()
Switches off transactioning for the record manager. |
byte[] |
fetch(long recid)
Fetches a record. |
long |
getRoot(int id)
Returns the indicated root rowid. |
int |
getRootCount()
Returns the number of slots available for "root" rowids. |
long |
insert(byte[] data)
Inserts a new record. |
void |
setRoot(int id,
long rowid)
Sets the indicated root rowid. |
void |
update(long recid,
byte[] data)
Updates a record. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public RecordManager(String filename) throws IOException
Method Detail |
public void disableTransactions()
Only call this method directly after opening the file, otherwise the results will be undefined.
public void close() throws IOException
public long insert(byte[] data) throws IOException
data
- the data for the new record.public void delete(long recid) throws IOException
rowid
- the rowid for the record that should be deleted.public void update(long recid, byte[] data) throws IOException
recid
- the recid for the record that is to be updated.data
- the new data for the record.public byte[] fetch(long recid) throws IOException
recid
- the recid for the record that must be fetched.public int getRootCount()
public long getRoot(int id) throws IOException
getRootCount
public void setRoot(int id, long rowid) throws IOException
getRootCount
|
Homepage | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |