public class ReadWriteSpannerView extends MutableView implements CloseableKVStore
KVStore
view of a ReadContext
.
For best performance, supply an ExecutorService
for asynchronous batch loading.
Use bufferMutations()
to transfer outstanding mutations into a TransactionContext
.
ReadOnlySpannerView
,
CachingKVStore
Modifier and Type | Field and Description |
---|---|
protected Function<? super SpannerException,RuntimeException> |
exceptionMapper |
protected Logger |
log |
protected String |
tableName |
Constructor and Description |
---|
ReadWriteSpannerView(String tableName,
ReadContext context,
Function<? super SpannerException,RuntimeException> exceptionMapper)
Constructor for when no batching is desired.
|
ReadWriteSpannerView(String tableName,
ReadContext context,
Function<? super SpannerException,RuntimeException> exceptionMapper,
ExecutorService executor,
long rttEstimate)
Constructor for when batching is desired.
|
Modifier and Type | Method and Description |
---|---|
void |
bufferMutations(TransactionContext context)
Atomically transfer all of the outstanding mutations associated with this instance into the given transaction context,
and then clear them.
|
ReadWriteSpannerView |
clone()
Clone this instance.
|
void |
close()
Close the associated
ReadContext . |
double |
getRttEstimate()
Get the current RTT estimate.
|
adjustCounter, apply, decodeCounter, disableReadTracking, encodeCounter, get, getKVStore, getRange, getReads, getReadTrackingControl, getWrites, put, remove, removeRange, setKVStore, setReadOnly, toString
getAtLeast, getAtMost
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
adjustCounter, apply, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange, getRange, getRange, put, remove, removeRange, removeRange
protected final Logger log
protected final String tableName
protected final Function<? super SpannerException,RuntimeException> exceptionMapper
public ReadWriteSpannerView(String tableName, ReadContext context, Function<? super SpannerException,RuntimeException> exceptionMapper)
tableName
- name of the Spanner database tablecontext
- read contextexceptionMapper
- mapper for any thrown SpannerException
s, or null for noneIllegalArgumentException
- if tableName
or context
is nullpublic ReadWriteSpannerView(String tableName, ReadContext context, Function<? super SpannerException,RuntimeException> exceptionMapper, ExecutorService executor, long rttEstimate)
tableName
- name of the Spanner database tablecontext
- read contextexceptionMapper
- mapper for any thrown SpannerException
s, or null for noneexecutor
- asynchronous load task executorrttEstimate
- initial RTT estimate in nanosecondsIllegalArgumentException
- if tableName
, context
or executor
is nullIllegalArgumentException
- if rttEstimate
is negativepublic double getRttEstimate()
public void bufferMutations(TransactionContext context)
context
- transaction contextIllegalArgumentException
- if context
is nullpublic ReadWriteSpannerView clone()
MutableView
The clone will have the same underlying KVStore
, but its own Reads
and Writes
,
which will themselves be cloned from this instance's copies.
clone
in class MutableView
public void close()
ReadContext
.close
in interface CloseableKVStore
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2022. All rights reserved.