-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) contains key api #302
Conversation
} | ||
|
||
private void internalContainsKey(final byte[] key, final CompletableFuture<Boolean> future, | ||
final int retriesLeft, final Errors lastCause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一行没有格式化
/** | ||
* Returns whether database contains the specified input key. | ||
* | ||
* @param key the specified key database contains. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
格式化
public void containsKey(final byte[] key, final KVStoreClosure closure) { | ||
final Timer.Context timeCtx = getTimeContext("CONTAINS_KEY"); | ||
try { | ||
final Boolean isContains = this.defaultDB.containsKey(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final boolean exists = this.defaultDB.containsKey(key);
@@ -153,7 +153,8 @@ private void doStatistics() { | |||
KVMetrics.counter(REGION_BYTES_WRITTEN, id).inc(this.bytesWritten); | |||
break; | |||
} | |||
case KVOperation.GET: { | |||
case KVOperation.GET: | |||
case KVOperation.CONTAINS_KEY: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CastException
final Lock readLock = this.readWriteLock.readLock(); | ||
readLock.lock(); | ||
try { | ||
final Boolean isContains = this.db.keyMayExist(key, new StringBuilder(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final boolean exists = this.db.keyMayExist(key, new StringBuilder(0));
readLock.lock(); | ||
try { | ||
final boolean exists = this.db.keyMayExist(key, new StringBuilder(0)); | ||
setSuccess(closure, exists); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean exists = false;
if (this.db.keyMayExist(key, new StringBuilder(0))) {
exists = this.db.get(key) != null;
}
应该是这样的逻辑
* 'master' of https://github.com/sofastack/sofa-jraft: (feat) Remove multiple of 10ms for windows platform. (sofastack#351) (feat) add thread pool metric report (sofastack#339) [ISSUE#347]upgrade the com.fasterxml.jackson.core:jackson-databind to version 2.9.10.1. (sofastack#352) (feat) Support readIndex from learner (sofastack#343) (feat) counter example (sofastack#318) minor fixes (sofastack#336) Impl learner for jraft, sofastack#8 (sofastack#312) (fix) Declare rpcClient to be volatile, fix sofastack#319 (sofastack#323) (feat) add current leader id to node describe (sofastack#322) (fix) fix remove metric failed on replicator destroy (sofastack#325) (fix) raft options copy (sofastack#321) (feat) contains key api (sofastack#302) (feat) add rocksdb table_format_config and statistics (sofastack#295) feat/async snapshot (sofastack#287) fix/state listener (sofastack#285)
Motivation:
Provide containsKey(byte[] key) method similar to get(byte[] key) etc.
Modification:
RheaKVStore provide containsKey(byte[] key) method similar to get(byte[] key) etc.
Result:
Fixes #290