public interface RawKVClientBase extends AutoCloseable
Modifier and Type | Field and Description |
---|---|
static int |
MAX_RAW_BATCH_LIMIT |
static int |
MAX_RAW_SCAN_LIMIT |
static int |
RAW_BATCH_DELETE_SIZE |
static int |
RAW_BATCH_GET_SIZE |
static int |
RAW_BATCH_PUT_SIZE |
Modifier and Type | Method and Description |
---|---|
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 |
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
|
void |
deleteRange(com.google.protobuf.ByteString startKey,
com.google.protobuf.ByteString endKey)
Delete all raw key-value pairs in range [startKey, endKey) from TiKV
|
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 |
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, ♾)
|
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
|
close
static final int MAX_RAW_SCAN_LIMIT
static final int MAX_RAW_BATCH_LIMIT
static final int RAW_BATCH_PUT_SIZE
static final int RAW_BATCH_GET_SIZE
static final int RAW_BATCH_DELETE_SIZE
void put(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)
key
- raw keyvalue
- raw valuevoid put(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value, long ttl)
key
- raw keyvalue
- raw valuettl
- the ttl of the key (in seconds), 0 means the key will never be outdatedOptional<com.google.protobuf.ByteString> putIfAbsent(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value)
To use this API, please enable `tikv.enable_atomic_for_cas`.
key
- keyvalue
- valueOptional<com.google.protobuf.ByteString> putIfAbsent(com.google.protobuf.ByteString key, com.google.protobuf.ByteString value, long ttl)
To use this API, please enable `tikv.enable_atomic_for_cas`.
key
- keyvalue
- valuettl
- TTL of key (in seconds), 0 means the key will never be outdated.void compareAndSet(com.google.protobuf.ByteString key, Optional<com.google.protobuf.ByteString> prevValue, com.google.protobuf.ByteString value)
To use this API, please enable `tikv.enable_atomic_for_cas`.
key
- keyvalue
- valuevoid compareAndSet(com.google.protobuf.ByteString key, Optional<com.google.protobuf.ByteString> prevValue, com.google.protobuf.ByteString value, long ttl)
To use this API, please enable `tikv.enable_atomic_for_cas`.
key
- keyvalue
- valuettl
- TTL of key (in seconds), 0 means the key will never be outdated.void batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs)
kvPairs
- kvPairsvoid batchPut(Map<com.google.protobuf.ByteString,com.google.protobuf.ByteString> kvPairs, long ttl)
kvPairs
- kvPairsttl
- the TTL of keys to be put (in seconds), 0 means the keys will never be outdatedOptional<com.google.protobuf.ByteString> get(com.google.protobuf.ByteString key)
key
- raw keyList<Kvrpcpb.KvPair> batchGet(List<com.google.protobuf.ByteString> keys)
keys
- list of raw keyvoid batchDelete(List<com.google.protobuf.ByteString> keys)
keys
- list of raw keyOptional<Long> getKeyTTL(com.google.protobuf.ByteString key)
key
- raw keyList<List<com.google.protobuf.ByteString>> batchScanKeys(List<Pair<com.google.protobuf.ByteString,com.google.protobuf.ByteString>> ranges, int eachLimit)
WARNING: 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.
ranges
- a list of rangesList<List<Kvrpcpb.KvPair>> batchScan(List<ScanOption> ranges)
WARNING: 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.
ranges
- a list of `ScanOption` for each rangeList<Kvrpcpb.KvPair> scan(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 MAX_RAW_SCAN_LIMIT
List<Kvrpcpb.KvPair> scan(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 MAX_RAW_SCAN_LIMIT
keyOnly
- whether to scan in key-only modeList<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, int limit)
startKey
- raw start key, inclusivelimit
- limit of key-value pairs scanned, should be less than MAX_RAW_SCAN_LIMIT
List<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, int limit, boolean keyOnly)
startKey
- raw start key, inclusivelimit
- limit of key-value pairs scanned, should be less than MAX_RAW_SCAN_LIMIT
keyOnly
- whether to scan in key-only modeList<Kvrpcpb.KvPair> scan(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey)
startKey
- raw start key, inclusiveendKey
- raw end key, exclusiveList<Kvrpcpb.KvPair> scan(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 modeList<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey, int limit, boolean keyOnly)
prefixKey
- prefix keylimit
- limit of keys retrievedkeyOnly
- whether to scan in keyOnly modeList<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey)
List<Kvrpcpb.KvPair> scanPrefix(com.google.protobuf.ByteString prefixKey, boolean keyOnly)
void delete(com.google.protobuf.ByteString key)
key
- raw key to be deletedvoid deleteRange(com.google.protobuf.ByteString startKey, com.google.protobuf.ByteString endKey)
Cautious, this API cannot be used concurrently, if multiple clients write keys into this range along with deleteRange API, the result will be undefined.
startKey
- raw start key to be deletedendKey
- raw start key to be deletedvoid deletePrefix(com.google.protobuf.ByteString key)
Cautious, this API cannot be used concurrently, if multiple clients write keys into this range along with deleteRange API, the result will be undefined.
key
- prefix of keys to be deletedTiSession getSession()
Copyright © 2024 PingCAP. All rights reserved.