Home » hive-0.5.0-dev » org.apache.hadoop.hive.ql.util.jdbm.recman » [javadoc | source]
org.apache.hadoop.hive.ql.util.jdbm.recman
public final class: BaseRecordManager [javadoc | source]
java.lang.Object
   org.apache.hadoop.hive.ql.util.jdbm.recman.BaseRecordManager

All Implemented Interfaces:
    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.

Field Summary
public static final  int NAME_DIRECTORY_ROOT    Reserved slot for name directory. 
public static final  boolean DEBUG    Static debugging flag 
Constructor:
 public BaseRecordManager(String filename) throws IOException 
    Creates a record manager for the indicated file
    Throws:
    IOException - when the file cannot be opened or is not a valid file content-wise.
 public BaseRecordManager(File file) throws IOException 
    Creates a record manager for the indicated file
    Throws:
    IOException - when the file cannot be opened or is not a valid file content-wise.
Method from org.apache.hadoop.hive.ql.util.jdbm.recman.BaseRecordManager Summary:
close,   commit,   delete,   disableTransactions,   fetch,   fetch,   getNamedObject,   getRoot,   getRootCount,   getTransactionManager,   insert,   insert,   rollback,   setNamedObject,   setRoot,   update,   update
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.hadoop.hive.ql.util.jdbm.recman.BaseRecordManager Detail:
 public synchronized  void close() throws IOException 
    Closes the record manager.
 public synchronized  void commit() throws IOException 
    Commit (make persistent) all changes since beginning of transaction.
 public synchronized  void delete(long recid) throws IOException 
    Deletes a record.
 public synchronized  void disableTransactions() 
    Switches off transactioning for the record manager. This means that a) a transaction log is not kept, and b) writes aren't synch'ed after every update. This is useful when batch inserting into a new database.

    Only call this method directly after opening the file, otherwise the results will be undefined.

 public Object fetch(long recid) throws IOException 
    Fetches a record using standard java object serialization.
 public synchronized Object fetch(long recid,
    Serializer serializer) throws IOException 
    Fetches a record using a custom serializer.
 public long getNamedObject(String name) throws IOException 
    Obtain the record id of a named object. Returns 0 if named object doesn't exist.
 public synchronized long getRoot(int id) throws IOException 
    Returns the indicated root rowid.
 public 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.
 public synchronized TransactionManager getTransactionManager() 
    Get the underlying Transaction Manager
 public long insert(Object obj) throws IOException 
    Inserts a new record using standard java object serialization.
 public synchronized long insert(Object obj,
    Serializer serializer) throws IOException 
    Inserts a new record using a custom serializer.
 public synchronized  void rollback() throws IOException 
    Rollback (cancel) all changes since beginning of transaction.
 public  void setNamedObject(String name,
    long recid) throws IOException 
    Set the record id of a named object.
 public synchronized  void setRoot(int id,
    long rowid) throws IOException 
    Sets the indicated root rowid.
 public  void update(long recid,
    Object obj) throws IOException 
    Updates a record using standard java object serialization.
 public synchronized  void update(long recid,
    Object obj,
    Serializer serializer) throws IOException 
    Updates a record using a custom serializer.