Interface ReadableTransaction
- All Known Subinterfaces:
WriteableTransaction
public interface ReadableTransaction
Represents a readable transaction on a storage engine.
-
Method Summary
Modifier and TypeMethodDescriptiondefault long
Returns the count of records accessed during a read transaction.default long
getRecordCount
(TreeName treeName) Returns the number of key/value pairs in the provided tree.default Cursor<ByteString,
ByteString> openCursor
(TreeName treeName) Opens a non-positioned cursor on the tree whose name is provided.default Cursor<ByteString,
ByteString> openCursor
(TreeName treeName, Set<Storage.ReadHint> hints) Opens a non-positioned cursor on the tree whose name is provided.default ByteString
read
(TreeName treeName, ByteString key) Reads the record's value associated to the provided key, in the tree whose name is provided.default void
setLookThroughLimit
(long limit) Sets the lookthrough limit which should be applied to this transaction.
-
Method Details
-
read
Reads the record's value associated to the provided key, in the tree whose name is provided.- Parameters:
treeName
- the tree namekey
- the record's key- Returns:
- the record's value, or
null
if none exists or if the tree does not exist.
-
openCursor
Opens a non-positioned cursor on the tree whose name is provided. The cursor will then have to be positioned (e.g: by invokingSequentialCursor.next()
) to bedefined
.- Parameters:
treeName
- the tree name- Returns:
- a new non-positioned cursor or an empty cursor if the tree does not exist.
-
openCursor
Opens a non-positioned cursor on the tree whose name is provided. The cursor will then have to be positioned (e.g: by invokingSequentialCursor.next()
) to bedefined
.- Parameters:
treeName
- the tree namehints
- the hints to apply to the opened cursor.- Returns:
- a new non-positioned cursor or an empty cursor if the tree does not exist.
-
getRecordCount
Returns the number of key/value pairs in the provided tree.- Parameters:
treeName
- the tree name- Returns:
- the number of key/value pairs in the provided tree or
0
if the tree does not exist.
-
setLookThroughLimit
default void setLookThroughLimit(long limit) Sets the lookthrough limit which should be applied to this transaction. The limit restricts the maximum number of records that may be accessed during a read transaction. This method is typically called at the start of a transaction and usually only for search operations. The lookthrough limit is disabled by default. ALookThroughLimitExceededException
will be thrown once the lookthrough limit has been reached.- Parameters:
limit
- The lookthrough limit. A negative or zero value indicates that there is no limit (the default).
-
getLookThroughCounter
default long getLookThroughCounter()Returns the count of records accessed during a read transaction.- Returns:
- The number of records accessed during a read transaction, or
-1
if unknown.
-