levy5307 opened a new pull request #672:
URL: https://github.com/apache/incubator-pegasus/pull/672
### What problem does this PR solve? <!--add issue link with summary if
exists-->
use rocksdb_wrapper to reimplement check_and_mutate
### Check List <!--REMOVE the items that are not applicable-->
Tests <!-- At least one of them must be included. -->
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
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]