public interface ReadTransaction extends ReadTransactionContext
Transaction
. This is the interface that
Transaction
's snapshot
presents.Transaction.commit()
and wait on the result on all transactions,
even ones that only read. This is done automatically when using the retry loops from
Database.run(Function)
. This is explained more in the intro to Transaction
.Transaction
Modifier and Type | Field and Description |
---|---|
static int |
ROW_LIMIT_UNLIMITED
When passed to a
getRange() call that takes a limit parameter,
indicates that the query should return unlimited rows. |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<byte[]> |
get(byte[] key)
Gets a value from the database.
|
java.util.concurrent.CompletableFuture<byte[]> |
getKey(KeySelector selector)
Returns the key referenced by the specified
KeySelector . |
AsyncIterable<KeyValue> |
getRange(byte[] begin,
byte[] end)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(byte[] begin,
byte[] end,
int limit)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(byte[] begin,
byte[] end,
int limit,
boolean reverse)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(byte[] begin,
byte[] end,
int limit,
boolean reverse,
StreamingMode mode)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(KeySelector begin,
KeySelector end)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(KeySelector begin,
KeySelector end,
int limit)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(KeySelector begin,
KeySelector end,
int limit,
boolean reverse)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(KeySelector begin,
KeySelector end,
int limit,
boolean reverse,
StreamingMode mode)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(Range range)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(Range range,
int limit)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(Range range,
int limit,
boolean reverse)
Gets an ordered range of keys and values from the database.
|
AsyncIterable<KeyValue> |
getRange(Range range,
int limit,
boolean reverse,
StreamingMode mode)
Gets an ordered range of keys and values from the database.
|
java.util.concurrent.CompletableFuture<java.lang.Long> |
getReadVersion()
Gets the version at which the reads for this
Transaction will access the database. |
TransactionOptions |
options()
Returns a set of options that can be set on a
Transaction |
getExecutor, read, readAsync
static final int ROW_LIMIT_UNLIMITED
getRange()
call that takes a limit
parameter,
indicates that the query should return unlimited rows.java.util.concurrent.CompletableFuture<java.lang.Long> getReadVersion()
Transaction
will access the database.java.util.concurrent.CompletableFuture<byte[]> get(byte[] key)
null
if the key is not
present in the database.key
- the key whose value to fetch from the databaseCompletableFuture
which will be set to the value corresponding to
the key or to null if the key does not exist.java.util.concurrent.CompletableFuture<byte[]> getKey(KeySelector selector)
KeySelector
.
By default, the key is cached for the duration of the transaction, providing
a potential performance benefit. However, the value of the key is also retrieved,
using network bandwidth. Invoking setReadYourWritesDisable
will avoid
both the caching and the increased network bandwidth.selector
- the relative key location to resolveCompletableFuture
which will be set to an absolute database keyKeySelector
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end)
KeySelector
s, with the begin
KeySelector
inclusive and the end KeySelector
exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end, int limit)
KeySelector
s, with the begin
KeySelector
inclusive and the end KeySelector
exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results.KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end, int limit, boolean reverse)
KeySelector
s, with the begin
KeySelector
inclusive and the end KeySelector
exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse orderKeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(KeySelector begin, KeySelector end, int limit, boolean reverse, StreamingMode mode)
KeySelector
s, with the begin
KeySelector
inclusive and the end KeySelector
exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse ordermode
- provide a hint about how the results are to be used. This
can provide speed improvements or efficiency gains based on the caller's
knowledge of the upcoming access pattern.KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end)
byte[]
arrays, with the begin
key inclusive and the end key exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end, int limit)
byte[]
arrays, with the begin
key inclusive and the end key exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results.KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end, int limit, boolean reverse)
byte[]
arrays, with the begin
key inclusive and the end key exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse orderKeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(byte[] begin, byte[] end, int limit, boolean reverse, StreamingMode mode)
byte[]
arrays, with the begin
key inclusive and the end key exclusive.begin
- the beginning of the range (inclusive)end
- the end of the range (exclusive)limit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse ordermode
- provide a hint about how the results are to be used. This
can provide speed improvements or efficiency gains based on the caller's
knowledge of the upcoming access pattern.KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(Range range)
byte[]
arrays, with the begin
key inclusive and the end key exclusive. Range
s are returned
from calls to Tuple.range()
and Range.startsWith(byte[])
. getRangeStartsWith( k )
with getRange(Range.startsWith( k ))
range
- the range of keys to returnKeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(Range range, int limit)
byte[]
arrays, with the begin
key inclusive and the end key exclusive. Range
s are returned
from calls to Tuple.range()
and Range.startsWith(byte[])
. getRangeStartsWith( k )
with getRange(Range.startsWith( k ))
range
- the range of keys to returnlimit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results.KeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(Range range, int limit, boolean reverse)
byte[]
arrays, with the begin
key inclusive and the end key exclusive. Range
s are returned
from calls to Tuple.range()
and Range.startsWith(byte[])
. getRangeStartsWith( k )
with getRange(Range.startsWith( k ))
range
- the range of keys to returnlimit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse orderKeySelector
,
AsyncIterator
AsyncIterable<KeyValue> getRange(Range range, int limit, boolean reverse, StreamingMode mode)
byte[]
arrays, with the begin
key inclusive and the end key exclusive. Range
s are returned
from calls to Tuple.range()
and Range.startsWith(byte[])
. getRangeStartsWith( k )
with getRange(Range.startsWith( k ))
range
- the range of keys to returnlimit
- the maximum number of results to return. Limits results to the
first keys in the range. Pass ROW_LIMIT_UNLIMITED
if this query
should not limit the number of results. If reverse
is true
rows
will be limited starting at the end of the range.reverse
- return results starting at the end of the range in reverse ordermode
- provide a hint about how the results are to be used. This
can provide speed improvements or efficiency gains based on the caller's
knowledge of the upcoming access pattern.KeySelector
,
AsyncIterator
TransactionOptions options()
Transaction
Transaction