diff --git a/HISTORY.md b/HISTORY.md index 57bc4f5d9..52c2f9c0c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -32,6 +32,7 @@ * Remove DBOptions::preserved_deletes and DB::SetPreserveDeletesSequenceNumber(). * 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) 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: * 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. diff --git a/cache/cache_bench_tool.cc b/cache/cache_bench_tool.cc index b63afc1e0..cd9fac3d9 100644 --- a/cache/cache_bench_tool.cc +++ b/cache/cache_bench_tool.cc @@ -510,8 +510,9 @@ class CacheBench { timer.Start(); Slice key = gen.GetRand(thread->rnd, max_key_, max_log_); uint64_t random_op = thread->rnd.Next(); - Cache::CreateCallback create_cb = - [](void* buf, size_t size, void** out_obj, size_t* charge) -> Status { + Cache::CreateCallback create_cb = [](const void* buf, size_t size, + void** out_obj, + size_t* charge) -> Status { *out_obj = reinterpret_cast(new char[size]); memcpy(*out_obj, buf, size); *charge = size; diff --git a/cache/lru_cache_test.cc b/cache/lru_cache_test.cc index e8eb63826..865a03751 100644 --- a/cache/lru_cache_test.cc +++ b/cache/lru_cache_test.cc @@ -432,8 +432,9 @@ class LRUSecondaryCacheTest : public LRUCacheTest { static Cache::CacheItemHelper helper_fail_; - Cache::CreateCallback test_item_creator = - [&](void* buf, size_t size, void** out_obj, size_t* charge) -> Status { + Cache::CreateCallback test_item_creator = [&](const void* buf, size_t size, + void** out_obj, + size_t* charge) -> Status { if (fail_create_) { return Status::NotSupported(); } diff --git a/include/rocksdb/cache.h b/include/rocksdb/cache.h index 772977df3..75fbea0e8 100644 --- a/include/rocksdb/cache.h +++ b/include/rocksdb/cache.h @@ -206,7 +206,7 @@ class Cache { // 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 // copy the contents into its own buffer. - using CreateCallback = std::function; Cache(std::shared_ptr allocator = nullptr) diff --git a/table/block_based/block_like_traits.h b/table/block_based/block_like_traits.h index ccfa8bc56..de9e8a440 100644 --- a/table/block_based/block_like_traits.h +++ b/table/block_based/block_like_traits.h @@ -25,7 +25,8 @@ Cache::CreateCallback GetCreateCallback(size_t read_amp_bytes_per_bit, Statistics* statistics, bool using_zstd, const FilterPolicy* 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); std::unique_ptr buf_data(new char[size]()); memcpy(buf_data.get(), buf, size);