|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.persist.BasicIndex<K,E>
abstract class BasicIndex<K,E>
Implements EntityIndex using a ValueAdapter. This class is abstract and does not implement get()/map()/sortedMap() because it doesn't have access to the entity binding.
Field Summary | |
---|---|
(package private) Database |
db
|
(package private) KeyRange |
emptyRange
|
(package private) ValueAdapter<E> |
entityAdapter
|
(package private) ValueAdapter<K> |
keyAdapter
|
(package private) EntryBinding |
keyBinding
|
(package private) Class<K> |
keyClass
|
(package private) boolean |
locking
|
(package private) static DatabaseEntry |
NO_RETURN_ENTRY
|
(package private) boolean |
sortedDups
|
(package private) boolean |
transactional
|
Constructor Summary | |
---|---|
BasicIndex(Database db,
Class<K> keyClass,
EntryBinding keyBinding,
ValueAdapter<E> entityAdapter)
|
Method Summary | |
---|---|
boolean |
contains(K key)
Checks for existence of a key in this index. |
boolean |
contains(Transaction txn,
K key,
LockMode lockMode)
Checks for existence of a key in this index. |
long |
count()
Returns a non-transactional count of the entities in this index. |
boolean |
delete(K key)
Deletes all entities with a given index key. |
boolean |
delete(Transaction txn,
K key)
Deletes all entities with a given index key. |
EntityCursor<E> |
entities()
Opens a cursor for traversing all entities in this index. |
EntityCursor<E> |
entities(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
Opens a cursor for traversing entities in a key range. |
EntityCursor<E> |
entities(Transaction txn,
CursorConfig config)
Opens a cursor for traversing all entities in this index. |
EntityCursor<E> |
entities(Transaction txn,
K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive,
CursorConfig config)
Opens a cursor for traversing entities in a key range. |
(package private) abstract boolean |
isUpdateAllowed()
|
EntityCursor<K> |
keys()
Opens a cursor for traversing all keys in this index. |
EntityCursor<K> |
keys(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
Opens a cursor for traversing keys in a key range. |
EntityCursor<K> |
keys(Transaction txn,
CursorConfig config)
Opens a cursor for traversing all keys in this index. |
EntityCursor<K> |
keys(Transaction txn,
K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive,
CursorConfig config)
Opens a cursor for traversing keys in a key range. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sleepycat.persist.EntityIndex |
---|
get, get, map, sortedMap |
Field Detail |
---|
static final DatabaseEntry NO_RETURN_ENTRY
Database db
boolean transactional
boolean sortedDups
boolean locking
Class<K> keyClass
EntryBinding keyBinding
KeyRange emptyRange
ValueAdapter<K> keyAdapter
ValueAdapter<E> entityAdapter
Constructor Detail |
---|
BasicIndex(Database db, Class<K> keyClass, EntryBinding keyBinding, ValueAdapter<E> entityAdapter) throws DatabaseException
DatabaseException
Method Detail |
---|
public boolean contains(K key) throws DatabaseException
EntityIndex
The operation will not be transaction protected, and LockMode.DEFAULT
is used implicitly.
READ_UNCOMMITTED
can be used with this method to reduce I/O,
since the record data item will not be read. This is the same benefit
as described in Key Cursor
Optimization with READ_UNCOMMITTED
contains
in interface EntityIndex<K,E>
key
- the key to search for.
OperationFailureException
- if one of the Read Operation
Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- the base class for all BDB exceptions.public boolean contains(Transaction txn, K key, LockMode lockMode) throws DatabaseException
EntityIndex
READ_UNCOMMITTED
can be used with this method to reduce I/O,
since the record data item will not be read. This is the same benefit
as described in Key Cursor
Optimization with READ_UNCOMMITTED
contains
in interface EntityIndex<K,E>
txn
- the transaction used to protect this operation, or null
if the operation should not be transaction protected.key
- the key to search for.lockMode
- the lock mode to use for this operation, or null to
use LockMode.DEFAULT
.
OperationFailureException
- if one of the Read Operation
Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- the base class for all BDB exceptions.public long count() throws DatabaseException
EntityIndex
This operation is faster than obtaining a count by scanning the index manually, and will not perturb the current contents of the cache. However, the count is not guaranteed to be accurate if there are concurrent updates.
count
in interface EntityIndex<K,E>
OperationFailureException
- if one of the Read Operation
Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- the base class for all BDB exceptions.public boolean delete(K key) throws DatabaseException
EntityIndex
Auto-commit is used implicitly if the store is transactional.
delete
in interface EntityIndex<K,E>
key
- the key to search for.
OperationFailureException
- if one of the Write
Operation Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- the base class for all BDB exceptions.public boolean delete(Transaction txn, K key) throws DatabaseException
EntityIndex
delete
in interface EntityIndex<K,E>
txn
- the transaction used to protect this operation, null to use
auto-commit, or null if the store is non-transactional.key
- the key to search for.
OperationFailureException
- if one of the Write
Operation Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<K> keys() throws DatabaseException
EntityIndex
The operations performed with the cursor will not be transaction
protected, and CursorConfig.DEFAULT
is used implicitly. If the
store is transactional, the cursor may not be used to update or delete
entities.
Note that READ_UNCOMMITTED
can be used with a key cursor to
reduce I/O, potentially providing significant performance benefits. See
Key Cursor Optimization with
READ_UNCOMMITTED
keys
in interface EntityIndex<K,E>
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<K> keys(Transaction txn, CursorConfig config) throws DatabaseException
EntityIndex
Note that READ_UNCOMMITTED
can be used with a key cursor to
reduce I/O, potentially providing significant performance benefits. See
Key Cursor Optimization with
READ_UNCOMMITTED
keys
in interface EntityIndex<K,E>
txn
- the transaction used to protect all operations performed with
the cursor, or null if the operations should not be transaction
protected. If the store is non-transactional, null must be specified.
For a transactional store the transaction is optional for read-only
access and required for read-write access.config
- the cursor configuration that determines the default lock
mode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT
.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<E> entities() throws DatabaseException
EntityIndex
The operations performed with the cursor will not be transaction
protected, and CursorConfig.DEFAULT
is used implicitly. If the
store is transactional, the cursor may not be used to update or delete
entities.
entities
in interface EntityIndex<K,E>
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<E> entities(Transaction txn, CursorConfig config) throws DatabaseException
EntityIndex
entities
in interface EntityIndex<K,E>
txn
- the transaction used to protect all operations performed with
the cursor, or null if the operations should not be transaction
protected. If the store is non-transactional, null must be specified.
For a transactional store the transaction is optional for read-only
access and required for read-write access.config
- the cursor configuration that determines the default lock
mode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT
.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<K> keys(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) throws DatabaseException
EntityIndex
The operations performed with the cursor will not be transaction
protected, and CursorConfig.DEFAULT
is used implicitly. If the
store is transactional, the cursor may not be used to update or delete
entities.
Note that READ_UNCOMMITTED
can be used with a key cursor to
reduce I/O, potentially providing significant performance benefits. See
Key Cursor Optimization with
READ_UNCOMMITTED
keys
in interface EntityIndex<K,E>
fromKey
- is the lower bound of the key range, or null if the range
has no lower bound.fromInclusive
- is true if keys greater than or equal to fromKey
should be included in the key range, or false if only keys greater than
fromKey should be included.toKey
- is the upper bound of the key range, or null if the range
has no upper bound.toInclusive
- is true if keys less than or equal to toKey should be
included in the key range, or false if only keys less than toKey should
be included.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<K> keys(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config) throws DatabaseException
EntityIndex
Using a key cursor potentially has a large performance benefit when
the READ_UNCOMMITTED
isolation mode is used. In this case, if
the record data is not in the JE cache, it will not be read from disk.
The performance benefit is potentially large because random access disk
reads may be reduced. Examples are:
READ_UNCOMMITTED
isolation is acceptable.READ_UNCOMMITTED
isolation.For other isolation modes (READ_COMMITTED
, REPEATABLE_READ
and SERIALIZABLE
), the performance benefit of a
key cursor is not as significant. In this case, the data item must be
read into the JE cache if it is not already present, in order to lock
the record. The only performance benefit is that the data will not be
copied from the JE cache to the application's entry parameter, and will
not be unmarshalled into an entity object.
For information on specifying isolation modes, see LockMode
,
CursorConfig
and TransactionConfig
.
keys
in interface EntityIndex<K,E>
txn
- the transaction used to protect all operations performed with
the cursor, or null if the operations should not be transaction
protected. If the store is non-transactional, null must be specified.
For a transactional store the transaction is optional for read-only
access and required for read-write access.fromKey
- is the lower bound of the key range, or null if the range
has no lower bound.fromInclusive
- is true if keys greater than or equal to fromKey
should be included in the key range, or false if only keys greater than
fromKey should be included.toKey
- is the upper bound of the key range, or null if the range
has no upper bound.toInclusive
- is true if keys less than or equal to toKey should be
included in the key range, or false if only keys less than toKey should
be included.config
- the cursor configuration that determines the default lock
mode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT
.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<E> entities(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) throws DatabaseException
EntityIndex
The operations performed with the cursor will not be transaction
protected, and CursorConfig.DEFAULT
is used implicitly. If the
store is transactional, the cursor may not be used to update or delete
entities.
entities
in interface EntityIndex<K,E>
fromKey
- is the lower bound of the key range, or null if the range
has no lower bound.fromInclusive
- is true if keys greater than or equal to fromKey
should be included in the key range, or false if only keys greater than
fromKey should be included.toKey
- is the upper bound of the key range, or null if the range
has no upper bound.toInclusive
- is true if keys less than or equal to toKey should be
included in the key range, or false if only keys less than toKey should
be included.
DatabaseException
- the base class for all BDB exceptions.public EntityCursor<E> entities(Transaction txn, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, CursorConfig config) throws DatabaseException
EntityIndex
entities
in interface EntityIndex<K,E>
txn
- the transaction used to protect all operations performed with
the cursor, or null if the operations should not be transaction
protected. If the store is non-transactional, null must be specified.
For a transactional store the transaction is optional for read-only
access and required for read-write access.fromKey
- is the lower bound of the key range, or null if the range
has no lower bound.fromInclusive
- is true if keys greater than or equal to fromKey
should be included in the key range, or false if only keys greater than
fromKey should be included.toKey
- is the upper bound of the key range, or null if the range
has no upper bound.toInclusive
- is true if keys less than or equal to toKey should be
included in the key range, or false if only keys less than toKey should
be included.config
- the cursor configuration that determines the default lock
mode used for all cursor operations, or null to implicitly use CursorConfig.DEFAULT
.
DatabaseException
- the base class for all BDB exceptions.abstract boolean isUpdateAllowed()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |