public class RawKVClient extends Object implements RawKVClientBase
| 限定符和类型 | 类和说明 |
|---|---|
class |
RawKVClient.TikvIterator |
| 限定符和类型 | 字段和说明 |
|---|---|
static io.prometheus.client.Counter |
RAW_REQUEST_FAILURE |
static io.prometheus.client.Histogram |
RAW_REQUEST_LATENCY |
static io.prometheus.client.Counter |
RAW_REQUEST_SUCCESS |
MAX_RAW_BATCH_LIMIT, MAX_RAW_SCAN_LIMIT, RAW_BATCH_DELETE_SIZE, RAW_BATCH_GET_SIZE, RAW_BATCH_PUT_SIZE| 构造器和说明 |
|---|
RawKVClient(TiSession session,
RegionStoreClient.RegionStoreClientBuilder clientBuilder) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
batchDelete(List<com.google.protobuf.ByteString> keys)
Delete a list of raw key-value pair from TiKV if key exists
|
List<Kvrpcpb.KvPair> |
batchGet(List<com.google.protobuf.ByteString> keys)
Get a list of raw key-value pair from TiKV if key exists
|
void |
batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs)
Put a set of raw key-value pair to TiKV.
|
void |
batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs,
long ttl)
Put a set of raw key-value pair to TiKV.
|
List<List<Kvrpcpb.KvPair>> |
batchScan(List<ScanOption> ranges)
Create a new `batch scan` request.
|
List<List<com.google.protobuf.ByteString>> |
batchScanKeys(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> ranges,
int eachLimit)
Create a new `batch scan` request with `keyOnly` option Once resolved this request will result
in a set of scanners over the given keys.
|
void |
close() |
void |
compareAndSet(com.google.protobuf.ByteString key,
Optional<com.google.protobuf.ByteString> prevValue,
com.google.protobuf.ByteString value)
Put a key-value pair if the prevValue matched the value in TiKV.
|
void |
compareAndSet(com.google.protobuf.ByteString key,
Optional<com.google.protobuf.ByteString> prevValue,
com.google.protobuf.ByteString value,
long ttl)
pair if the prevValue matched the value in TiKV.
|
void |
delete(com.google.protobuf.ByteString key)
Delete a raw key-value pair from TiKV if key exists
|
void |
deletePrefix(com.google.protobuf.ByteString key)
Delete all raw key-value pairs with the prefix `key` from TiKV
Cautious, this API cannot be used concurrently, if multiple clients write keys into this
range along with deleteRange API, the result will be undefined.
|
void |
deleteRange(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey)
Delete all raw key-value pairs in range [startKey, endKey) from TiKV
Cautious, this API cannot be used concurrently, if multiple clients write keys into this
range along with deleteRange API, the result will be undefined.
|
Optional<com.google.protobuf.ByteString> |
get(com.google.protobuf.ByteString key)
Get a raw key-value pair from TiKV if key exists
|
Optional<Long> |
getKeyTTL(com.google.protobuf.ByteString key)
Get the TTL of a raw key from TiKV if key exists
|
TiSession |
getSession()
Get the session of the current client
|
void |
ingest(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> list)
Ingest KV pairs to RawKV using StreamKV API.
|
void |
ingest(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> list,
Long ttl)
Ingest KV pairs to RawKV using StreamKV API.
|
void |
put(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value)
Put a raw key-value pair to TiKV
|
void |
put(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value,
long ttl)
Put a raw key-value pair to TiKV
|
Optional<com.google.protobuf.ByteString> |
putIfAbsent(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value)
Put a key-value pair if it does not exist.
|
Optional<com.google.protobuf.ByteString> |
putIfAbsent(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value,
long ttl)
Put a key-value pair with TTL if it does not exist.
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey)
Scan all raw key-value pairs from TiKV in range [startKey, endKey)
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
boolean keyOnly)
Scan all raw key-value pairs from TiKV in range [startKey, endKey)
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
int limit)
Scan raw key-value pairs from TiKV in range [startKey, endKey)
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
int limit,
boolean keyOnly)
Scan raw key-value pairs from TiKV in range [startKey, endKey)
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
int limit)
Scan raw key-value pairs from TiKV in range [startKey, ♾)
|
List<Kvrpcpb.KvPair> |
scan(com.google.protobuf.ByteString startKey,
int limit,
boolean keyOnly)
Scan raw key-value pairs from TiKV in range [startKey, ♾)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey)
Scan all raw key-value pairs from TiKV in range [startKey, endKey)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
boolean keyOnly)
Scan all raw key-value pairs from TiKV in range [startKey, endKey)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
int limit)
Scan raw key-value pairs from TiKV in range [startKey, endKey)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey,
int limit,
boolean keyOnly)
Scan raw key-value pairs from TiKV in range [startKey, endKey)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
int limit)
Scan raw key-value pairs from TiKV in range [startKey, ♾)
|
Iterator<Kvrpcpb.KvPair> |
scan0(com.google.protobuf.ByteString startKey,
int limit,
boolean keyOnly)
Scan raw key-value pairs from TiKV in range [startKey, ♾)
|
List<Kvrpcpb.KvPair> |
scanPrefix(com.google.protobuf.ByteString prefixKey) |
List<Kvrpcpb.KvPair> |
scanPrefix(com.google.protobuf.ByteString prefixKey,
boolean keyOnly) |
List<Kvrpcpb.KvPair> |
scanPrefix(com.google.protobuf.ByteString prefixKey,
int limit,
boolean keyOnly)
Scan keys with prefix
|
Iterator<Kvrpcpb.KvPair> |
scanPrefix0(com.google.protobuf.ByteString prefixKey) |
Iterator<Kvrpcpb.KvPair> |
scanPrefix0(com.google.protobuf.ByteString prefixKey,
boolean keyOnly) |
Iterator<Kvrpcpb.KvPair> |
scanPrefix0(com.google.protobuf.ByteString prefixKey,
int limit,
boolean keyOnly)
Scan keys with prefix
|
public static final io.prometheus.client.Histogram RAW_REQUEST_LATENCY
public static final io.prometheus.client.Counter RAW_REQUEST_SUCCESS
public static final io.prometheus.client.Counter RAW_REQUEST_FAILURE
public RawKVClient(TiSession session, RegionStoreClient.RegionStoreClientBuilder clientBuilder)
public void close()
close 在接口中 AutoCloseablepublic void put(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value)
RawKVClientBaseput 在接口中 RawKVClientBasekey - raw keyvalue - raw valuepublic void put(com.google.protobuf.ByteString key,
com.google.protobuf.ByteString value,
long ttl)
RawKVClientBaseput 在接口中 RawKVClientBasekey - raw keyvalue - raw valuettl - the ttl of the key (in seconds), 0 means the key will never be outdatedpublic Optional<com.google.protobuf.ByteString> putIfAbsent(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)
RawKVClientBaseTo use this API, please enable `tikv.enable_atomic_for_cas`.
putIfAbsent 在接口中 RawKVClientBasekey - keyvalue - valuepublic Optional<com.google.protobuf.ByteString> putIfAbsent(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value, long ttl)
RawKVClientBaseTo use this API, please enable `tikv.enable_atomic_for_cas`.
putIfAbsent 在接口中 RawKVClientBasekey - keyvalue - valuettl - TTL of key (in seconds), 0 means the key will never be outdated.public void compareAndSet(com.google.protobuf.ByteString key,
Optional<com.google.protobuf.ByteString> prevValue,
com.google.protobuf.ByteString value)
throws RawCASConflictException
RawKVClientBaseTo use this API, please enable `tikv.enable_atomic_for_cas`.
compareAndSet 在接口中 RawKVClientBasekey - keyvalue - valueRawCASConflictExceptionpublic void compareAndSet(com.google.protobuf.ByteString key,
Optional<com.google.protobuf.ByteString> prevValue,
com.google.protobuf.ByteString value,
long ttl)
throws RawCASConflictException
RawKVClientBaseTo use this API, please enable `tikv.enable_atomic_for_cas`.
compareAndSet 在接口中 RawKVClientBasekey - keyvalue - valuettl - TTL of key (in seconds), 0 means the key will never be outdated.RawCASConflictExceptionpublic void batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs)
RawKVClientBasebatchPut 在接口中 RawKVClientBasekvPairs - kvPairspublic void batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs, long ttl)
RawKVClientBasebatchPut 在接口中 RawKVClientBasekvPairs - kvPairsttl - the TTL of keys to be put (in seconds), 0 means the keys will never be outdatedpublic Optional<com.google.protobuf.ByteString> get(com.google.protobuf.ByteString key)
RawKVClientBaseget 在接口中 RawKVClientBasekey - raw keypublic List<Kvrpcpb.KvPair> batchGet(List<com.google.protobuf.ByteString> keys)
RawKVClientBasebatchGet 在接口中 RawKVClientBasekeys - list of raw keypublic void batchDelete(List<com.google.protobuf.ByteString> keys)
RawKVClientBasebatchDelete 在接口中 RawKVClientBasekeys - list of raw keypublic Optional<Long> getKeyTTL(com.google.protobuf.ByteString key)
RawKVClientBasegetKeyTTL 在接口中 RawKVClientBasekey - raw keypublic List<List<com.google.protobuf.ByteString>> batchScanKeys(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> ranges, int eachLimit)
RawKVClientBaseWARNING: This method is experimental. The `each_limit` parameter does not work as expected. It does not limit the number of results returned of each range, instead it limits the number of results in each region of each range. As a result, you may get more than each_limit key-value pairs for each range. But you should not miss any entries.
batchScanKeys 在接口中 RawKVClientBaseranges - a list of rangespublic List<List<Kvrpcpb.KvPair>> batchScan(List<ScanOption> ranges)
RawKVClientBaseWARNING: This method is experimental. The `each_limit` parameter does not work as expected. It does not limit the number of results returned of each range, instead it limits the number of results in each region of each range. As a result, you may get more than each_limit key-value pairs for each range. But you should not miss any entries.
batchScan 在接口中 RawKVClientBaseranges - a list of `ScanOption` for each rangepublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, int limit)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusiveendKey - raw end key, exclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITpublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, int limit, boolean keyOnly)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusiveendKey - raw end key, exclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITkeyOnly - whether to scan in key-only modepublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, int limit)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITpublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, int limit, boolean keyOnly)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITkeyOnly - whether to scan in key-only modepublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusiveendKey - raw end key, exclusivepublic List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, boolean keyOnly)
RawKVClientBasescan 在接口中 RawKVClientBasestartKey - raw start key, inclusiveendKey - raw end key, exclusivekeyOnly - whether to scan in key-only modepublic List<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey, int limit, boolean keyOnly)
RawKVClientBasescanPrefix 在接口中 RawKVClientBaseprefixKey - prefix keylimit - limit of keys retrievedkeyOnly - whether to scan in keyOnly modepublic List<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey)
scanPrefix 在接口中 RawKVClientBasepublic List<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey, boolean keyOnly)
scanPrefix 在接口中 RawKVClientBasepublic void delete(com.google.protobuf.ByteString key)
RawKVClientBasedelete 在接口中 RawKVClientBasekey - raw key to be deletedpublic void deleteRange(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey)
RawKVClientBaseCautious, this API cannot be used concurrently, if multiple clients write keys into this range along with deleteRange API, the result will be undefined.
deleteRange 在接口中 RawKVClientBasestartKey - raw start key to be deletedendKey - raw start key to be deletedpublic void deletePrefix(com.google.protobuf.ByteString key)
RawKVClientBaseCautious, this API cannot be used concurrently, if multiple clients write keys into this range along with deleteRange API, the result will be undefined.
deletePrefix 在接口中 RawKVClientBasekey - prefix of keys to be deletedpublic TiSession getSession()
RawKVClientBasegetSession 在接口中 RawKVClientBasepublic void ingest(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> list)
list - public void ingest(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> list, Long ttl) throws GrpcException
list - ttl - the ttl of the key (in seconds), 0 means the key will never be outdatedGrpcExceptionpublic Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, int limit)
startKey - raw start key, inclusiveendKey - raw end key, exclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITpublic Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, int limit)
startKey - raw start key, inclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITpublic Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, int limit, boolean keyOnly)
startKey - raw start key, inclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITkeyOnly - whether to scan in key-only modepublic Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, int limit, boolean keyOnly)
startKey - raw start key, inclusiveendKey - raw end key, exclusivelimit - limit of key-value pairs scanned, should be less than RawKVClientBase.MAX_RAW_SCAN_LIMITkeyOnly - whether to scan in key-only modepublic Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey)
startKey - raw start key, inclusiveendKey - raw end key, exclusivepublic Iterator<Kvrpcpb.KvPair> scanPrefix0(com.google.protobuf.ByteString prefixKey, int limit, boolean keyOnly)
prefixKey - prefix keylimit - limit of keys retrievedkeyOnly - whether to scan in keyOnly modepublic Iterator<Kvrpcpb.KvPair> scanPrefix0(com.google.protobuf.ByteString prefixKey)
public Iterator<Kvrpcpb.KvPair> scanPrefix0(com.google.protobuf.ByteString prefixKey, boolean keyOnly)
public Iterator<Kvrpcpb.KvPair> scan0(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey, boolean keyOnly)
startKey - raw start key, inclusiveendKey - raw end key, exclusivekeyOnly - whether to scan in key-only modeCopyright © 2023 PingCAP. All rights reserved.