com.sleepycat.collections
Class DataView

java.lang.Object
  extended by com.sleepycat.collections.DataView
All Implemented Interfaces:
Cloneable

final class DataView
extends Object
implements Cloneable

Represents a Berkeley DB database and adds support for indices, bindings and key ranges.

This class defines a view and takes care of reading and updating indices, calling bindings, constraining access to a key range, etc.

Author:
Mark Hayes

Field Summary
(package private)  boolean btreeRecNumAccess
           
(package private)  boolean btreeRecNumDb
           
(package private)  CurrentTransaction currentTxn
           
(package private)  CursorConfig cursorConfig
           
(package private)  Database db
           
(package private)  boolean dupsAllowed
           
(package private)  boolean dupsOrdered
           
(package private)  EntityBinding entityBinding
           
(package private)  PrimaryKeyAssigner keyAssigner
           
(package private)  EntryBinding keyBinding
           
(package private)  boolean keysRenumbered
           
(package private)  boolean ordered
           
(package private)  KeyRange range
           
(package private)  boolean readUncommittedAllowed
           
(package private)  boolean recNumAccess
           
(package private)  boolean recNumAllowed
           
(package private)  boolean recNumRenumber
           
(package private)  SecondaryDatabase secDb
           
(package private)  SecondaryKeyCreator secKeyCreator
           
(package private)  boolean transactional
           
(package private)  EntryBinding valueBinding
           
(package private)  boolean writeAllowed
           
 
Constructor Summary
DataView(Database database, EntryBinding keyBinding, EntryBinding valueBinding, EntityBinding entityBinding, boolean writeAllowed, PrimaryKeyAssigner keyAssigner)
          Creates a view for a given database and bindings.
 
Method Summary
(package private)  OperationStatus append(Object value, Object[] retPrimaryKey, Object[] retValue)
          Appends a value and returns the new key.
(package private)  boolean canDeriveKeyFromValue()
          Returns whether data keys can be derived from the value/entity binding of this view, which determines whether a value/entity object alone is sufficient for operations that require keys.
(package private)  void clear()
          Deletes all records in the current range.
(package private)  DataView configuredView(CursorConfig config)
          Returns a new view with a specified cursor configuration.
(package private)  CurrentTransaction getCurrentTxn()
          Returns the current transaction for the view or null if the environment is non-transactional.
(package private)  Environment getEnv()
          Returns the environment for the database.
(package private)  DatabaseEntry getSingleKeyThang()
          Returns the key thang for a single key range, or null if a single key range is not used.
(package private)  boolean isEmpty()
          Returns whether no records are present in the view.
(package private)  boolean isSecondary()
          Returns whether this is a view on a secondary database rather than directly on a primary database.
(package private)  DataCursor join(DataCursor[] indexCursors, JoinConfig joinConfig)
          Returns a cursor for this view that reads only records having the index key values at the specified cursors.
(package private)  DataCursor join(DataView[] indexViews, Object[] indexKeys, JoinConfig joinConfig)
          Returns a cursor for this view that reads only records having the specified index key values.
(package private)  DataView keySetView()
          Return a new key-set view derived from this view by setting the entity and value binding to null.
(package private)  Object makeKey(DatabaseEntry keyThang)
          Converts a key entry to a key object.
(package private)  Object makeValue(DatabaseEntry primaryKeyThang, DatabaseEntry valueThang)
          Converts a key-value entry pair to a value object.
(package private)  KeyRange subRange(Object singleKey)
          Intersects the given key and the current range.
(package private)  KeyRange subRange(Object beginKey, boolean beginInclusive, Object endKey, boolean endInclusive)
          Intersects the given range and the current range.
(package private)  DataView subView(Object beginKey, boolean beginInclusive, Object endKey, boolean endInclusive, EntryBinding keyBinding)
          Return a new value-set view for key range, optionally changing the key binding.
(package private)  boolean useKey(Object key, Object value, DatabaseEntry keyThang, KeyRange checkRange)
          Populates the key entry and returns whether the key is within range.
(package private)  Transaction useTransaction()
          Returns the current transaction if the database is transaction, or null if the database is not transactional or there is no current transaction.
(package private)  void useValue(Object value, DatabaseEntry valueThang, DatabaseEntry checkKeyThang)
          Populates the value entry and throws an exception if the primary key would be changed via an entity binding.
(package private)  DataView valueSetView()
          Return a new value-set view derived from this view by setting the key binding to null.
(package private)  DataView valueSetView(Object singleKey)
          Return a new value-set view for single key range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

Database db

secDb

SecondaryDatabase secDb

currentTxn

CurrentTransaction currentTxn

range

KeyRange range

keyBinding

EntryBinding keyBinding

valueBinding

EntryBinding valueBinding

entityBinding

EntityBinding entityBinding

keyAssigner

PrimaryKeyAssigner keyAssigner

secKeyCreator

SecondaryKeyCreator secKeyCreator

cursorConfig

CursorConfig cursorConfig

writeAllowed

boolean writeAllowed

ordered

boolean ordered

recNumAllowed

boolean recNumAllowed

recNumAccess

boolean recNumAccess

btreeRecNumDb

boolean btreeRecNumDb

btreeRecNumAccess

boolean btreeRecNumAccess

recNumRenumber

boolean recNumRenumber

keysRenumbered

boolean keysRenumbered

dupsAllowed

boolean dupsAllowed

dupsOrdered

boolean dupsOrdered

transactional

boolean transactional

readUncommittedAllowed

boolean readUncommittedAllowed
Constructor Detail

DataView

DataView(Database database,
         EntryBinding keyBinding,
         EntryBinding valueBinding,
         EntityBinding entityBinding,
         boolean writeAllowed,
         PrimaryKeyAssigner keyAssigner)
   throws IllegalArgumentException
Creates a view for a given database and bindings. The initial key range of the view will be open.

Throws:
IllegalArgumentException
Method Detail

keySetView

DataView keySetView()
Return a new key-set view derived from this view by setting the entity and value binding to null.

Returns:
the derived view.

valueSetView

DataView valueSetView()
Return a new value-set view derived from this view by setting the key binding to null.

Returns:
the derived view.

valueSetView

DataView valueSetView(Object singleKey)
                throws DatabaseException,
                       KeyRangeException
Return a new value-set view for single key range.

Parameters:
singleKey - the single key value.
Returns:
the derived view.
Throws:
DatabaseException - if a database problem occurs.
KeyRangeException - if the specified range is not within the current range.

subView

DataView subView(Object beginKey,
                 boolean beginInclusive,
                 Object endKey,
                 boolean endInclusive,
                 EntryBinding keyBinding)
           throws DatabaseException,
                  KeyRangeException
Return a new value-set view for key range, optionally changing the key binding.

Throws:
DatabaseException
KeyRangeException

configuredView

DataView configuredView(CursorConfig config)
Returns a new view with a specified cursor configuration.


getCurrentTxn

CurrentTransaction getCurrentTxn()
Returns the current transaction for the view or null if the environment is non-transactional.


getSingleKeyThang

DatabaseEntry getSingleKeyThang()
Returns the key thang for a single key range, or null if a single key range is not used.


getEnv

final Environment getEnv()
Returns the environment for the database.


isSecondary

final boolean isSecondary()
Returns whether this is a view on a secondary database rather than directly on a primary database.


isEmpty

boolean isEmpty()
          throws DatabaseException
Returns whether no records are present in the view.

Throws:
DatabaseException

append

OperationStatus append(Object value,
                       Object[] retPrimaryKey,
                       Object[] retValue)
                 throws DatabaseException
Appends a value and returns the new key. If a key assigner is used it assigns the key, otherwise a QUEUE or RECNO database is required.

Throws:
DatabaseException

useTransaction

Transaction useTransaction()
Returns the current transaction if the database is transaction, or null if the database is not transactional or there is no current transaction.


clear

void clear()
     throws DatabaseException
Deletes all records in the current range.

Throws:
DatabaseException

join

DataCursor join(DataView[] indexViews,
                Object[] indexKeys,
                JoinConfig joinConfig)
          throws DatabaseException
Returns a cursor for this view that reads only records having the specified index key values.

Throws:
DatabaseException

join

DataCursor join(DataCursor[] indexCursors,
                JoinConfig joinConfig)
          throws DatabaseException
Returns a cursor for this view that reads only records having the index key values at the specified cursors.

Throws:
DatabaseException

useKey

boolean useKey(Object key,
               Object value,
               DatabaseEntry keyThang,
               KeyRange checkRange)
         throws DatabaseException
Populates the key entry and returns whether the key is within range.

Throws:
DatabaseException

canDeriveKeyFromValue

final boolean canDeriveKeyFromValue()
Returns whether data keys can be derived from the value/entity binding of this view, which determines whether a value/entity object alone is sufficient for operations that require keys.


useValue

void useValue(Object value,
              DatabaseEntry valueThang,
              DatabaseEntry checkKeyThang)
        throws DatabaseException
Populates the value entry and throws an exception if the primary key would be changed via an entity binding.

Throws:
DatabaseException

makeKey

Object makeKey(DatabaseEntry keyThang)
         throws DatabaseException
Converts a key entry to a key object.

Throws:
DatabaseException

makeValue

Object makeValue(DatabaseEntry primaryKeyThang,
                 DatabaseEntry valueThang)
           throws DatabaseException
Converts a key-value entry pair to a value object.

Throws:
DatabaseException

subRange

KeyRange subRange(Object singleKey)
            throws DatabaseException,
                   KeyRangeException
Intersects the given key and the current range.

Throws:
DatabaseException
KeyRangeException

subRange

KeyRange subRange(Object beginKey,
                  boolean beginInclusive,
                  Object endKey,
                  boolean endInclusive)
            throws DatabaseException,
                   KeyRangeException
Intersects the given range and the current range.

Throws:
DatabaseException
KeyRangeException


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.