Change type of cache buffer passed to Cache::CreateCallback()
to const void*
(#9595)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/9595 Reviewed By: riversand963 Differential Revision: D34329906 Pulled By: ajkr fbshipit-source-id: 508601856fa9bee4d40f4a68d14d333ef2143d40
This commit is contained in:
parent
48b9de4a3e
commit
54fb2a8975
@ -32,6 +32,7 @@
|
|||||||
* Remove DBOptions::preserved_deletes and DB::SetPreserveDeletesSequenceNumber().
|
* Remove DBOptions::preserved_deletes and DB::SetPreserveDeletesSequenceNumber().
|
||||||
* Remove deprecated API AdvancedColumnFamilyOptions::rate_limit_delay_max_milliseconds.
|
* Remove deprecated API AdvancedColumnFamilyOptions::rate_limit_delay_max_milliseconds.
|
||||||
* Removed timestamp from WriteOptions. Accordingly, added to DB APIs Put, Delete, SingleDelete, etc. accepting an additional argument 'timestamp'. Added Put, Delete, SingleDelete, etc to WriteBatch accepting an additional argument 'timestamp'. Removed WriteBatch::AssignTimestamps(vector<Slice>) API. Renamed WriteBatch::AssignTimestamp() to WriteBatch::UpdateTimestamps() with clarified comments.
|
* Removed timestamp from WriteOptions. Accordingly, added to DB APIs Put, Delete, SingleDelete, etc. accepting an additional argument 'timestamp'. Added Put, Delete, SingleDelete, etc to WriteBatch accepting an additional argument 'timestamp'. Removed WriteBatch::AssignTimestamps(vector<Slice>) API. Renamed WriteBatch::AssignTimestamp() to WriteBatch::UpdateTimestamps() with clarified comments.
|
||||||
|
* Changed type of cache buffer passed to `Cache::CreateCallback` from `void*` to `const void*`.
|
||||||
* Significant updates to FilterPolicy-related APIs and configuration:
|
* Significant updates to FilterPolicy-related APIs and configuration:
|
||||||
* Remove public API support for deprecated, inefficient block-based filter (use_block_based_builder=true).
|
* Remove public API support for deprecated, inefficient block-based filter (use_block_based_builder=true).
|
||||||
* Old code and configuration strings that would enable it now quietly enable full filters instead, though any built-in FilterPolicy can still read block-based filters. This includes changing the longstanding default behavior of the Java API.
|
* Old code and configuration strings that would enable it now quietly enable full filters instead, though any built-in FilterPolicy can still read block-based filters. This includes changing the longstanding default behavior of the Java API.
|
||||||
|
5
cache/cache_bench_tool.cc
vendored
5
cache/cache_bench_tool.cc
vendored
@ -510,8 +510,9 @@ class CacheBench {
|
|||||||
timer.Start();
|
timer.Start();
|
||||||
Slice key = gen.GetRand(thread->rnd, max_key_, max_log_);
|
Slice key = gen.GetRand(thread->rnd, max_key_, max_log_);
|
||||||
uint64_t random_op = thread->rnd.Next();
|
uint64_t random_op = thread->rnd.Next();
|
||||||
Cache::CreateCallback create_cb =
|
Cache::CreateCallback create_cb = [](const void* buf, size_t size,
|
||||||
[](void* buf, size_t size, void** out_obj, size_t* charge) -> Status {
|
void** out_obj,
|
||||||
|
size_t* charge) -> Status {
|
||||||
*out_obj = reinterpret_cast<void*>(new char[size]);
|
*out_obj = reinterpret_cast<void*>(new char[size]);
|
||||||
memcpy(*out_obj, buf, size);
|
memcpy(*out_obj, buf, size);
|
||||||
*charge = size;
|
*charge = size;
|
||||||
|
5
cache/lru_cache_test.cc
vendored
5
cache/lru_cache_test.cc
vendored
@ -432,8 +432,9 @@ class LRUSecondaryCacheTest : public LRUCacheTest {
|
|||||||
|
|
||||||
static Cache::CacheItemHelper helper_fail_;
|
static Cache::CacheItemHelper helper_fail_;
|
||||||
|
|
||||||
Cache::CreateCallback test_item_creator =
|
Cache::CreateCallback test_item_creator = [&](const void* buf, size_t size,
|
||||||
[&](void* buf, size_t size, void** out_obj, size_t* charge) -> Status {
|
void** out_obj,
|
||||||
|
size_t* charge) -> Status {
|
||||||
if (fail_create_) {
|
if (fail_create_) {
|
||||||
return Status::NotSupported();
|
return Status::NotSupported();
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ class Cache {
|
|||||||
// takes in a buffer from the NVM cache and constructs an object using
|
// takes in a buffer from the NVM cache and constructs an object using
|
||||||
// it. The callback doesn't have ownership of the buffer and should
|
// it. The callback doesn't have ownership of the buffer and should
|
||||||
// copy the contents into its own buffer.
|
// copy the contents into its own buffer.
|
||||||
using CreateCallback = std::function<Status(void* buf, size_t size,
|
using CreateCallback = std::function<Status(const void* buf, size_t size,
|
||||||
void** out_obj, size_t* charge)>;
|
void** out_obj, size_t* charge)>;
|
||||||
|
|
||||||
Cache(std::shared_ptr<MemoryAllocator> allocator = nullptr)
|
Cache(std::shared_ptr<MemoryAllocator> allocator = nullptr)
|
||||||
|
@ -25,7 +25,8 @@ Cache::CreateCallback GetCreateCallback(size_t read_amp_bytes_per_bit,
|
|||||||
Statistics* statistics, bool using_zstd,
|
Statistics* statistics, bool using_zstd,
|
||||||
const FilterPolicy* filter_policy) {
|
const FilterPolicy* filter_policy) {
|
||||||
return [read_amp_bytes_per_bit, statistics, using_zstd, filter_policy](
|
return [read_amp_bytes_per_bit, statistics, using_zstd, filter_policy](
|
||||||
void* buf, size_t size, void** out_obj, size_t* charge) -> Status {
|
const void* buf, size_t size, void** out_obj,
|
||||||
|
size_t* charge) -> Status {
|
||||||
assert(buf != nullptr);
|
assert(buf != nullptr);
|
||||||
std::unique_ptr<char[]> buf_data(new char[size]());
|
std::unique_ptr<char[]> buf_data(new char[size]());
|
||||||
memcpy(buf_data.get(), buf, size);
|
memcpy(buf_data.get(), buf, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user