Skip to content
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

refactor: use rocksdb_wrapper::get to reimplement check_and_mutate #655

Merged
merged 2 commits into from
Dec 14, 2020

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Dec 10, 2020

What problem does this PR solve?

use rocksdb_wrapper::get to reimplement check_and_mutate.

Check List

Tests

There are a lot of function tests in test_check_and_mutate.cpp.

  • Manual test (add detailed scripts or steps below)
>>> use temp
OK
>>> exist a b 
False

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> check_and_mutate a -c b -t exist -r
Load mutations, like
  set <sort_key> <value> [ttl]
  del <sort_key>
Print "ok" to finish loading, "abort" to abort this command
>>> set b1 c1
LOAD: set sortkey "b1", value "c1", ttl 0
>>> set b2 c2
LOAD: set sortkey "b2", value "c2", ttl 0
>>> ok
INFO: load mutations done.

hash_key: "a"
check_sort_key: "b"
check_type: exist
return_check_value: true
mutations:
  mutation[0].type: SET
  mutation[0].sort_key: "b1"
  mutation[0].value: "c1"
  mutation[0].expire_seconds: 0
  mutation[1].type: SET
  mutation[1].sort_key: "b2"
  mutation[1].value: "c2"
  mutation[1].expire_seconds: 0

Mutate failed, because check not passed.

Check value not exist.

app_id          : 2
partition_index : 4
decree          : 13
server          : 10.232.55.210:34802
>>> get a b1
Not found

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> get a b2
Not found

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> set a b c
OK

app_id          : 2
partition_index : 4
decree          : 14
server          : 10.232.55.210:34802
>>> check_and_mutate a -c b -t exist -r
Load mutations, like
  set <sort_key> <value> [ttl]
  del <sort_key>
Print "ok" to finish loading, "abort" to abort this command
>>> set b1 c1
LOAD: set sortkey "b1", value "c1", ttl 0
>>> set b2 c2
LOAD: set sortkey "b2", value "c2", ttl 0
>>> ok
INFO: load mutations done.

hash_key: "a"
check_sort_key: "b"
check_type: exist
return_check_value: true
mutations:
  mutation[0].type: SET
  mutation[0].sort_key: "b1"
  mutation[0].value: "c1"
  mutation[0].expire_seconds: 0
  mutation[1].type: SET
  mutation[1].sort_key: "b2"
  mutation[1].value: "c2"
  mutation[1].expire_seconds: 0

Mutate succeed.

Check value: "c"

app_id          : 2
partition_index : 4
decree          : 16
server          : 10.232.55.210:34802
>>> get a b1
"c1"

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> get a b2
"c2"

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> set a b c 1
OK

app_id          : 2
partition_index : 4
decree          : 19
server          : 10.232.55.210:34802
>>> check_and_mutate a -c b -t exist -r
Load mutations, like
  set <sort_key> <value> [ttl]
  del <sort_key>
Print "ok" to finish loading, "abort" to abort this command
>>> set b3 c3
LOAD: set sortkey "b3", value "c3", ttl 0
>>> ok
INFO: load mutations done.

hash_key: "a"
check_sort_key: "b"
check_type: exist
return_check_value: true
mutations:
  mutation[0].type: SET
  mutation[0].sort_key: "b3"
  mutation[0].value: "c3"
  mutation[0].expire_seconds: 0

Mutate failed, because check not passed.

Check value not exist.

app_id          : 2
partition_index : 4
decree          : 20
server          : 10.232.55.210:34802
>>> exist a b3
False

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> check_and_mutate a -c b -t not_exist -r
Load mutations, like
  set <sort_key> <value> [ttl]
  del <sort_key>
Print "ok" to finish loading, "abort" to abort this command
>>> set b3 c3
LOAD: set sortkey "b3", value "c3", ttl 0
>>> ok
INFO: load mutations done.

hash_key: "a"
check_sort_key: "b"
check_type: not_exist
return_check_value: true
mutations:
  mutation[0].type: SET
  mutation[0].sort_key: "b3"
  mutation[0].value: "c3"
  mutation[0].expire_seconds: 0

Mutate succeed.

Check value not exist.

app_id          : 2
partition_index : 4
decree          : 39
server          : 10.232.55.210:34802
>>> get a b3
"c3"

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802

@hycdong hycdong merged commit df8f41e into apache:master Dec 14, 2020
@neverchanje neverchanje mentioned this pull request Mar 1, 2021
@levy5307 levy5307 deleted the check-and-mutate branch March 18, 2021 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants