Interface Index
- All Superinterfaces:
AutoCloseable, Closeable, View
-
Method Summary
Modifier and TypeMethodDescriptionanalyze(byte[] lowKey, byte[] highKey) Estimates the size of this index with a single random probe.<R> Table<R> Returns aTableinstance which stores rows in this index.voidclose()Closes this index reference.voiddrop()Fully closes and removes an empty index.longevict(Transaction txn, byte[] lowKey, byte[] highKey, Filter evictionFilter, boolean autoload) Select a few entries, and delete them from the index.longid()booleanisClosed()byte[]name()booleanverify(VerificationObserver observer, int numThreads) Verifies the integrity of the index.Methods inherited from interface View
comparator, count, count, delete, exchange, exists, insert, isEmpty, isModifyAtomic, isUnmodifiable, load, lockCheck, lockExclusive, lockShared, lockUpgradable, newAccessor, newCursor, newTransaction, ordering, remove, replace, store, touch, tryLockExclusive, tryLockShared, tryLockUpgradable, update, update, viewDifference, viewFiltered, viewGe, viewGt, viewIntersection, viewKeys, viewLe, viewLt, viewPrefix, viewReverse, viewTransformed, viewUnion, viewUnmodifiableModifier and TypeMethodDescriptiondefault Comparator<byte[]> Returns a key comparator for the ordering of this view, or null if unordered.default longcount(byte[] lowKey, boolean lowInclusive, byte[] highKey, boolean highInclusive) Non-transactionally counts the number of entries within the given range.default longcount(byte[] lowKey, byte[] highKey) Non-transactionally counts the number of entries within the given range.default booleandelete(Transaction txn, byte[] key) Unconditionally removes the entry associated with the given key.default byte[]exchange(Transaction txn, byte[] key, byte[] value) Unconditionally associates a value with the given key, returning the previous value.default booleanexists(Transaction txn, byte[] key) Checks if an entry for the given key exists.default booleaninsert(Transaction txn, byte[] key, byte[] value) Associates a value with the given key, unless a corresponding value already exists.default booleanisEmpty()Non-transactionally determines if the view has nothing in it.default booleanReturns true if the value-modifying methods of this view are atomic, even when not using transactions.booleanReturns true if any attempt to modify this view causes anUnmodifiableViewExceptionto be thrown.default byte[]load(Transaction txn, byte[] key) Returns a copy of the value for the given key, or null if no matching entry exists.lockCheck(Transaction txn, byte[] key) Checks the lock ownership for the given key.lockExclusive(Transaction txn, byte[] key) Explicitly acquire an exclusive lock for the given key, denying any additional locks.lockShared(Transaction txn, byte[] key) Explicitly acquire a shared lock for the given key, denying exclusive locks.lockUpgradable(Transaction txn, byte[] key) Explicitly acquire an upgradable lock for the given key, denying exclusive and additional upgradable locks.default CursornewAccessor(Transaction txn, byte[] key) Returns a cursor intended for accessing values in chunks, permitting them to be larger than what can fit in main memory.newCursor(Transaction txn) Returns a new cursor over this view.default TransactionnewTransaction(DurabilityMode durabilityMode) Returns a new transaction which is compatible with this view.ordering()Returns the key ordering for this view.default booleanremove(Transaction txn, byte[] key, byte[] value) Removes the entry associated with the given key, but only if the given value matches.default booleanreplace(Transaction txn, byte[] key, byte[] value) Associates a value with the given key, but only if a corresponding value already exists.default voidstore(Transaction txn, byte[] key, byte[] value) Unconditionally associates a value with the given key.default LockResulttouch(Transaction txn, byte[] key) Touch the given key as if callingload, but instead only acquiring any necessary locks.default LockResulttryLockExclusive(Transaction txn, byte[] key, long nanosTimeout) Explicitly acquire an exclusive lock for the given key, denying any additional locks.default LockResulttryLockShared(Transaction txn, byte[] key, long nanosTimeout) Explicitly acquire a shared lock for the given key, denying exclusive locks.default LockResulttryLockUpgradable(Transaction txn, byte[] key, long nanosTimeout) Explicitly acquire an upgradable lock for the given key, denying exclusive and additional upgradable locks.default booleanupdate(Transaction txn, byte[] key, byte[] value) Associates a value with the given key, but only if the given value differs from the existing value.default booleanupdate(Transaction txn, byte[] key, byte[] oldValue, byte[] newValue) Associates a value with the given key, but only if the given old value matches the existing value.default ViewviewDifference(Combiner combiner, View second) Returns a view which represents the set difference of this view and a second one.default ViewviewFiltered(Filter filter) Returns a sub-view, backed by this one, whose entries have been filtered out.default ViewviewGe(byte[] key) Returns a sub-view, backed by this one, whose keys are greater than or equal to the given key.default ViewviewGt(byte[] key) Returns a sub-view, backed by this one, whose keys are greater than the given key.default ViewviewIntersection(Combiner combiner, View second) Returns a view which represents the set intersection of this view and a second one.default ViewviewKeys()Returns a view, backed by this one, which only provides the keys.default ViewviewLe(byte[] key) Returns a sub-view, backed by this one, whose keys are less than or equal to the given key.default ViewviewLt(byte[] key) Returns a sub-view, backed by this one, whose keys are less than the given key.default ViewviewPrefix(byte[] prefix, int trim) Returns a sub-view, backed by this one, whose keys start with the given prefix.default ViewReturns a view, backed by this one, whose natural order is reversed.default ViewviewTransformed(Transformer transformer) Returns a sub-view, backed by this one, whose entries have been filtered out and transformed.default ViewReturns a view which represents the set union of this view and a second one.default ViewReturns a view, backed by this one, whose entries cannot be modified.
-
Method Details
-
id
long id()- Returns:
- randomly assigned, unique non-zero identifier for this index
-
name
byte[] name()- Returns:
- unique user-specified index name
-
nameString
String nameString()- Returns:
- name decoded as UTF-8
-
asTable
Returns aTableinstance which stores rows in this index. Bypassing theTableand storing directly into this index should be avoided, since it interferes with row encoding. Mixing encoding strategies can cause data corruption.- Returns:
- shared
Tableinstance - Throws:
IOException- See Also:
-
evict
long evict(Transaction txn, byte[] lowKey, byte[] highKey, Filter evictionFilter, boolean autoload) throws IOException Select a few entries, and delete them from the index. Implementation should attempt to evict entries which haven't been recently used, but it might select them at random.- Parameters:
txn- optionallowKey- inclusive lowest key in the evictable range; pass null for open rangehighKey- exclusive highest key in the evictable range; pass null for open rangeevictionFilter- callback which determines which entries are allowed to be evicted; pass null to evict all selected entriesautoload- pass true to also load values and pass them to the filter- Returns:
- sum of the key and value lengths which were evicted, or 0 if none were evicted
- Throws:
IOException
-
analyze
Estimates the size of this index with a single random probe. To improve the estimate, average several analysis results together.- Parameters:
lowKey- inclusive lowest key in the analysis range; pass null for open rangehighKey- exclusive highest key in the analysis range; pass null for open range- Throws:
IOException
-
verify
Verifies the integrity of the index. Using multiple threads speeds up verification, even though some nodes might be visited multiple times.- Parameters:
observer- optional observer; pass null for defaultnumThreads- pass 0 for default, or if negative, the actual number will be(-numThreads * availableProcessors).- Returns:
- true if verification passed
- Throws:
IOException
-
close
Closes this index reference. The underlying index is still valid and can be re-opened, unless it's a temporary index.In general, indexes should not be closed if they are referenced by active transactions. Although closing the index is safe, the transaction might re-open it.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- See Also:
-
isClosed
boolean isClosed() -
drop
Fully closes and removes an empty index. An exception is thrown if the index isn't empty or if an in-progress transaction is modifying it.- Throws:
IllegalStateException- if index isn't empty or if any pending transactional changes existClosedIndexException- if this index reference is closedIOException- See Also:
-