jdbm
Interface RecordManager

All Known Implementing Classes:
BaseRecordManager, CacheRecordManager

public interface RecordManager

An interface to manages records, which are uninterpreted blobs of data.

The set of record operations is simple: fetch, insert, update and delete. Each record is identified using a "rowid" and contains a byte[] data block. Rowids are returned on inserts and you can store them 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.

Version:
$Id: RecordManager.java,v 1.3 2005/06/25 23:12:31 doomdark Exp $
Author:
Alex Boisvert, Cees de Groot

Field Summary
static int NAME_DIRECTORY_ROOT
          Reserved slot for name directory.
 
Method Summary
 void close()
          Closes the record manager.
 void commit()
          Commit (make persistent) all changes since beginning of transaction.
 void delete(long recid)
          Deletes a record.
 java.lang.Object fetch(long recid)
          Fetches a record using standard java object serialization.
 java.lang.Object fetch(long recid, Serializer serializer)
          Fetches a record using a custom serializer.
 long getNamedObject(java.lang.String name)
          Obtain the record id of a named object.
 long getRoot(int id)
          Returns the indicated root rowid.
 int getRootCount()
          Returns the number of slots available for "root" rowids.
 long insert(java.lang.Object obj)
          Inserts a new record using standard java object serialization.
 long insert(java.lang.Object obj, Serializer serializer)
          Inserts a new record using a custom serializer.
 void rollback()
          Rollback (cancel) all changes since beginning of transaction.
 void setNamedObject(java.lang.String name, long recid)
          Set the record id of a named object.
 void setRoot(int id, long rowid)
          Sets the indicated root rowid.
 void update(long recid, java.lang.Object obj)
          Updates a record using standard java object serialization.
 void update(long recid, java.lang.Object obj, Serializer serializer)
          Updates a record using a custom serializer.
 

Field Detail

NAME_DIRECTORY_ROOT

static final int NAME_DIRECTORY_ROOT
Reserved slot for name directory.

See Also:
Constant Field Values
Method Detail

insert

long insert(java.lang.Object obj)
            throws java.io.IOException
Inserts a new record using standard java object serialization.

Parameters:
obj - the object for the new record.
Returns:
the rowid for the new record.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

insert

long insert(java.lang.Object obj,
            Serializer serializer)
            throws java.io.IOException
Inserts a new record using a custom serializer.

Parameters:
obj - the object for the new record.
serializer - a custom serializer
Returns:
the rowid for the new record.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

delete

void delete(long recid)
            throws java.io.IOException
Deletes a record.

Parameters:
recid - the rowid for the record that should be deleted.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

update

void update(long recid,
            java.lang.Object obj)
            throws java.io.IOException
Updates a record using standard java object serialization.

Parameters:
recid - the recid for the record that is to be updated.
obj - the new object for the record.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

update

void update(long recid,
            java.lang.Object obj,
            Serializer serializer)
            throws java.io.IOException
Updates a record using a custom serializer.

Parameters:
recid - the recid for the record that is to be updated.
obj - the new object for the record.
serializer - a custom serializer
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

fetch

java.lang.Object fetch(long recid)
                       throws java.io.IOException
Fetches a record using standard java object serialization.

Parameters:
recid - the recid for the record that must be fetched.
Returns:
the object contained in the record.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

fetch

java.lang.Object fetch(long recid,
                       Serializer serializer)
                       throws java.io.IOException
Fetches a record using a custom serializer.

Parameters:
recid - the recid for the record that must be fetched.
serializer - a custom serializer
Returns:
the object contained in the record.
Throws:
java.io.IOException - when one of the underlying I/O operations fails.

close

void close()
           throws java.io.IOException
Closes the record manager.

Throws:
java.io.IOException - when one of the underlying I/O operations fails.

getRootCount

int getRootCount()
Returns the number of slots available for "root" rowids. These slots can be used to store special rowids, like rowids that point to other rowids. Root rowids are useful for bootstrapping access to a set of data.


getRoot

long getRoot(int id)
             throws java.io.IOException
Returns the indicated root rowid.

Throws:
java.io.IOException
See Also:
getRootCount()

setRoot

void setRoot(int id,
             long rowid)
             throws java.io.IOException
Sets the indicated root rowid.

Throws:
java.io.IOException
See Also:
getRootCount()

commit

void commit()
            throws java.io.IOException
Commit (make persistent) all changes since beginning of transaction.

Throws:
java.io.IOException

rollback

void rollback()
              throws java.io.IOException
Rollback (cancel) all changes since beginning of transaction.

Throws:
java.io.IOException

getNamedObject

long getNamedObject(java.lang.String name)
                    throws java.io.IOException
Obtain the record id of a named object. Returns 0 if named object doesn't exist.

Throws:
java.io.IOException

setNamedObject

void setNamedObject(java.lang.String name,
                    long recid)
                    throws java.io.IOException
Set the record id of a named object.

Throws:
java.io.IOException


Cees de Groot (C) 2000. All rights reserved http://jdbm.sourceforge.net