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::write_batch_put to reimplement check_and_set #656

Merged
merged 13 commits into from
Dec 30, 2020

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Dec 14, 2020

What problem does this PR solve?

use rocksdb_wrapper::write_batch_put to reimplement check_and_set

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)
>>> use temp
OK
>>> use temp
OK
>>> check_and_set a -c b -t exist -s b1 -v c1 -r
hash_key: "a"
check_sort_key: "b"
check_type: exist
set_sort_key: "b1"
set_value: "c1"
set_value_ttl_seconds: 0
return_check_value: true

Set failed, because check not passed.

Check value not exist.

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

app_id          : 2
partition_index : 4
decree          : 10
server          : 10.232.55.210:34802
>>> get a b 
"c"

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> check_and_set a -c b -t exist -s b1 -v c1 -r
hash_key: "a"
check_sort_key: "b"
check_type: exist
set_sort_key: "b1"
set_value: "c1"
set_value_ttl_seconds: 0
return_check_value: true

Set succeed.

Check value: "c"

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

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          : 14
server          : 10.232.55.210:34802
>>> check_and_set a -c b -t exist -s b2 -v c2 -r
hash_key: "a"
check_sort_key: "b"
check_type: exist
set_sort_key: "b2"
set_value: "c2"
set_value_ttl_seconds: 0
return_check_value: true

Set failed, because check not passed.

Check value not exist.

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

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802
>>> check_and_set a -c b -t not_exist -s b2 -v c2 -r
hash_key: "a"
check_sort_key: "b"
check_type: not_exist
set_sort_key: "b2"
set_value: "c2"
set_value_ttl_seconds: 0
return_check_value: true

Set succeed.

Check value not exist.

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

app_id          : 2
partition_index : 4
server          : 10.232.55.210:34802

src/server/pegasus_write_service_impl.h Outdated Show resolved Hide resolved
src/server/rocksdb_wrapper.cpp Outdated Show resolved Hide resolved
src/server/rocksdb_write_batch_cleaner.h Outdated Show resolved Hide resolved
src/server/pegasus_write_service_impl.h Outdated Show resolved Hide resolved
acelyc111
acelyc111 previously approved these changes Dec 24, 2020
Comment on lines +74 to +77
std::unique_ptr<pegasus_value_generator> _value_generator;
std::unique_ptr<rocksdb::WriteBatch> _write_batch;
std::unique_ptr<rocksdb::WriteOptions> _wt_opts;
rocksdb::ColumnFamilyHandle *_meta_cf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::unique_ptr<pegasus_value_generator> _value_generator;
std::unique_ptr<rocksdb::WriteBatch> _write_batch;
std::unique_ptr<rocksdb::WriteOptions> _wt_opts;
rocksdb::ColumnFamilyHandle *_meta_cf;
pegasus_value_generator _value_generator;
rocksdb::WriteBatch _write_batch;
rocksdb::WriteOptions _wt_opts;
rocksdb::ColumnFamilyHandle *_meta_cf;

Why not use value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce file dependencies

@hycdong hycdong merged commit 6dae647 into apache:master Dec 30, 2020
@neverchanje neverchanje mentioned this pull request Mar 1, 2021
@levy5307 levy5307 deleted the write-check-and-set 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.

4 participants