mirror of https://github.com/facebook/rocksdb.git
add WriteBufferManager to c api (#11710)
Summary: I want to use the `WriteBufferManager` in my rust project, which requires exposing it through the c api, just like `Cache` is. Hopefully the changes are fairly straightfoward! Pull Request resolved: https://github.com/facebook/rocksdb/pull/11710 Reviewed By: cbi42 Differential Revision: D51166518 Pulled By: ajkr fbshipit-source-id: cd266ff1e4a7ab145d05385cd125a8390f51f3fc
This commit is contained in:
parent
9202db1867
commit
6d10f8d690
59
db/c.cc
59
db/c.cc
|
@ -45,6 +45,7 @@
|
|||
#include "rocksdb/utilities/transaction_db.h"
|
||||
#include "rocksdb/utilities/write_batch_with_index.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
#include "rocksdb/write_buffer_manager.h"
|
||||
#include "utilities/merge_operators.h"
|
||||
|
||||
using ROCKSDB_NAMESPACE::BackupEngine;
|
||||
|
@ -125,6 +126,7 @@ using ROCKSDB_NAMESPACE::WALRecoveryMode;
|
|||
using ROCKSDB_NAMESPACE::WritableFile;
|
||||
using ROCKSDB_NAMESPACE::WriteBatch;
|
||||
using ROCKSDB_NAMESPACE::WriteBatchWithIndex;
|
||||
using ROCKSDB_NAMESPACE::WriteBufferManager;
|
||||
using ROCKSDB_NAMESPACE::WriteOptions;
|
||||
|
||||
using std::unordered_set;
|
||||
|
@ -219,6 +221,9 @@ struct rocksdb_memory_allocator_t {
|
|||
struct rocksdb_cache_t {
|
||||
std::shared_ptr<Cache> rep;
|
||||
};
|
||||
struct rocksdb_write_buffer_manager_t {
|
||||
std::shared_ptr<WriteBufferManager> rep;
|
||||
};
|
||||
struct rocksdb_livefiles_t {
|
||||
std::vector<LiveFileMetaData> rep;
|
||||
};
|
||||
|
@ -4896,6 +4901,60 @@ size_t rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache) {
|
|||
return cache->rep->GetOccupancyCount();
|
||||
}
|
||||
|
||||
rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create(
|
||||
size_t buffer_size, bool allow_stall) {
|
||||
rocksdb_write_buffer_manager_t* wbm = new rocksdb_write_buffer_manager_t;
|
||||
wbm->rep.reset(new WriteBufferManager(buffer_size, {}, allow_stall));
|
||||
return wbm;
|
||||
}
|
||||
|
||||
rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create_with_cache(
|
||||
size_t buffer_size, const rocksdb_cache_t* cache, bool allow_stall) {
|
||||
rocksdb_write_buffer_manager_t* wbm = new rocksdb_write_buffer_manager_t;
|
||||
wbm->rep.reset(new WriteBufferManager(buffer_size, cache->rep, allow_stall));
|
||||
return wbm;
|
||||
}
|
||||
|
||||
void rocksdb_write_buffer_manager_destroy(rocksdb_write_buffer_manager_t* wbm) {
|
||||
delete wbm;
|
||||
}
|
||||
|
||||
bool rocksdb_write_buffer_manager_enabled(rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->enabled();
|
||||
}
|
||||
|
||||
bool rocksdb_write_buffer_manager_cost_to_cache(
|
||||
rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->cost_to_cache();
|
||||
}
|
||||
|
||||
size_t rocksdb_write_buffer_manager_memory_usage(
|
||||
rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->memory_usage();
|
||||
}
|
||||
|
||||
size_t rocksdb_write_buffer_manager_mutable_memtable_memory_usage(
|
||||
rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->mutable_memtable_memory_usage();
|
||||
}
|
||||
|
||||
size_t rocksdb_write_buffer_manager_dummy_entries_in_cache_usage(
|
||||
rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->dummy_entries_in_cache_usage();
|
||||
}
|
||||
size_t rocksdb_write_buffer_manager_buffer_size(
|
||||
rocksdb_write_buffer_manager_t* wbm) {
|
||||
return wbm->rep->buffer_size();
|
||||
}
|
||||
void rocksdb_write_buffer_manager_set_buffer_size(
|
||||
rocksdb_write_buffer_manager_t* wbm, size_t new_size) {
|
||||
wbm->rep->SetBufferSize(new_size);
|
||||
}
|
||||
ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_set_allow_stall(
|
||||
rocksdb_write_buffer_manager_t* wbm, bool new_allow_stall) {
|
||||
wbm->rep->SetAllowStall(new_allow_stall);
|
||||
}
|
||||
|
||||
rocksdb_dbpath_t* rocksdb_dbpath_create(const char* path,
|
||||
uint64_t target_size) {
|
||||
rocksdb_dbpath_t* result = new rocksdb_dbpath_t;
|
||||
|
|
|
@ -78,6 +78,7 @@ typedef struct rocksdb_lru_cache_options_t rocksdb_lru_cache_options_t;
|
|||
typedef struct rocksdb_hyper_clock_cache_options_t
|
||||
rocksdb_hyper_clock_cache_options_t;
|
||||
typedef struct rocksdb_cache_t rocksdb_cache_t;
|
||||
typedef struct rocksdb_write_buffer_manager_t rocksdb_write_buffer_manager_t;
|
||||
typedef struct rocksdb_compactionfilter_t rocksdb_compactionfilter_t;
|
||||
typedef struct rocksdb_compactionfiltercontext_t
|
||||
rocksdb_compactionfiltercontext_t;
|
||||
|
@ -2077,6 +2078,36 @@ rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache);
|
|||
extern ROCKSDB_LIBRARY_API size_t
|
||||
rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache);
|
||||
|
||||
/* WriteBufferManager */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API rocksdb_write_buffer_manager_t*
|
||||
rocksdb_write_buffer_manager_create(size_t buffer_size, bool allow_stall);
|
||||
extern ROCKSDB_LIBRARY_API rocksdb_write_buffer_manager_t*
|
||||
rocksdb_write_buffer_manager_create_with_cache(size_t buffer_size,
|
||||
const rocksdb_cache_t* cache,
|
||||
bool allow_stall);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_destroy(
|
||||
rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API bool rocksdb_write_buffer_manager_enabled(
|
||||
rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API bool rocksdb_write_buffer_manager_cost_to_cache(
|
||||
rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API size_t
|
||||
rocksdb_write_buffer_manager_memory_usage(rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API size_t
|
||||
rocksdb_write_buffer_manager_mutable_memtable_memory_usage(
|
||||
rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API size_t
|
||||
rocksdb_write_buffer_manager_dummy_entries_in_cache_usage(
|
||||
rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API size_t
|
||||
rocksdb_write_buffer_manager_buffer_size(rocksdb_write_buffer_manager_t* wbm);
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_set_buffer_size(
|
||||
rocksdb_write_buffer_manager_t* wbm, size_t new_size);
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_set_allow_stall(
|
||||
rocksdb_write_buffer_manager_t* wbm, bool new_allow_stall);
|
||||
|
||||
/* HyperClockCache */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API rocksdb_hyper_clock_cache_options_t*
|
||||
|
|
Loading…
Reference in New Issue