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

server: support default TTL for a table #206

Merged
merged 39 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
40be8ff
use static lib s2
acelyc111 Jul 12, 2018
cb631bb
Merge branch 'master' into master
acelyc111 Jul 13, 2018
971ce36
Merge branch 'master' into master
acelyc111 Jul 13, 2018
74d9bc3
update rdns
acelyc111 Jul 13, 2018
883f005
Merge branch 'master' of github.com:acelyc111/pegasus
acelyc111 Jul 13, 2018
7523b21
Merge branch 'master' of github.com:acelyc111/pegasus
acelyc111 Jul 14, 2018
fd9464f
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Jul 16, 2018
beb3103
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Jul 17, 2018
65a33cd
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Jul 18, 2018
c08ea38
fix pack tools script
acelyc111 Jul 18, 2018
a253cd6
Merge branch 'master' into master
acelyc111 Jul 18, 2018
f7005eb
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Jul 23, 2018
b748938
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Jul 30, 2018
b3d473e
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Aug 6, 2018
2e5dfc3
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Aug 15, 2018
a92048e
Merge remote-tracking branch 'origin_xm/master'
acelyc111 Aug 29, 2018
8b9abc5
Merge branch 'master' of github.com:acelyc111/pegasus
acelyc111 Oct 29, 2018
5c3c71c
support default ttl for tabele
acelyc111 Oct 29, 2018
40a487b
fix pointer bug
acelyc111 Oct 30, 2018
7dcb369
rename
acelyc111 Oct 30, 2018
8e4dca2
add test cases
acelyc111 Oct 30, 2018
550792e
code style
acelyc111 Oct 30, 2018
0a86ec8
Merge branch 'master' into default_ttl
acelyc111 Oct 30, 2018
e9d9fb1
fix compile error
acelyc111 Oct 30, 2018
e27135f
fix by comments
acelyc111 Oct 31, 2018
a91606d
code style
acelyc111 Oct 31, 2018
c86ea4b
Merge branch 'master' into default_ttl
acelyc111 Oct 31, 2018
b1313a2
use volatile instread of atomic
acelyc111 Oct 31, 2018
dec9a49
optimize string copy
acelyc111 Nov 1, 2018
50d1344
update rdns
acelyc111 Jul 13, 2018
d08ece3
Merge branch 'master' of github.com:acelyc111/pegasus
acelyc111 Nov 1, 2018
1d7c6cc
support default ttl for tabele
acelyc111 Oct 29, 2018
7a87a82
fix by comments
acelyc111 Oct 31, 2018
5f60247
code style
acelyc111 Oct 31, 2018
b7b23b1
optimize string copy
acelyc111 Nov 1, 2018
e95e984
Merge branch 'default_ttl' of github.com:acelyc111/pegasus into defau…
acelyc111 Nov 1, 2018
57a5035
rdsn
acelyc111 Nov 1, 2018
cc74160
fix
acelyc111 Nov 1, 2018
b00051a
fix
acelyc111 Nov 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/base/pegasus_value_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ pegasus_extract_user_data(uint32_t version, std::string &&raw_value, ::dsn::blob
user_data.assign(std::move(buf), 0, static_cast<unsigned int>(view.length()));
}

/// Update expire_ts in rocksdb value with given version.
/// The value schema must be in v0.
inline void pegasus_update_expire_ts(uint32_t version, std::string &value, uint32_t new_expire_ts)
acelyc111 marked this conversation as resolved.
Show resolved Hide resolved
{
dassert_f(version <= PEGASUS_VALUE_SCHEMA_MAX_VERSION,
"value schema version({}) must be <= {}",
version,
PEGASUS_VALUE_SCHEMA_MAX_VERSION);
dassert_f(value.length() >= sizeof(uint32_t), "value must include 'expire_ts' header");

new_expire_ts = dsn::endian::hton(new_expire_ts);
memcpy(const_cast<char *>(value.data()), &new_expire_ts, sizeof(uint32_t));
}

/// \return true if expired
inline bool check_if_ts_expired(uint32_t epoch_now, uint32_t expire_ts)
{
Expand Down
12 changes: 2 additions & 10 deletions src/server/key_ttl_compaction_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,8 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter
pegasus_extract_expire_ts(_value_schema_version, utils::to_string_view(existing_value));
if (_default_ttl != 0 && expire_ts == 0) {
// should update ttl
dsn::blob user_data;
pegasus_extract_user_data(_value_schema_version,
std::string(existing_value.data(), existing_value.length()),
user_data);
rocksdb::SliceParts sparts = _gen.generate_value(_value_schema_version,
dsn::string_view(user_data),
utils::epoch_now() + _default_ttl);
for (int i = 0; i < sparts.num_parts; i++) {
*new_value += sparts.parts[i].ToString();
}
*new_value = existing_value.ToString();
pegasus_update_expire_ts(_value_schema_version, *new_value, utils::epoch_now() + _default_ttl);
*value_changed = true;
return false;
}
Expand Down