From 5bb49a36c00f8888623699cf63bc1b3a5bfa958c Mon Sep 17 00:00:00 2001 From: birdstorm Date: Thu, 24 Jun 2021 14:22:52 +0800 Subject: [PATCH 1/2] update v3.1.0 document Signed-off-by: birdstorm --- README.md | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 198 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cd4ab8ed4b1..d03f1994cc4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ After building, add following lines into your `pom.xml` if you are using Maven org.tikv tikv-client-java - 3.0.1 + 3.1.0 ``` @@ -80,7 +80,7 @@ public class Main { } ``` -### API +### RawKVClient API ```java /** @@ -89,7 +89,71 @@ public class Main { * @param key raw key * @param value raw value */ -void put(ByteString key, ByteString value) +public void put(ByteString key, ByteString value) + +/** + * Put a raw key-value pair to TiKV + * + * @param key raw key + * @param value raw value + * @param ttl the ttl of the key (in seconds), 0 means the key will never be outdated + */ +public void put(ByteString key, ByteString value, long ttl) + +/** + * Put a key-value pair if it does not exist. This API is atomic. + * + * @param key key + * @param value value + * @return a ByteString. returns ByteString.EMPTY if the value is written successfully. returns + * the previous key if the value already exists, and does not write to TiKV. + */ +public ByteString putIfAbsent(ByteString key, ByteString value) + +/** + * Put a key-value pair with TTL if it does not exist. This API is atomic. + * + * @param key key + * @param value value + * @param ttl TTL of key (in seconds), 0 means the key will never be outdated. + * @return a ByteString. returns ByteString.EMPTY if the value is written successfully. returns + * the previous key if the value already exists, and does not write to TiKV. + */ +public ByteString putIfAbsent(ByteString key, ByteString value, long ttl) +``` + +```java +/** + * Put a set of raw key-value pair to TiKV, this API does not ensure the operation is atomic. + * + * @param kvPairs kvPairs + */ +public void batchPut(Map kvPairs) + +/** + * Put a set of raw key-value pair to TiKV, this API does not ensure the operation is atomic. + * + * @param kvPairs kvPairs + * @param ttl the TTL of keys to be put (in seconds), 0 means the keys will never be outdated + */ +public void batchPut(Map kvPairs, long ttl) + +/** + * Put a set of raw key-value pair to TiKV, this API is atomic + * + * @param kvPairs kvPairs + */ +public void batchPutAtomic(Map kvPairs) + +/** + * Put a set of raw key-value pair to TiKV, this API is atomic. + * + * @param kvPairs kvPairs + * @param ttl the TTL of keys to be put (in seconds), 0 means the keys will never be outdated + */ +public void batchPutAtomic(Map kvPairs, long ttl) + + ``` ```java @@ -99,7 +163,44 @@ void put(ByteString key, ByteString value) * @param key raw key * @return a ByteString value if key exists, ByteString.EMPTY if key does not exist */ -ByteString get(ByteString key) +public ByteString get(ByteString key) +``` + +```java +/** + * Get a list of raw key-value pair from TiKV if key exists + * + * @param keys list of raw key + * @return a ByteString value if key exists, ByteString.EMPTY if key does not exist + */ +public List batchGet(List keys) +``` + +```java +/** + * Delete a list of raw key-value pair from TiKV if key exists + * + * @param keys list of raw key + */ +public void batchDelete(List keys) + +/** + * Delete a list of raw key-value pair from TiKV if key exists, this API is atomic + * + * @param keys list of raw key + */ +public void batchDeleteAtomic(List keys) +``` + +```java +/** + * Get the TTL of a raw key from TiKV if key exists + * + * @param key raw key + * @return a Long indicating the TTL of key ttl is a non-null long value indicating TTL if key + * exists. - ttl=0 if the key will never be outdated. - ttl=null if the key does not exist + */ +public Long getKeyTTL(ByteString key) ``` ```java @@ -111,18 +212,85 @@ ByteString get(ByteString key) * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} * @return list of key-value pairs in range */ -List scan(ByteString startKey, ByteString endKey, int limit) -``` +public List scan(ByteString startKey, ByteString endKey, int limit) -```java /** * Scan raw key-value pairs from TiKV in range [startKey, endKey) * * @param startKey raw start key, inclusive + * @param endKey raw end key, exclusive * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} + * @param keyOnly whether to scan in key-only mode * @return list of key-value pairs in range */ -List scan(ByteString startKey, int limit) +public List scan(ByteString startKey, ByteString endKey, int limit, boolean keyOnly) + +/** + * Scan raw key-value pairs from TiKV in range [startKey, ♾) + * + * @param startKey raw start key, inclusive + * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} + * @return list of key-value pairs in range + */ +public List scan(ByteString startKey, int limit) + +/** + * Scan raw key-value pairs from TiKV in range [startKey, ♾) + * + * @param startKey raw start key, inclusive + * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} + * @param keyOnly whether to scan in key-only mode + * @return list of key-value pairs in range + */ +public List scan(ByteString startKey, int limit, boolean keyOnly) + +/** + * Scan all raw key-value pairs from TiKV in range [startKey, endKey) + * + * @param startKey raw start key, inclusive + * @param endKey raw end key, exclusive + * @return list of key-value pairs in range + */ +public List scan(ByteString startKey, ByteString endKey) + +/** + * Scan all raw key-value pairs from TiKV in range [startKey, endKey) + * + * @param startKey raw start key, inclusive + * @param endKey raw end key, exclusive + * @param keyOnly whether to scan in key-only mode + * @return list of key-value pairs in range + */ +public List scan(ByteString startKey, ByteString endKey, boolean keyOnly) +``` + +```java +/** + * Scan keys with prefix + * + * @param prefixKey prefix key + * @param limit limit of keys retrieved + * @param keyOnly whether to scan in keyOnly mode + * @return kvPairs with the specified prefix + */ +public List scanPrefix(ByteString prefixKey, int limit, boolean keyOnly) + +/** + * Scan keys with prefix without limit and retrieve key and value + * + * @param prefixKey prefix key + * @return kvPairs with the specified prefix + */ +public List scanPrefix(ByteString prefixKey) + +/** + * Scan keys with prefix without limit + * + * @param prefixKey prefix key + * @param keyOnly whether to scan in keyOnly mode + * @return kvPairs with the specified prefix + */ +public List scanPrefix(ByteString prefixKey, boolean keyOnly) ``` ```java @@ -131,7 +299,28 @@ List scan(ByteString startKey, int limit) * * @param key raw key to be deleted */ -void delete(ByteString key) +public void delete(ByteString key) + +/** + * 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. + * + * @param startKey raw start key to be deleted + * @param endKey raw start key to be deleted + */ +public synchronized void deleteRange(ByteString startKey, ByteString endKey) + +/** + * 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. + * + * @param key prefix of keys to be deleted + */ +public synchronized void deletePrefix(ByteString key) ``` ## Java Client Configuration Parameter From e0be63d13be68abf0ade7db1b97b856f34cbe19a Mon Sep 17 00:00:00 2001 From: birdstorm Date: Fri, 25 Jun 2021 13:10:27 +0800 Subject: [PATCH 2/2] remove api document Signed-off-by: birdstorm --- README.md | 243 ------------------------------------------------------ 1 file changed, 243 deletions(-) diff --git a/README.md b/README.md index d03f1994cc4..4f496812363 100644 --- a/README.md +++ b/README.md @@ -80,249 +80,6 @@ public class Main { } ``` -### RawKVClient API - -```java -/** - * Put a raw key-value pair to TiKV - * - * @param key raw key - * @param value raw value - */ -public void put(ByteString key, ByteString value) - -/** - * Put a raw key-value pair to TiKV - * - * @param key raw key - * @param value raw value - * @param ttl the ttl of the key (in seconds), 0 means the key will never be outdated - */ -public void put(ByteString key, ByteString value, long ttl) - -/** - * Put a key-value pair if it does not exist. This API is atomic. - * - * @param key key - * @param value value - * @return a ByteString. returns ByteString.EMPTY if the value is written successfully. returns - * the previous key if the value already exists, and does not write to TiKV. - */ -public ByteString putIfAbsent(ByteString key, ByteString value) - -/** - * Put a key-value pair with TTL if it does not exist. This API is atomic. - * - * @param key key - * @param value value - * @param ttl TTL of key (in seconds), 0 means the key will never be outdated. - * @return a ByteString. returns ByteString.EMPTY if the value is written successfully. returns - * the previous key if the value already exists, and does not write to TiKV. - */ -public ByteString putIfAbsent(ByteString key, ByteString value, long ttl) -``` - -```java -/** - * Put a set of raw key-value pair to TiKV, this API does not ensure the operation is atomic. - * - * @param kvPairs kvPairs - */ -public void batchPut(Map kvPairs) - -/** - * Put a set of raw key-value pair to TiKV, this API does not ensure the operation is atomic. - * - * @param kvPairs kvPairs - * @param ttl the TTL of keys to be put (in seconds), 0 means the keys will never be outdated - */ -public void batchPut(Map kvPairs, long ttl) - -/** - * Put a set of raw key-value pair to TiKV, this API is atomic - * - * @param kvPairs kvPairs - */ -public void batchPutAtomic(Map kvPairs) - -/** - * Put a set of raw key-value pair to TiKV, this API is atomic. - * - * @param kvPairs kvPairs - * @param ttl the TTL of keys to be put (in seconds), 0 means the keys will never be outdated - */ -public void batchPutAtomic(Map kvPairs, long ttl) - - -``` - -```java -/** - * Get a raw key-value pair from TiKV if key exists - * - * @param key raw key - * @return a ByteString value if key exists, ByteString.EMPTY if key does not exist - */ -public ByteString get(ByteString key) -``` - -```java -/** - * Get a list of raw key-value pair from TiKV if key exists - * - * @param keys list of raw key - * @return a ByteString value if key exists, ByteString.EMPTY if key does not exist - */ -public List batchGet(List keys) -``` - -```java -/** - * Delete a list of raw key-value pair from TiKV if key exists - * - * @param keys list of raw key - */ -public void batchDelete(List keys) - -/** - * Delete a list of raw key-value pair from TiKV if key exists, this API is atomic - * - * @param keys list of raw key - */ -public void batchDeleteAtomic(List keys) -``` - -```java -/** - * Get the TTL of a raw key from TiKV if key exists - * - * @param key raw key - * @return a Long indicating the TTL of key ttl is a non-null long value indicating TTL if key - * exists. - ttl=0 if the key will never be outdated. - ttl=null if the key does not exist - */ -public Long getKeyTTL(ByteString key) -``` - -```java -/** - * Scan raw key-value pairs from TiKV in range [startKey, endKey) - * - * @param startKey raw start key, inclusive - * @param endKey raw end key, exclusive - * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, ByteString endKey, int limit) - -/** - * Scan raw key-value pairs from TiKV in range [startKey, endKey) - * - * @param startKey raw start key, inclusive - * @param endKey raw end key, exclusive - * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} - * @param keyOnly whether to scan in key-only mode - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, ByteString endKey, int limit, boolean keyOnly) - -/** - * Scan raw key-value pairs from TiKV in range [startKey, ♾) - * - * @param startKey raw start key, inclusive - * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, int limit) - -/** - * Scan raw key-value pairs from TiKV in range [startKey, ♾) - * - * @param startKey raw start key, inclusive - * @param limit limit of key-value pairs scanned, should be less than {@link #MAX_RAW_SCAN_LIMIT} - * @param keyOnly whether to scan in key-only mode - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, int limit, boolean keyOnly) - -/** - * Scan all raw key-value pairs from TiKV in range [startKey, endKey) - * - * @param startKey raw start key, inclusive - * @param endKey raw end key, exclusive - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, ByteString endKey) - -/** - * Scan all raw key-value pairs from TiKV in range [startKey, endKey) - * - * @param startKey raw start key, inclusive - * @param endKey raw end key, exclusive - * @param keyOnly whether to scan in key-only mode - * @return list of key-value pairs in range - */ -public List scan(ByteString startKey, ByteString endKey, boolean keyOnly) -``` - -```java -/** - * Scan keys with prefix - * - * @param prefixKey prefix key - * @param limit limit of keys retrieved - * @param keyOnly whether to scan in keyOnly mode - * @return kvPairs with the specified prefix - */ -public List scanPrefix(ByteString prefixKey, int limit, boolean keyOnly) - -/** - * Scan keys with prefix without limit and retrieve key and value - * - * @param prefixKey prefix key - * @return kvPairs with the specified prefix - */ -public List scanPrefix(ByteString prefixKey) - -/** - * Scan keys with prefix without limit - * - * @param prefixKey prefix key - * @param keyOnly whether to scan in keyOnly mode - * @return kvPairs with the specified prefix - */ -public List scanPrefix(ByteString prefixKey, boolean keyOnly) -``` - -```java -/** - * Delete a raw key-value pair from TiKV if key exists - * - * @param key raw key to be deleted - */ -public void delete(ByteString key) - -/** - * 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. - * - * @param startKey raw start key to be deleted - * @param endKey raw start key to be deleted - */ -public synchronized void deleteRange(ByteString startKey, ByteString endKey) - -/** - * 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. - * - * @param key prefix of keys to be deleted - */ -public synchronized void deletePrefix(ByteString key) -``` - ## Java Client Configuration Parameter ### JVM Parameter