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 to reimplement check_and_mutate #672

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Jan 6, 2021

What problem does this PR solve?

use rocksdb_wrapper 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:34803
>>> 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          : 9
server          : 10.232.55.210:34803
>>> get a b1
Not found

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

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

app_id          : 2
partition_index : 4
decree          : 14
server          : 10.232.55.210:34803
>>> 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          : 18
server          : 10.232.55.210:34803
>>> get a b1
"c1"

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

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

app_id          : 2
partition_index : 4
decree          : 21
server          : 10.232.55.210:34803
>>> 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          : 24
server          : 10.232.55.210:34803
>>> exist a b3
False

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34803
>>> 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          : 28
server          : 10.232.55.210:34803
>>> get a b3
"c3"

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34803

@levy5307 levy5307 merged commit cee7f8e into apache:master Jan 7, 2021
@levy5307 levy5307 deleted the check_and_mutate branch January 7, 2021 08:50
@neverchanje neverchanje mentioned this pull request Mar 1, 2021
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