|
7 | 7 | // Use of this source code is governed by a BSD-style license that can be |
8 | 8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
9 | 9 |
|
10 | | - |
11 | 10 | #include "rocksdb/c.h" |
12 | 11 |
|
13 | 12 | #include <cstdlib> |
@@ -78,6 +77,7 @@ using ROCKSDB_NAMESPACE::EnvOptions; |
78 | 77 | using ROCKSDB_NAMESPACE::FileLock; |
79 | 78 | using ROCKSDB_NAMESPACE::FilterPolicy; |
80 | 79 | using ROCKSDB_NAMESPACE::FlushOptions; |
| 80 | +using ROCKSDB_NAMESPACE::HyperClockCacheOptions; |
81 | 81 | using ROCKSDB_NAMESPACE::InfoLogLevel; |
82 | 82 | using ROCKSDB_NAMESPACE::IngestExternalFileOptions; |
83 | 83 | using ROCKSDB_NAMESPACE::Iterator; |
@@ -208,6 +208,9 @@ struct rocksdb_logger_t { |
208 | 208 | struct rocksdb_lru_cache_options_t { |
209 | 209 | LRUCacheOptions rep; |
210 | 210 | }; |
| 211 | +struct rocksdb_hyper_clock_cache_options_t { |
| 212 | + HyperClockCacheOptions rep; |
| 213 | +}; |
211 | 214 | struct rocksdb_memory_allocator_t { |
212 | 215 | std::shared_ptr<MemoryAllocator> rep; |
213 | 216 | }; |
@@ -4682,6 +4685,53 @@ rocksdb_cache_t* rocksdb_cache_create_lru_opts( |
4682 | 4685 | return c; |
4683 | 4686 | } |
4684 | 4687 |
|
| 4688 | +rocksdb_hyper_clock_cache_options_t* rocksdb_hyper_clock_cache_options_create( |
| 4689 | + size_t capacity, size_t estimated_entry_charge) { |
| 4690 | + return new rocksdb_hyper_clock_cache_options_t{ |
| 4691 | + HyperClockCacheOptions(capacity, estimated_entry_charge)}; |
| 4692 | +} |
| 4693 | + |
| 4694 | +void rocksdb_hyper_clock_cache_options_destroy( |
| 4695 | + rocksdb_hyper_clock_cache_options_t* opt) { |
| 4696 | + delete opt; |
| 4697 | +} |
| 4698 | + |
| 4699 | +void rocksdb_hyper_clock_cache_options_set_capacity( |
| 4700 | + rocksdb_hyper_clock_cache_options_t* opts, size_t capacity) { |
| 4701 | + opts->rep.capacity = capacity; |
| 4702 | +} |
| 4703 | + |
| 4704 | +void rocksdb_hyper_clock_cache_options_set_estimated_entry_charge( |
| 4705 | + rocksdb_hyper_clock_cache_options_t* opts, size_t estimated_entry_charge) { |
| 4706 | + opts->rep.estimated_entry_charge = estimated_entry_charge; |
| 4707 | +} |
| 4708 | + |
| 4709 | +void rocksdb_hyper_clock_cache_options_set_num_shard_bits( |
| 4710 | + rocksdb_hyper_clock_cache_options_t* opts, int num_shard_bits) { |
| 4711 | + opts->rep.num_shard_bits = num_shard_bits; |
| 4712 | +} |
| 4713 | + |
| 4714 | +void rocksdb_hyper_clock_cache_options_set_memory_allocator( |
| 4715 | + rocksdb_hyper_clock_cache_options_t* opts, |
| 4716 | + rocksdb_memory_allocator_t* memory_allocator) { |
| 4717 | + opts->rep.memory_allocator = memory_allocator->rep; |
| 4718 | +} |
| 4719 | + |
| 4720 | +rocksdb_cache_t* rocksdb_cache_create_hyper_clock( |
| 4721 | + size_t capacity, size_t estimated_entry_charge) { |
| 4722 | + HyperClockCacheOptions opts(capacity, estimated_entry_charge); |
| 4723 | + rocksdb_cache_t* c = new rocksdb_cache_t; |
| 4724 | + c->rep = opts.MakeSharedCache(); |
| 4725 | + return c; |
| 4726 | +} |
| 4727 | + |
| 4728 | +rocksdb_cache_t* rocksdb_cache_create_hyper_clock_opts( |
| 4729 | + rocksdb_hyper_clock_cache_options_t* opts) { |
| 4730 | + rocksdb_cache_t* c = new rocksdb_cache_t; |
| 4731 | + c->rep = opts->rep.MakeSharedCache(); |
| 4732 | + return c; |
| 4733 | +} |
| 4734 | + |
4685 | 4735 | void rocksdb_cache_destroy(rocksdb_cache_t* cache) { delete cache; } |
4686 | 4736 |
|
4687 | 4737 | void rocksdb_cache_disown_data(rocksdb_cache_t* cache) { |
|
0 commit comments