mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
1fdd726 Hotfix RocksDB 3.5 d67500a Add `make install` to Makefile in 3.5.fb. 4cb631a update HISTORY.md cfd0946 comments about the BlockBasedTableOptions migration in Options REVERT: 25888ae Merge pull request #329 from fyrz/master REVERT: 89833e5 Fixed signed-unsigned comparison warning in db_test.cc REVERT: fcac705 Fixed compile warning on Mac caused by unused variables. REVERT: b3343fd resolution for java build problem introduced by 5ec53f3edf62bec1b690ce12fb21a6c52203f3c8 REVERT: 187b299 ForwardIterator: update prev_key_ only if prefix hasn't changed REVERT: 5ec53f3 make compaction related options changeable REVERT: d122e7b Update INSTALL.md REVERT: 986dad0 Merge pull request #324 from dalgaaf/wip-da-SCA-20140930 REVERT: 8ee75dc db/memtable.cc: remove unused variable merge_result REVERT: 0fd8bbc db/db_impl.cc: reduce scope of prefix_initialized REVERT: 676ff7b compaction_picker.cc: remove check for >=0 for unsigned REVERT: e55aea5 document_db.cc: fix assert REVERT: d517c83 in_table_factory.cc: use correct format specifier REVERT: b140375 ttl/ttl_test.cc: prefer prefix ++operator for non-primitive types REVERT: 43c789c spatialdb/spatial_db.cc: use !empty() instead of 'size() > 0' REVERT: 0de452e document_db.cc: pass const parameter by reference REVERT: 4cc8643 util/ldb_cmd.cc: prefer prefix ++operator for non-primitive types REVERT: af8c2b2 util/signal_test.cc: suppress intentional null pointer deref REVERT: 33580fa db/db_impl.cc: fix object handling, remove double lines REVERT: 873f135 db_ttl_impl.h: pass func parameter by reference REVERT: 8558457 ldb_cmd_execute_result.h: perform init in initialization list REVERT: 063471b table/table_test.cc: pass func parameter by reference REVERT: 93548ce table/cuckoo_table_reader.cc: pass func parameter by ref REVERT: b8b7117 db/version_set.cc: use !empty() instead of 'size() > 0' REVERT: 8ce050b table/bloom_block.*: pass func parameter by reference REVERT: 53910dd db_test.cc: pass parameter by reference REVERT: 68ca534 corruption_test.cc: pass parameter by reference REVERT: 7506198 cuckoo_table_db_test.cc: add flush after delete REVERT: 1f96330 Print MB per second compaction throughput separately for reads and writes REVERT: ffe3d49 Add an instruction about SSE in INSTALL.md REVERT: ee1f3cc Package generation for Ubuntu and CentOS REVERT: f0f7955 Fixing comile errors on OS X REVERT: 99fb613 remove 2 space linter REVERT: b2d64a4 Fix linters, second try REVERT: 747523d Print per column family metrics in db_bench REVERT: 56ebd40 Fix arc lint (should fix #238) REVERT: 637f891 Merge pull request #321 from eonnen/master REVERT: 827e31c Make test use a compatible type in the size checks. REVERT: fd5d80d CompactedDB: log using the correct info_log REVERT: 2faf49d use GetContext to replace callback function pointer REVERT: 983d2de Add AUTHORS file. Fix #203 REVERT: abd70c5 Merge pull request #316 from fyrz/ReverseBytewiseComparator REVERT: 2dc6f62 handle kDelete type in cuckoo builder REVERT: 8b8011a Changed name of ReverseBytewiseComparator based on review comment REVERT: 389edb6 universal compaction picker: use double for potential overflow REVERT: 5340484 Built-in comparator(s) in RocksJava REVERT: d439451 delay initialization of cuckoo table iterator REVERT: 94997ea reduce memory usage of cuckoo table builder REVERT: c627595 improve memory efficiency of cuckoo reader REVERT: 581442d option to choose module when calculating CuckooTable hash REVERT: fbd2daf CompactedDBImpl::MultiGet() for better CuckooTable performance REVERT: 3c68006 CompactedDBImpl REVERT: f7375f3 Fix double deletes REVERT: 21ddcf6 Remove allow_thread_local REVERT: fb4a492 Merge pull request #311 from ankgup87/master REVERT: 611e286 Merge branch 'master' of https://github.com/facebook/rocksdb REVERT: 0103b44 Merge branch 'master' of ssh://github.com/ankgup87/rocksdb REVERT: 1dfb7bb Add block based table config options REVERT: cdaf44f Enlarge log size cap when printing file summary REVERT: 7cc1ed7 Merge pull request #309 from naveenatceg/staticbuild REVERT: ba6d660 Resolving merge conflict REVERT: 51eeaf6 Addressing review comments REVERT: fd7d3fe Addressing review comments (adding a env variable to override temp directory) REVERT: cf7ace8 Addressing review comments REVERT: 0a29ce5 re-enable BlockBasedTable::SetupForCompaction() REVERT: 55af370 Remove TODO for checking index checksums REVERT: 3d74f09 Fix compile REVERT: 53b0039 Fix release compile REVERT: d0de413 WriteBatchWithIndex to allow different Comparators for different column families REVERT: 57a32f1 change target_file_size_base to uint64_t REVERT: 5e6aee4 dont create backup_input if compaction filter v2 is not used REVERT: 49b5f94 Merge pull request #306 from Liuchang0812/fix_cast REVERT: 787cb4d remove cast, replace %llu with % PRIu64 REVERT: a7574d4 Update logging.cc REVERT: 7e0dcb9 Update logging.cc REVERT: 57fa3cc Merge pull request #304 from Liuchang0812/fix-check REVERT: cd44522 Merge pull request #305 from Liuchang0812/fix-logging REVERT: 6a031b6 remove unused variable REVERT: 4436f17 fixed #303: replace %ld with % PRId64 REVERT: 7a1bd05 Merge pull request #302 from ankgup87/master REVERT: 423e52c Merge branch 'master' of https://github.com/facebook/rocksdb REVERT: bfeef94 Add rate limiter REVERT: 32f2532 Print compression_size_percent as a signed int REVERT: 976caca Skip AllocateTest if fallocate() is not supported in the file system REVERT: 3b897cd Enable no-fbcode RocksDB build REVERT: f445947 RocksDB: Format uint64 using PRIu64 in db_impl.cc REVERT: e17bc65 Merge pull request #299 from ankgup87/master REVERT: b93797a Fix build REVERT: adae3ca [Java] Fix JNI link error caused by the removal of options.db_stats_log_interval REVERT: 90b8c07 Fix unit tests errors REVERT: 51af7c3 CuckooTable: add one option to allow identity function for the first hash function REVERT: 0350435 Fixed a signed-unsigned comparison in spatial_db.cc -- issue #293 REVERT: 2fb1fea Fix syncronization issues REVERT: ff76895 Remove some unnecessary constructors REVERT: feadb9d fix cuckoo table builder test REVERT: 3c232e1 Fix mac compile REVERT: 54cada9 Run make format on PR #249 REVERT: 27b22f1 Merge pull request #249 from tdfischer/decompression-refactoring REVERT: fb6456b Replace naked calls to operator new and delete (Fixes #222) REVERT: 5600c8f cuckoo table: return estimated size - 1 REVERT: a062e1f SetOptions() for memtable related options REVERT: e4eca6a Options conversion function for convenience REVERT: a7c2094 Merge pull request #292 from saghmrossi/master REVERT: 4d05234 Merge branch 'master' of github.com:saghmrossi/rocksdb REVERT: 60a4aa1 Test use_mmap_reads REVERT: 94e43a1 [Java] Fixed 32-bit overflowing issue when converting jlong to size_t REVERT: f9eaaa6 added include for inttypes.h to fix nonworking printf statements REVERT: f090575 Replaced "built on on earlier work" by "built on earlier work" in README.md REVERT: faad439 Fix #284 REVERT: 49aacd8 Fix make install REVERT: acb9348 [Java] Include WriteBatch into RocksDBSample.java, fix how DbBenchmark.java handles WriteBatch. REVERT: 4a27a2f Don't sync manifest when disableDataSync = true REVERT: 9b8480d Merge pull request #287 from yinqiwen/rate-limiter-crash-fix REVERT: 28be16b fix rate limiter crash #286 REVERT: 04ce1b2 Fix #284 REVERT: add22e3 standardize scripts to run RocksDB benchmarks REVERT: dee91c2 WriteThread REVERT: 540a257 Fix WAL synced REVERT: 24f034b Merge pull request #282 from Chilledheart/develop REVERT: 49fe329 Fix build issue under macosx REVERT: ebb5c65 Add make install REVERT: 0352a9f add_wrapped_bloom_test REVERT: 9c0e66c Don't run background jobs (flush, compactions) when bg_error_ is set REVERT: a9639bd Fix valgrind test REVERT: d1f24dc Relax FlushSchedule test REVERT: 3d9e6f7 Push model for flushing memtables REVERT: 059e584 [unit test] CompactRange should fail if we don't have space REVERT: dd641b2 fix RocksDB java build REVERT: 53404d9 add_qps_info_in cache bench REVERT: a52cecb Fix Mac compile REVERT: 092f97e Fix comments and typos REVERT: 6cc1286 Added a few statistics for BackupableDB REVERT: 0a42295 Fix SimpleWriteTimeoutTest REVERT: 06d9862 Always pass MergeContext as pointer, not reference REVERT: d343c3f Improve db recovery REVERT: 6bb7e3e Merger test REVERT: 88841bd Explicitly cast char to signed char in Hash() REVERT: 5231146 MemTableOptions REVERT: 1d284db Addressing review comments REVERT: 55114e7 Some updates for SpatialDB REVERT: 171d4ff remove TailingIterator reference in db_impl.h REVERT: 9b0f7ff rename version_set options_ to db_options_ to avoid confusion REVERT: 2d57828 Check stop level trigger-0 before slowdown level-0 trigger REVERT: 659d2d5 move compaction_filter to immutable_options REVERT: 048560a reduce references to cfd->options() in DBImpl REVERT: 011241b DB::Flush() Do not wait for background threads when there is nothing in mem table REVERT: a2bb7c3 Push- instead of pull-model for managing Write stalls REVERT: 0af157f Implement full filter for block based table. REVERT: 9360cc6 Fix valgrind issue REVERT: 02d5bff Merge pull request #277 from wankai/master REVERT: 88a2f44 fix comments REVERT: 7c16e39 Merge pull request #276 from wankai/master REVERT: 8237738 replace hard-coded number with named variable REVERT: db8ca52 Merge pull request #273 from nbougalis/static-analysis REVERT: b7b031f Merge pull request #274 from wankai/master REVERT: 4c2b1f0 Merge remote-tracking branch 'upstream/master' REVERT: a5d2863 typo improvement REVERT: 9f8aa09 Don't leak data returned by opendir REVERT: d1cfb71 Remove unused member(s) REVERT: bfee319 sizeof(int*) where sizeof(int) was intended REVERT: d40c1f7 Add missing break statement REVERT: 2e97c38 Avoid off-by-one error when using readlink REVERT: 40ddc3d add cache bench REVERT: 9f1c80b Drop column family from write thread REVERT: 8de151b Add db_bench with lots of column families to regression tests REVERT: c9e419c rename options_ to db_options_ in DBImpl to avoid confusion REVERT: 5cd0576 Fix compaction bug in Cuckoo Table Builder. Use kvs_.size() instead of num_entries in FileSize() method. REVERT: 0fbb3fa fixed memory leak in unit test DBIteratorBoundTest REVERT: adcd253 fix asan check REVERT: 4092b7a Merge pull request #272 from project-zerus/patch-1 REVERT: bb6ae0f fix more compile warnings REVERT: 6d31441 Merge pull request #271 from nbougalis/cleanups REVERT: 0cd0ec4 Plug memory leak during index creation REVERT: 4329d74 Fix swapped variable names to accurately reflect usage REVERT: 45a5e3e Remove path with arena==nullptr from NewInternalIterator REVERT: 5665e5e introduce ImmutableOptions REVERT: e0b99d4 created a new ReadOptions parameter 'iterate_upper_bound' REVERT: 51ea889 Fix travis builds REVERT: a481626 Relax backupable rate limiting test REVERT: f7f973d Merge pull request #269 from huahang/patch-2 REVERT: ef5b384 fix a few compile warnings REVERT: 2fd3806 Merge pull request #263 from wankai/master REVERT: 1785114 delete unused Comparator REVERT: 1b1d961 update HISTORY.md REVERT: 703c3ea comments about the BlockBasedTableOptions migration in Options REVERT: 4b5ad88 Merge pull request #260 from wankai/master REVERT: 19cc588 change to filter_block std::unique_ptr support RAII REVERT: 9b976e3 Merge pull request #259 from wankai/master REVERT: 5d25a46 Merge remote-tracking branch 'upstream/master' REVERT: dff2b1a typo improvement REVERT: 343e98a Reverting import change REVERT: ddb8039 RocksDB static build Make file changes to download and build the dependencies .Load the shared library when RocksDB is initialized git-subtree-dir: src/rocksdb2 git-subtree-split: 1fdd726a8254c13d0c66d8db8130ad17c13d7bcc
2087 lines
62 KiB
C++
2087 lines
62 KiB
C++
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under the BSD-style license found in the
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
//
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
#include "rocksdb/c.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include "rocksdb/cache.h"
|
|
#include "rocksdb/compaction_filter.h"
|
|
#include "rocksdb/comparator.h"
|
|
#include "rocksdb/db.h"
|
|
#include "rocksdb/env.h"
|
|
#include "rocksdb/filter_policy.h"
|
|
#include "rocksdb/iterator.h"
|
|
#include "rocksdb/merge_operator.h"
|
|
#include "rocksdb/options.h"
|
|
#include "rocksdb/status.h"
|
|
#include "rocksdb/write_batch.h"
|
|
#include "rocksdb/memtablerep.h"
|
|
#include "rocksdb/universal_compaction.h"
|
|
#include "rocksdb/statistics.h"
|
|
#include "rocksdb/slice_transform.h"
|
|
#include "rocksdb/table.h"
|
|
|
|
using rocksdb::Cache;
|
|
using rocksdb::ColumnFamilyDescriptor;
|
|
using rocksdb::ColumnFamilyHandle;
|
|
using rocksdb::ColumnFamilyOptions;
|
|
using rocksdb::CompactionFilter;
|
|
using rocksdb::CompactionFilterFactory;
|
|
using rocksdb::CompactionFilterV2;
|
|
using rocksdb::CompactionFilterFactoryV2;
|
|
using rocksdb::CompactionFilterContext;
|
|
using rocksdb::CompactionOptionsFIFO;
|
|
using rocksdb::Comparator;
|
|
using rocksdb::CompressionType;
|
|
using rocksdb::DB;
|
|
using rocksdb::DBOptions;
|
|
using rocksdb::Env;
|
|
using rocksdb::InfoLogLevel;
|
|
using rocksdb::FileLock;
|
|
using rocksdb::FilterPolicy;
|
|
using rocksdb::FlushOptions;
|
|
using rocksdb::Iterator;
|
|
using rocksdb::Logger;
|
|
using rocksdb::MergeOperator;
|
|
using rocksdb::NewBloomFilterPolicy;
|
|
using rocksdb::NewLRUCache;
|
|
using rocksdb::Options;
|
|
using rocksdb::BlockBasedTableOptions;
|
|
using rocksdb::RandomAccessFile;
|
|
using rocksdb::Range;
|
|
using rocksdb::ReadOptions;
|
|
using rocksdb::SequentialFile;
|
|
using rocksdb::Slice;
|
|
using rocksdb::SliceTransform;
|
|
using rocksdb::Snapshot;
|
|
using rocksdb::Status;
|
|
using rocksdb::WritableFile;
|
|
using rocksdb::WriteBatch;
|
|
using rocksdb::WriteOptions;
|
|
using rocksdb::LiveFileMetaData;
|
|
|
|
using std::shared_ptr;
|
|
|
|
extern "C" {
|
|
|
|
struct rocksdb_t { DB* rep; };
|
|
struct rocksdb_iterator_t { Iterator* rep; };
|
|
struct rocksdb_writebatch_t { WriteBatch rep; };
|
|
struct rocksdb_snapshot_t { const Snapshot* rep; };
|
|
struct rocksdb_flushoptions_t { FlushOptions rep; };
|
|
struct rocksdb_fifo_compaction_options_t { CompactionOptionsFIFO rep; };
|
|
struct rocksdb_readoptions_t { ReadOptions rep; };
|
|
struct rocksdb_writeoptions_t { WriteOptions rep; };
|
|
struct rocksdb_options_t { Options rep; };
|
|
struct rocksdb_block_based_table_options_t { BlockBasedTableOptions rep; };
|
|
struct rocksdb_seqfile_t { SequentialFile* rep; };
|
|
struct rocksdb_randomfile_t { RandomAccessFile* rep; };
|
|
struct rocksdb_writablefile_t { WritableFile* rep; };
|
|
struct rocksdb_filelock_t { FileLock* rep; };
|
|
struct rocksdb_logger_t { shared_ptr<Logger> rep; };
|
|
struct rocksdb_cache_t { shared_ptr<Cache> rep; };
|
|
struct rocksdb_livefiles_t { std::vector<LiveFileMetaData> rep; };
|
|
struct rocksdb_column_family_handle_t { ColumnFamilyHandle* rep; };
|
|
|
|
struct rocksdb_compactionfiltercontext_t {
|
|
CompactionFilter::Context rep;
|
|
};
|
|
|
|
struct rocksdb_compactionfilter_t : public CompactionFilter {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
unsigned char (*filter_)(
|
|
void*,
|
|
int level,
|
|
const char* key, size_t key_length,
|
|
const char* existing_value, size_t value_length,
|
|
char** new_value, size_t *new_value_length,
|
|
unsigned char* value_changed);
|
|
const char* (*name_)(void*);
|
|
|
|
virtual ~rocksdb_compactionfilter_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual bool Filter(
|
|
int level,
|
|
const Slice& key,
|
|
const Slice& existing_value,
|
|
std::string* new_value,
|
|
bool* value_changed) const {
|
|
char* c_new_value = NULL;
|
|
size_t new_value_length = 0;
|
|
unsigned char c_value_changed = 0;
|
|
unsigned char result = (*filter_)(
|
|
state_,
|
|
level,
|
|
key.data(), key.size(),
|
|
existing_value.data(), existing_value.size(),
|
|
&c_new_value, &new_value_length, &c_value_changed);
|
|
if (c_value_changed) {
|
|
new_value->assign(c_new_value, new_value_length);
|
|
*value_changed = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
};
|
|
|
|
struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
rocksdb_compactionfilter_t* (*create_compaction_filter_)(
|
|
void*, rocksdb_compactionfiltercontext_t* context);
|
|
const char* (*name_)(void*);
|
|
|
|
virtual ~rocksdb_compactionfilterfactory_t() { (*destructor_)(state_); }
|
|
|
|
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
|
|
const CompactionFilter::Context& context) {
|
|
rocksdb_compactionfiltercontext_t ccontext;
|
|
ccontext.rep = context;
|
|
CompactionFilter* cf = (*create_compaction_filter_)(state_, &ccontext);
|
|
return std::unique_ptr<CompactionFilter>(cf);
|
|
}
|
|
|
|
virtual const char* Name() const { return (*name_)(state_); }
|
|
};
|
|
|
|
struct rocksdb_compactionfilterv2_t : public CompactionFilterV2 {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
const char* (*name_)(void*);
|
|
void (*filter_)(void*, int level, size_t num_keys,
|
|
const char* const* keys_list, const size_t* keys_list_sizes,
|
|
const char* const* existing_values_list, const size_t* existing_values_list_sizes,
|
|
char** new_values_list, size_t* new_values_list_sizes,
|
|
unsigned char* to_delete_list);
|
|
|
|
virtual ~rocksdb_compactionfilterv2_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
virtual std::vector<bool> Filter(int level,
|
|
const SliceVector& keys,
|
|
const SliceVector& existing_values,
|
|
std::vector<std::string>* new_values,
|
|
std::vector<bool>* values_changed) const {
|
|
// Make a vector pointing to the underlying key data.
|
|
size_t num_keys = keys.size();
|
|
std::vector<const char*> keys_list(num_keys);
|
|
std::vector<size_t> keys_list_sizes(num_keys);
|
|
for (size_t i = 0; i < num_keys; ++i) {
|
|
keys_list[i] = keys[i].data();
|
|
keys_list_sizes[i] = keys[i].size();
|
|
}
|
|
// Make a vector pointing to the underlying value data.
|
|
std::vector<const char*> existing_values_list(num_keys);
|
|
std::vector<size_t> existing_values_list_sizes(num_keys);
|
|
for (size_t i = 0; i < num_keys; ++i) {
|
|
existing_values_list[i] = existing_values[i].data();
|
|
existing_values_list_sizes[i] = existing_values[i].size();
|
|
}
|
|
// Make a vector which will accept newly-allocated char* arrays
|
|
// which we will take ownership of and assign to strings in new_values.
|
|
new_values->clear();
|
|
std::vector<char*> new_values_list(num_keys);
|
|
std::vector<size_t> new_values_list_sizes(num_keys);
|
|
// Resize values_changed to hold all keys.
|
|
values_changed->resize(num_keys);
|
|
// Make a vector for bools indicating a value should be deleted
|
|
// on compaction (true) or maintained (false).
|
|
std::vector<unsigned char> to_delete_list(num_keys);
|
|
|
|
(*filter_)(
|
|
state_, level, num_keys, &keys_list[0], &keys_list_sizes[0],
|
|
&existing_values_list[0], &existing_values_list_sizes[0],
|
|
&new_values_list[0], &new_values_list_sizes[0], &to_delete_list[0]);
|
|
|
|
// Now, we transfer any changed values, setting values_changed and
|
|
// initializing new_values in the event a value changed.
|
|
std::vector<bool> to_delete(num_keys);
|
|
for (size_t i = 0; i < num_keys; ++i) {
|
|
to_delete[i] = to_delete_list[i];
|
|
(*values_changed)[i] = new_values_list[i] != nullptr;
|
|
if ((*values_changed)[i]) {
|
|
new_values->push_back(std::string(new_values_list[i], new_values_list_sizes[i]));
|
|
free(new_values_list[i]);
|
|
}
|
|
}
|
|
return to_delete;
|
|
}
|
|
};
|
|
|
|
struct rocksdb_compactionfilterfactoryv2_t : public CompactionFilterFactoryV2 {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
const char* (*name_)(void*);
|
|
rocksdb_compactionfilterv2_t* (*create_compaction_filter_v2_)(
|
|
void* state, const rocksdb_compactionfiltercontext_t* context);
|
|
|
|
rocksdb_compactionfilterfactoryv2_t(const SliceTransform* prefix_extractor)
|
|
: CompactionFilterFactoryV2(prefix_extractor) {
|
|
}
|
|
|
|
virtual ~rocksdb_compactionfilterfactoryv2_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
virtual std::unique_ptr<CompactionFilterV2> CreateCompactionFilterV2(
|
|
const CompactionFilterContext& context) {
|
|
struct rocksdb_compactionfiltercontext_t c_context;
|
|
c_context.rep.is_full_compaction = context.is_full_compaction;
|
|
c_context.rep.is_manual_compaction = context.is_manual_compaction;
|
|
return std::unique_ptr<CompactionFilterV2>(
|
|
(*create_compaction_filter_v2_)(state_, &c_context));
|
|
}
|
|
};
|
|
|
|
struct rocksdb_comparator_t : public Comparator {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
int (*compare_)(
|
|
void*,
|
|
const char* a, size_t alen,
|
|
const char* b, size_t blen);
|
|
const char* (*name_)(void*);
|
|
|
|
virtual ~rocksdb_comparator_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual int Compare(const Slice& a, const Slice& b) const {
|
|
return (*compare_)(state_, a.data(), a.size(), b.data(), b.size());
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
// No-ops since the C binding does not support key shortening methods.
|
|
virtual void FindShortestSeparator(std::string*, const Slice&) const { }
|
|
virtual void FindShortSuccessor(std::string* key) const { }
|
|
};
|
|
|
|
struct rocksdb_filterpolicy_t : public FilterPolicy {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
const char* (*name_)(void*);
|
|
char* (*create_)(
|
|
void*,
|
|
const char* const* key_array, const size_t* key_length_array,
|
|
int num_keys,
|
|
size_t* filter_length);
|
|
unsigned char (*key_match_)(
|
|
void*,
|
|
const char* key, size_t length,
|
|
const char* filter, size_t filter_length);
|
|
void (*delete_filter_)(
|
|
void*,
|
|
const char* filter, size_t filter_length);
|
|
|
|
virtual ~rocksdb_filterpolicy_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
|
std::vector<const char*> key_pointers(n);
|
|
std::vector<size_t> key_sizes(n);
|
|
for (int i = 0; i < n; i++) {
|
|
key_pointers[i] = keys[i].data();
|
|
key_sizes[i] = keys[i].size();
|
|
}
|
|
size_t len;
|
|
char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len);
|
|
dst->append(filter, len);
|
|
|
|
if (delete_filter_ != nullptr) {
|
|
(*delete_filter_)(state_, filter, len);
|
|
} else {
|
|
free(filter);
|
|
}
|
|
}
|
|
|
|
virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const {
|
|
return (*key_match_)(state_, key.data(), key.size(),
|
|
filter.data(), filter.size());
|
|
}
|
|
};
|
|
|
|
struct rocksdb_mergeoperator_t : public MergeOperator {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
const char* (*name_)(void*);
|
|
char* (*full_merge_)(
|
|
void*,
|
|
const char* key, size_t key_length,
|
|
const char* existing_value, size_t existing_value_length,
|
|
const char* const* operands_list, const size_t* operands_list_length,
|
|
int num_operands,
|
|
unsigned char* success, size_t* new_value_length);
|
|
char* (*partial_merge_)(void*, const char* key, size_t key_length,
|
|
const char* const* operands_list,
|
|
const size_t* operands_list_length, int num_operands,
|
|
unsigned char* success, size_t* new_value_length);
|
|
void (*delete_value_)(
|
|
void*,
|
|
const char* value, size_t value_length);
|
|
|
|
virtual ~rocksdb_mergeoperator_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
virtual bool FullMerge(
|
|
const Slice& key,
|
|
const Slice* existing_value,
|
|
const std::deque<std::string>& operand_list,
|
|
std::string* new_value,
|
|
Logger* logger) const {
|
|
|
|
size_t n = operand_list.size();
|
|
std::vector<const char*> operand_pointers(n);
|
|
std::vector<size_t> operand_sizes(n);
|
|
for (size_t i = 0; i < n; i++) {
|
|
Slice operand(operand_list[i]);
|
|
operand_pointers[i] = operand.data();
|
|
operand_sizes[i] = operand.size();
|
|
}
|
|
|
|
const char* existing_value_data = nullptr;
|
|
size_t existing_value_len = 0;
|
|
if (existing_value != nullptr) {
|
|
existing_value_data = existing_value->data();
|
|
existing_value_len = existing_value->size();
|
|
}
|
|
|
|
unsigned char success;
|
|
size_t new_value_len;
|
|
char* tmp_new_value = (*full_merge_)(
|
|
state_,
|
|
key.data(), key.size(),
|
|
existing_value_data, existing_value_len,
|
|
&operand_pointers[0], &operand_sizes[0], n,
|
|
&success, &new_value_len);
|
|
new_value->assign(tmp_new_value, new_value_len);
|
|
|
|
if (delete_value_ != nullptr) {
|
|
(*delete_value_)(state_, tmp_new_value, new_value_len);
|
|
} else {
|
|
free(tmp_new_value);
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
virtual bool PartialMergeMulti(const Slice& key,
|
|
const std::deque<Slice>& operand_list,
|
|
std::string* new_value, Logger* logger) const {
|
|
size_t operand_count = operand_list.size();
|
|
std::vector<const char*> operand_pointers(operand_count);
|
|
std::vector<size_t> operand_sizes(operand_count);
|
|
for (size_t i = 0; i < operand_count; ++i) {
|
|
Slice operand(operand_list[i]);
|
|
operand_pointers[i] = operand.data();
|
|
operand_sizes[i] = operand.size();
|
|
}
|
|
|
|
unsigned char success;
|
|
size_t new_value_len;
|
|
char* tmp_new_value = (*partial_merge_)(
|
|
state_, key.data(), key.size(), &operand_pointers[0], &operand_sizes[0],
|
|
operand_count, &success, &new_value_len);
|
|
new_value->assign(tmp_new_value, new_value_len);
|
|
|
|
if (delete_value_ != nullptr) {
|
|
(*delete_value_)(state_, tmp_new_value, new_value_len);
|
|
} else {
|
|
free(tmp_new_value);
|
|
}
|
|
|
|
return success;
|
|
}
|
|
};
|
|
|
|
struct rocksdb_env_t {
|
|
Env* rep;
|
|
bool is_default;
|
|
};
|
|
|
|
struct rocksdb_slicetransform_t : public SliceTransform {
|
|
void* state_;
|
|
void (*destructor_)(void*);
|
|
const char* (*name_)(void*);
|
|
char* (*transform_)(
|
|
void*,
|
|
const char* key, size_t length,
|
|
size_t* dst_length);
|
|
unsigned char (*in_domain_)(
|
|
void*,
|
|
const char* key, size_t length);
|
|
unsigned char (*in_range_)(
|
|
void*,
|
|
const char* key, size_t length);
|
|
|
|
virtual ~rocksdb_slicetransform_t() {
|
|
(*destructor_)(state_);
|
|
}
|
|
|
|
virtual const char* Name() const {
|
|
return (*name_)(state_);
|
|
}
|
|
|
|
virtual Slice Transform(const Slice& src) const {
|
|
size_t len;
|
|
char* dst = (*transform_)(state_, src.data(), src.size(), &len);
|
|
return Slice(dst, len);
|
|
}
|
|
|
|
virtual bool InDomain(const Slice& src) const {
|
|
return (*in_domain_)(state_, src.data(), src.size());
|
|
}
|
|
|
|
virtual bool InRange(const Slice& src) const {
|
|
return (*in_range_)(state_, src.data(), src.size());
|
|
}
|
|
};
|
|
|
|
struct rocksdb_universal_compaction_options_t {
|
|
rocksdb::CompactionOptionsUniversal *rep;
|
|
};
|
|
|
|
static bool SaveError(char** errptr, const Status& s) {
|
|
assert(errptr != nullptr);
|
|
if (s.ok()) {
|
|
return false;
|
|
} else if (*errptr == nullptr) {
|
|
*errptr = strdup(s.ToString().c_str());
|
|
} else {
|
|
// TODO(sanjay): Merge with existing error?
|
|
free(*errptr);
|
|
*errptr = strdup(s.ToString().c_str());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static char* CopyString(const std::string& str) {
|
|
char* result = reinterpret_cast<char*>(malloc(sizeof(char) * str.size()));
|
|
memcpy(result, str.data(), sizeof(char) * str.size());
|
|
return result;
|
|
}
|
|
|
|
rocksdb_t* rocksdb_open(
|
|
const rocksdb_options_t* options,
|
|
const char* name,
|
|
char** errptr) {
|
|
DB* db;
|
|
if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) {
|
|
return nullptr;
|
|
}
|
|
rocksdb_t* result = new rocksdb_t;
|
|
result->rep = db;
|
|
return result;
|
|
}
|
|
|
|
rocksdb_t* rocksdb_open_for_read_only(
|
|
const rocksdb_options_t* options,
|
|
const char* name,
|
|
unsigned char error_if_log_file_exist,
|
|
char** errptr) {
|
|
DB* db;
|
|
if (SaveError(errptr, DB::OpenForReadOnly(options->rep, std::string(name), &db, error_if_log_file_exist))) {
|
|
return nullptr;
|
|
}
|
|
rocksdb_t* result = new rocksdb_t;
|
|
result->rep = db;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_close(rocksdb_t* db) {
|
|
delete db->rep;
|
|
delete db;
|
|
}
|
|
|
|
rocksdb_t* rocksdb_open_column_families(
|
|
const rocksdb_options_t* db_options,
|
|
const char* name,
|
|
int num_column_families,
|
|
const char** column_family_names,
|
|
const rocksdb_options_t** column_family_options,
|
|
rocksdb_column_family_handle_t** column_family_handles,
|
|
char** errptr) {
|
|
std::vector<ColumnFamilyDescriptor> column_families;
|
|
for (int i = 0; i < num_column_families; i++) {
|
|
column_families.push_back(ColumnFamilyDescriptor(
|
|
std::string(column_family_names[i]),
|
|
ColumnFamilyOptions(column_family_options[i]->rep)));
|
|
}
|
|
|
|
DB* db;
|
|
std::vector<ColumnFamilyHandle*> handles;
|
|
if (SaveError(errptr, DB::Open(DBOptions(db_options->rep),
|
|
std::string(name), column_families, &handles, &db))) {
|
|
return nullptr;
|
|
}
|
|
|
|
for (size_t i = 0; i < handles.size(); i++) {
|
|
rocksdb_column_family_handle_t* c_handle = new rocksdb_column_family_handle_t;
|
|
c_handle->rep = handles[i];
|
|
column_family_handles[i] = c_handle;
|
|
}
|
|
rocksdb_t* result = new rocksdb_t;
|
|
result->rep = db;
|
|
return result;
|
|
}
|
|
|
|
rocksdb_t* rocksdb_open_for_read_only_column_families(
|
|
const rocksdb_options_t* db_options,
|
|
const char* name,
|
|
int num_column_families,
|
|
const char** column_family_names,
|
|
const rocksdb_options_t** column_family_options,
|
|
rocksdb_column_family_handle_t** column_family_handles,
|
|
unsigned char error_if_log_file_exist,
|
|
char** errptr) {
|
|
std::vector<ColumnFamilyDescriptor> column_families;
|
|
for (int i = 0; i < num_column_families; i++) {
|
|
column_families.push_back(ColumnFamilyDescriptor(
|
|
std::string(column_family_names[i]),
|
|
ColumnFamilyOptions(column_family_options[i]->rep)));
|
|
}
|
|
|
|
DB* db;
|
|
std::vector<ColumnFamilyHandle*> handles;
|
|
if (SaveError(errptr, DB::OpenForReadOnly(DBOptions(db_options->rep),
|
|
std::string(name), column_families, &handles, &db, error_if_log_file_exist))) {
|
|
return nullptr;
|
|
}
|
|
|
|
for (size_t i = 0; i < handles.size(); i++) {
|
|
rocksdb_column_family_handle_t* c_handle = new rocksdb_column_family_handle_t;
|
|
c_handle->rep = handles[i];
|
|
column_family_handles[i] = c_handle;
|
|
}
|
|
rocksdb_t* result = new rocksdb_t;
|
|
result->rep = db;
|
|
return result;
|
|
}
|
|
|
|
char** rocksdb_list_column_families(
|
|
const rocksdb_options_t* options,
|
|
const char* name,
|
|
size_t* lencfs,
|
|
char** errptr) {
|
|
std::vector<std::string> fams;
|
|
SaveError(errptr,
|
|
DB::ListColumnFamilies(DBOptions(options->rep),
|
|
std::string(name), &fams));
|
|
|
|
*lencfs = fams.size();
|
|
char** column_families = static_cast<char**>(malloc(sizeof(char*) * fams.size()));
|
|
for (size_t i = 0; i < fams.size(); i++) {
|
|
column_families[i] = strdup(fams[i].c_str());
|
|
}
|
|
return column_families;
|
|
}
|
|
|
|
void rocksdb_list_column_families_destroy(char** list, size_t len) {
|
|
for (size_t i = 0; i < len; ++i) {
|
|
free(list[i]);
|
|
}
|
|
free(list);
|
|
}
|
|
|
|
rocksdb_column_family_handle_t* rocksdb_create_column_family(
|
|
rocksdb_t* db,
|
|
const rocksdb_options_t* column_family_options,
|
|
const char* column_family_name,
|
|
char** errptr) {
|
|
rocksdb_column_family_handle_t* handle = new rocksdb_column_family_handle_t;
|
|
SaveError(errptr,
|
|
db->rep->CreateColumnFamily(ColumnFamilyOptions(column_family_options->rep),
|
|
std::string(column_family_name), &(handle->rep)));
|
|
return handle;
|
|
}
|
|
|
|
void rocksdb_drop_column_family(
|
|
rocksdb_t* db,
|
|
rocksdb_column_family_handle_t* handle,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->DropColumnFamily(handle->rep));
|
|
}
|
|
|
|
void rocksdb_column_family_handle_destroy(rocksdb_column_family_handle_t* handle) {
|
|
delete handle->rep;
|
|
delete handle;
|
|
}
|
|
|
|
void rocksdb_put(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
const char* key, size_t keylen,
|
|
const char* val, size_t vallen,
|
|
char** errptr) {
|
|
SaveError(errptr,
|
|
db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen)));
|
|
}
|
|
|
|
void rocksdb_put_cf(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t keylen,
|
|
const char* val, size_t vallen,
|
|
char** errptr) {
|
|
SaveError(errptr,
|
|
db->rep->Put(options->rep, column_family->rep,
|
|
Slice(key, keylen), Slice(val, vallen)));
|
|
}
|
|
|
|
void rocksdb_delete(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
const char* key, size_t keylen,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen)));
|
|
}
|
|
|
|
void rocksdb_delete_cf(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t keylen,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->Delete(options->rep, column_family->rep,
|
|
Slice(key, keylen)));
|
|
}
|
|
|
|
void rocksdb_merge(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
const char* key, size_t keylen,
|
|
const char* val, size_t vallen,
|
|
char** errptr) {
|
|
SaveError(errptr,
|
|
db->rep->Merge(options->rep, Slice(key, keylen), Slice(val, vallen)));
|
|
}
|
|
|
|
void rocksdb_merge_cf(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t keylen,
|
|
const char* val, size_t vallen,
|
|
char** errptr) {
|
|
SaveError(errptr,
|
|
db->rep->Merge(options->rep, column_family->rep,
|
|
Slice(key, keylen), Slice(val, vallen)));
|
|
}
|
|
|
|
void rocksdb_write(
|
|
rocksdb_t* db,
|
|
const rocksdb_writeoptions_t* options,
|
|
rocksdb_writebatch_t* batch,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->Write(options->rep, &batch->rep));
|
|
}
|
|
|
|
char* rocksdb_get(
|
|
rocksdb_t* db,
|
|
const rocksdb_readoptions_t* options,
|
|
const char* key, size_t keylen,
|
|
size_t* vallen,
|
|
char** errptr) {
|
|
char* result = nullptr;
|
|
std::string tmp;
|
|
Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp);
|
|
if (s.ok()) {
|
|
*vallen = tmp.size();
|
|
result = CopyString(tmp);
|
|
} else {
|
|
*vallen = 0;
|
|
if (!s.IsNotFound()) {
|
|
SaveError(errptr, s);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
char* rocksdb_get_cf(
|
|
rocksdb_t* db,
|
|
const rocksdb_readoptions_t* options,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t keylen,
|
|
size_t* vallen,
|
|
char** errptr) {
|
|
char* result = nullptr;
|
|
std::string tmp;
|
|
Status s = db->rep->Get(options->rep, column_family->rep,
|
|
Slice(key, keylen), &tmp);
|
|
if (s.ok()) {
|
|
*vallen = tmp.size();
|
|
result = CopyString(tmp);
|
|
} else {
|
|
*vallen = 0;
|
|
if (!s.IsNotFound()) {
|
|
SaveError(errptr, s);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
rocksdb_iterator_t* rocksdb_create_iterator(
|
|
rocksdb_t* db,
|
|
const rocksdb_readoptions_t* options) {
|
|
rocksdb_iterator_t* result = new rocksdb_iterator_t;
|
|
result->rep = db->rep->NewIterator(options->rep);
|
|
return result;
|
|
}
|
|
|
|
rocksdb_iterator_t* rocksdb_create_iterator_cf(
|
|
rocksdb_t* db,
|
|
const rocksdb_readoptions_t* options,
|
|
rocksdb_column_family_handle_t* column_family) {
|
|
rocksdb_iterator_t* result = new rocksdb_iterator_t;
|
|
result->rep = db->rep->NewIterator(options->rep, column_family->rep);
|
|
return result;
|
|
}
|
|
|
|
const rocksdb_snapshot_t* rocksdb_create_snapshot(
|
|
rocksdb_t* db) {
|
|
rocksdb_snapshot_t* result = new rocksdb_snapshot_t;
|
|
result->rep = db->rep->GetSnapshot();
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_release_snapshot(
|
|
rocksdb_t* db,
|
|
const rocksdb_snapshot_t* snapshot) {
|
|
db->rep->ReleaseSnapshot(snapshot->rep);
|
|
delete snapshot;
|
|
}
|
|
|
|
char* rocksdb_property_value(
|
|
rocksdb_t* db,
|
|
const char* propname) {
|
|
std::string tmp;
|
|
if (db->rep->GetProperty(Slice(propname), &tmp)) {
|
|
// We use strdup() since we expect human readable output.
|
|
return strdup(tmp.c_str());
|
|
} else {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
char* rocksdb_property_value_cf(
|
|
rocksdb_t* db,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* propname) {
|
|
std::string tmp;
|
|
if (db->rep->GetProperty(column_family->rep, Slice(propname), &tmp)) {
|
|
// We use strdup() since we expect human readable output.
|
|
return strdup(tmp.c_str());
|
|
} else {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
void rocksdb_approximate_sizes(
|
|
rocksdb_t* db,
|
|
int num_ranges,
|
|
const char* const* range_start_key, const size_t* range_start_key_len,
|
|
const char* const* range_limit_key, const size_t* range_limit_key_len,
|
|
uint64_t* sizes) {
|
|
Range* ranges = new Range[num_ranges];
|
|
for (int i = 0; i < num_ranges; i++) {
|
|
ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]);
|
|
ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]);
|
|
}
|
|
db->rep->GetApproximateSizes(ranges, num_ranges, sizes);
|
|
delete[] ranges;
|
|
}
|
|
|
|
void rocksdb_approximate_sizes_cf(
|
|
rocksdb_t* db,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
int num_ranges,
|
|
const char* const* range_start_key, const size_t* range_start_key_len,
|
|
const char* const* range_limit_key, const size_t* range_limit_key_len,
|
|
uint64_t* sizes) {
|
|
Range* ranges = new Range[num_ranges];
|
|
for (int i = 0; i < num_ranges; i++) {
|
|
ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]);
|
|
ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]);
|
|
}
|
|
db->rep->GetApproximateSizes(column_family->rep, ranges, num_ranges, sizes);
|
|
delete[] ranges;
|
|
}
|
|
|
|
void rocksdb_delete_file(
|
|
rocksdb_t* db,
|
|
const char* name) {
|
|
db->rep->DeleteFile(name);
|
|
}
|
|
|
|
const rocksdb_livefiles_t* rocksdb_livefiles(
|
|
rocksdb_t* db) {
|
|
rocksdb_livefiles_t* result = new rocksdb_livefiles_t;
|
|
db->rep->GetLiveFilesMetaData(&result->rep);
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_compact_range(
|
|
rocksdb_t* db,
|
|
const char* start_key, size_t start_key_len,
|
|
const char* limit_key, size_t limit_key_len) {
|
|
Slice a, b;
|
|
db->rep->CompactRange(
|
|
// Pass nullptr Slice if corresponding "const char*" is nullptr
|
|
(start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr),
|
|
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr));
|
|
}
|
|
|
|
void rocksdb_compact_range_cf(
|
|
rocksdb_t* db,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* start_key, size_t start_key_len,
|
|
const char* limit_key, size_t limit_key_len) {
|
|
Slice a, b;
|
|
db->rep->CompactRange(
|
|
column_family->rep,
|
|
// Pass nullptr Slice if corresponding "const char*" is nullptr
|
|
(start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr),
|
|
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr));
|
|
}
|
|
|
|
void rocksdb_flush(
|
|
rocksdb_t* db,
|
|
const rocksdb_flushoptions_t* options,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->Flush(options->rep));
|
|
}
|
|
|
|
void rocksdb_disable_file_deletions(
|
|
rocksdb_t* db,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->DisableFileDeletions());
|
|
}
|
|
|
|
void rocksdb_enable_file_deletions(
|
|
rocksdb_t* db,
|
|
unsigned char force,
|
|
char** errptr) {
|
|
SaveError(errptr, db->rep->EnableFileDeletions(force));
|
|
}
|
|
|
|
void rocksdb_destroy_db(
|
|
const rocksdb_options_t* options,
|
|
const char* name,
|
|
char** errptr) {
|
|
SaveError(errptr, DestroyDB(name, options->rep));
|
|
}
|
|
|
|
void rocksdb_repair_db(
|
|
const rocksdb_options_t* options,
|
|
const char* name,
|
|
char** errptr) {
|
|
SaveError(errptr, RepairDB(name, options->rep));
|
|
}
|
|
|
|
void rocksdb_iter_destroy(rocksdb_iterator_t* iter) {
|
|
delete iter->rep;
|
|
delete iter;
|
|
}
|
|
|
|
unsigned char rocksdb_iter_valid(const rocksdb_iterator_t* iter) {
|
|
return iter->rep->Valid();
|
|
}
|
|
|
|
void rocksdb_iter_seek_to_first(rocksdb_iterator_t* iter) {
|
|
iter->rep->SeekToFirst();
|
|
}
|
|
|
|
void rocksdb_iter_seek_to_last(rocksdb_iterator_t* iter) {
|
|
iter->rep->SeekToLast();
|
|
}
|
|
|
|
void rocksdb_iter_seek(rocksdb_iterator_t* iter, const char* k, size_t klen) {
|
|
iter->rep->Seek(Slice(k, klen));
|
|
}
|
|
|
|
void rocksdb_iter_next(rocksdb_iterator_t* iter) {
|
|
iter->rep->Next();
|
|
}
|
|
|
|
void rocksdb_iter_prev(rocksdb_iterator_t* iter) {
|
|
iter->rep->Prev();
|
|
}
|
|
|
|
const char* rocksdb_iter_key(const rocksdb_iterator_t* iter, size_t* klen) {
|
|
Slice s = iter->rep->key();
|
|
*klen = s.size();
|
|
return s.data();
|
|
}
|
|
|
|
const char* rocksdb_iter_value(const rocksdb_iterator_t* iter, size_t* vlen) {
|
|
Slice s = iter->rep->value();
|
|
*vlen = s.size();
|
|
return s.data();
|
|
}
|
|
|
|
void rocksdb_iter_get_error(const rocksdb_iterator_t* iter, char** errptr) {
|
|
SaveError(errptr, iter->rep->status());
|
|
}
|
|
|
|
rocksdb_writebatch_t* rocksdb_writebatch_create() {
|
|
return new rocksdb_writebatch_t;
|
|
}
|
|
|
|
rocksdb_writebatch_t* rocksdb_writebatch_create_from(const char* rep,
|
|
size_t size) {
|
|
rocksdb_writebatch_t* b = new rocksdb_writebatch_t;
|
|
b->rep = WriteBatch(std::string(rep, size));
|
|
return b;
|
|
}
|
|
|
|
void rocksdb_writebatch_destroy(rocksdb_writebatch_t* b) {
|
|
delete b;
|
|
}
|
|
|
|
void rocksdb_writebatch_clear(rocksdb_writebatch_t* b) {
|
|
b->rep.Clear();
|
|
}
|
|
|
|
int rocksdb_writebatch_count(rocksdb_writebatch_t* b) {
|
|
return b->rep.Count();
|
|
}
|
|
|
|
void rocksdb_writebatch_put(
|
|
rocksdb_writebatch_t* b,
|
|
const char* key, size_t klen,
|
|
const char* val, size_t vlen) {
|
|
b->rep.Put(Slice(key, klen), Slice(val, vlen));
|
|
}
|
|
|
|
void rocksdb_writebatch_put_cf(
|
|
rocksdb_writebatch_t* b,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t klen,
|
|
const char* val, size_t vlen) {
|
|
b->rep.Put(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
|
}
|
|
|
|
void rocksdb_writebatch_merge(
|
|
rocksdb_writebatch_t* b,
|
|
const char* key, size_t klen,
|
|
const char* val, size_t vlen) {
|
|
b->rep.Merge(Slice(key, klen), Slice(val, vlen));
|
|
}
|
|
|
|
void rocksdb_writebatch_merge_cf(
|
|
rocksdb_writebatch_t* b,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t klen,
|
|
const char* val, size_t vlen) {
|
|
b->rep.Merge(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
|
}
|
|
|
|
void rocksdb_writebatch_delete(
|
|
rocksdb_writebatch_t* b,
|
|
const char* key, size_t klen) {
|
|
b->rep.Delete(Slice(key, klen));
|
|
}
|
|
|
|
void rocksdb_writebatch_delete_cf(
|
|
rocksdb_writebatch_t* b,
|
|
rocksdb_column_family_handle_t* column_family,
|
|
const char* key, size_t klen) {
|
|
b->rep.Delete(column_family->rep, Slice(key, klen));
|
|
}
|
|
|
|
void rocksdb_writebatch_iterate(
|
|
rocksdb_writebatch_t* b,
|
|
void* state,
|
|
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
|
|
void (*deleted)(void*, const char* k, size_t klen)) {
|
|
class H : public WriteBatch::Handler {
|
|
public:
|
|
void* state_;
|
|
void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen);
|
|
void (*deleted_)(void*, const char* k, size_t klen);
|
|
virtual void Put(const Slice& key, const Slice& value) {
|
|
(*put_)(state_, key.data(), key.size(), value.data(), value.size());
|
|
}
|
|
virtual void Delete(const Slice& key) {
|
|
(*deleted_)(state_, key.data(), key.size());
|
|
}
|
|
};
|
|
H handler;
|
|
handler.state_ = state;
|
|
handler.put_ = put;
|
|
handler.deleted_ = deleted;
|
|
b->rep.Iterate(&handler);
|
|
}
|
|
|
|
const char* rocksdb_writebatch_data(rocksdb_writebatch_t* b, size_t* size) {
|
|
*size = b->rep.GetDataSize();
|
|
return b->rep.Data().c_str();
|
|
}
|
|
|
|
rocksdb_block_based_table_options_t*
|
|
rocksdb_block_based_options_create() {
|
|
return new rocksdb_block_based_table_options_t;
|
|
}
|
|
|
|
void rocksdb_block_based_options_destroy(
|
|
rocksdb_block_based_table_options_t* options) {
|
|
delete options;
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_block_size(
|
|
rocksdb_block_based_table_options_t* options, size_t block_size) {
|
|
options->rep.block_size = block_size;
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_block_size_deviation(
|
|
rocksdb_block_based_table_options_t* options, int block_size_deviation) {
|
|
options->rep.block_size_deviation = block_size_deviation;
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_block_restart_interval(
|
|
rocksdb_block_based_table_options_t* options, int block_restart_interval) {
|
|
options->rep.block_restart_interval = block_restart_interval;
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_filter_policy(
|
|
rocksdb_block_based_table_options_t* options,
|
|
rocksdb_filterpolicy_t* filter_policy) {
|
|
options->rep.filter_policy.reset(filter_policy);
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_no_block_cache(
|
|
rocksdb_block_based_table_options_t* options,
|
|
unsigned char no_block_cache) {
|
|
options->rep.no_block_cache = no_block_cache;
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_block_cache(
|
|
rocksdb_block_based_table_options_t* options,
|
|
rocksdb_cache_t* block_cache) {
|
|
if (block_cache) {
|
|
options->rep.block_cache = block_cache->rep;
|
|
}
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_block_cache_compressed(
|
|
rocksdb_block_based_table_options_t* options,
|
|
rocksdb_cache_t* block_cache_compressed) {
|
|
if (block_cache_compressed) {
|
|
options->rep.block_cache_compressed = block_cache_compressed->rep;
|
|
}
|
|
}
|
|
|
|
void rocksdb_block_based_options_set_whole_key_filtering(
|
|
rocksdb_block_based_table_options_t* options, unsigned char v) {
|
|
options->rep.whole_key_filtering = v;
|
|
}
|
|
|
|
void rocksdb_options_set_block_based_table_factory(
|
|
rocksdb_options_t *opt,
|
|
rocksdb_block_based_table_options_t* table_options) {
|
|
if (table_options) {
|
|
opt->rep.table_factory.reset(
|
|
rocksdb::NewBlockBasedTableFactory(table_options->rep));
|
|
}
|
|
}
|
|
|
|
|
|
rocksdb_options_t* rocksdb_options_create() {
|
|
return new rocksdb_options_t;
|
|
}
|
|
|
|
void rocksdb_options_destroy(rocksdb_options_t* options) {
|
|
delete options;
|
|
}
|
|
|
|
void rocksdb_options_increase_parallelism(
|
|
rocksdb_options_t* opt, int total_threads) {
|
|
opt->rep.IncreaseParallelism(total_threads);
|
|
}
|
|
|
|
void rocksdb_options_optimize_for_point_lookup(
|
|
rocksdb_options_t* opt, uint64_t block_cache_size_mb) {
|
|
opt->rep.OptimizeForPointLookup(block_cache_size_mb);
|
|
}
|
|
|
|
void rocksdb_options_optimize_level_style_compaction(
|
|
rocksdb_options_t* opt, uint64_t memtable_memory_budget) {
|
|
opt->rep.OptimizeLevelStyleCompaction(memtable_memory_budget);
|
|
}
|
|
|
|
void rocksdb_options_optimize_universal_style_compaction(
|
|
rocksdb_options_t* opt, uint64_t memtable_memory_budget) {
|
|
opt->rep.OptimizeUniversalStyleCompaction(memtable_memory_budget);
|
|
}
|
|
|
|
void rocksdb_options_set_compaction_filter(
|
|
rocksdb_options_t* opt,
|
|
rocksdb_compactionfilter_t* filter) {
|
|
opt->rep.compaction_filter = filter;
|
|
}
|
|
|
|
void rocksdb_options_set_compaction_filter_factory(
|
|
rocksdb_options_t* opt, rocksdb_compactionfilterfactory_t* factory) {
|
|
opt->rep.compaction_filter_factory =
|
|
std::shared_ptr<CompactionFilterFactory>(factory);
|
|
}
|
|
|
|
void rocksdb_options_set_comparator(
|
|
rocksdb_options_t* opt,
|
|
rocksdb_comparator_t* cmp) {
|
|
opt->rep.comparator = cmp;
|
|
}
|
|
|
|
void rocksdb_options_set_merge_operator(
|
|
rocksdb_options_t* opt,
|
|
rocksdb_mergeoperator_t* merge_operator) {
|
|
opt->rep.merge_operator = std::shared_ptr<MergeOperator>(merge_operator);
|
|
}
|
|
|
|
void rocksdb_options_set_compaction_filter_factory_v2(
|
|
rocksdb_options_t* opt,
|
|
rocksdb_compactionfilterfactoryv2_t* compaction_filter_factory_v2) {
|
|
opt->rep.compaction_filter_factory_v2 = std::shared_ptr<CompactionFilterFactoryV2>(compaction_filter_factory_v2);
|
|
}
|
|
|
|
void rocksdb_options_set_create_if_missing(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.create_if_missing = v;
|
|
}
|
|
|
|
void rocksdb_options_set_create_missing_column_families(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.create_missing_column_families = v;
|
|
}
|
|
|
|
void rocksdb_options_set_error_if_exists(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.error_if_exists = v;
|
|
}
|
|
|
|
void rocksdb_options_set_paranoid_checks(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.paranoid_checks = v;
|
|
}
|
|
|
|
void rocksdb_options_set_env(rocksdb_options_t* opt, rocksdb_env_t* env) {
|
|
opt->rep.env = (env ? env->rep : nullptr);
|
|
}
|
|
|
|
void rocksdb_options_set_info_log(rocksdb_options_t* opt, rocksdb_logger_t* l) {
|
|
if (l) {
|
|
opt->rep.info_log = l->rep;
|
|
}
|
|
}
|
|
|
|
void rocksdb_options_set_info_log_level(
|
|
rocksdb_options_t* opt, int v) {
|
|
opt->rep.info_log_level = static_cast<InfoLogLevel>(v);
|
|
}
|
|
|
|
void rocksdb_options_set_write_buffer_size(rocksdb_options_t* opt, size_t s) {
|
|
opt->rep.write_buffer_size = s;
|
|
}
|
|
|
|
void rocksdb_options_set_max_open_files(rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_open_files = n;
|
|
}
|
|
|
|
void rocksdb_options_set_target_file_size_base(
|
|
rocksdb_options_t* opt, uint64_t n) {
|
|
opt->rep.target_file_size_base = n;
|
|
}
|
|
|
|
void rocksdb_options_set_target_file_size_multiplier(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.target_file_size_multiplier = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_bytes_for_level_base(
|
|
rocksdb_options_t* opt, uint64_t n) {
|
|
opt->rep.max_bytes_for_level_base = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_bytes_for_level_multiplier(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_bytes_for_level_multiplier = n;
|
|
}
|
|
|
|
void rocksdb_options_set_expanded_compaction_factor(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.expanded_compaction_factor = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_grandparent_overlap_factor(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_grandparent_overlap_factor = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_bytes_for_level_multiplier_additional(
|
|
rocksdb_options_t* opt, int* level_values, size_t num_levels) {
|
|
opt->rep.max_bytes_for_level_multiplier_additional.resize(num_levels);
|
|
for (size_t i = 0; i < num_levels; ++i) {
|
|
opt->rep.max_bytes_for_level_multiplier_additional[i] = level_values[i];
|
|
}
|
|
}
|
|
|
|
void rocksdb_options_enable_statistics(rocksdb_options_t* opt) {
|
|
opt->rep.statistics = rocksdb::CreateDBStatistics();
|
|
}
|
|
|
|
void rocksdb_options_set_num_levels(rocksdb_options_t* opt, int n) {
|
|
opt->rep.num_levels = n;
|
|
}
|
|
|
|
void rocksdb_options_set_level0_file_num_compaction_trigger(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.level0_file_num_compaction_trigger = n;
|
|
}
|
|
|
|
void rocksdb_options_set_level0_slowdown_writes_trigger(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.level0_slowdown_writes_trigger = n;
|
|
}
|
|
|
|
void rocksdb_options_set_level0_stop_writes_trigger(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.level0_stop_writes_trigger = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_mem_compaction_level(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_mem_compaction_level = n;
|
|
}
|
|
|
|
void rocksdb_options_set_compression(rocksdb_options_t* opt, int t) {
|
|
opt->rep.compression = static_cast<CompressionType>(t);
|
|
}
|
|
|
|
void rocksdb_options_set_compression_per_level(rocksdb_options_t* opt,
|
|
int* level_values,
|
|
size_t num_levels) {
|
|
opt->rep.compression_per_level.resize(num_levels);
|
|
for (size_t i = 0; i < num_levels; ++i) {
|
|
opt->rep.compression_per_level[i] =
|
|
static_cast<CompressionType>(level_values[i]);
|
|
}
|
|
}
|
|
|
|
void rocksdb_options_set_compression_options(
|
|
rocksdb_options_t* opt, int w_bits, int level, int strategy) {
|
|
opt->rep.compression_opts.window_bits = w_bits;
|
|
opt->rep.compression_opts.level = level;
|
|
opt->rep.compression_opts.strategy = strategy;
|
|
}
|
|
|
|
void rocksdb_options_set_prefix_extractor(
|
|
rocksdb_options_t* opt, rocksdb_slicetransform_t* prefix_extractor) {
|
|
opt->rep.prefix_extractor.reset(prefix_extractor);
|
|
}
|
|
|
|
void rocksdb_options_set_disable_data_sync(
|
|
rocksdb_options_t* opt, int disable_data_sync) {
|
|
opt->rep.disableDataSync = disable_data_sync;
|
|
}
|
|
|
|
void rocksdb_options_set_use_fsync(
|
|
rocksdb_options_t* opt, int use_fsync) {
|
|
opt->rep.use_fsync = use_fsync;
|
|
}
|
|
|
|
void rocksdb_options_set_db_log_dir(
|
|
rocksdb_options_t* opt, const char* db_log_dir) {
|
|
opt->rep.db_log_dir = db_log_dir;
|
|
}
|
|
|
|
void rocksdb_options_set_wal_dir(
|
|
rocksdb_options_t* opt, const char* v) {
|
|
opt->rep.wal_dir = v;
|
|
}
|
|
|
|
void rocksdb_options_set_WAL_ttl_seconds(rocksdb_options_t* opt, uint64_t ttl) {
|
|
opt->rep.WAL_ttl_seconds = ttl;
|
|
}
|
|
|
|
void rocksdb_options_set_WAL_size_limit_MB(
|
|
rocksdb_options_t* opt, uint64_t limit) {
|
|
opt->rep.WAL_size_limit_MB = limit;
|
|
}
|
|
|
|
void rocksdb_options_set_manifest_preallocation_size(
|
|
rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.manifest_preallocation_size = v;
|
|
}
|
|
|
|
void rocksdb_options_set_purge_redundant_kvs_while_flush(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.purge_redundant_kvs_while_flush = v;
|
|
}
|
|
|
|
void rocksdb_options_set_allow_os_buffer(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.allow_os_buffer = v;
|
|
}
|
|
|
|
void rocksdb_options_set_allow_mmap_reads(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.allow_mmap_reads = v;
|
|
}
|
|
|
|
void rocksdb_options_set_allow_mmap_writes(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.allow_mmap_writes = v;
|
|
}
|
|
|
|
void rocksdb_options_set_is_fd_close_on_exec(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.is_fd_close_on_exec = v;
|
|
}
|
|
|
|
void rocksdb_options_set_skip_log_error_on_recovery(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.skip_log_error_on_recovery = v;
|
|
}
|
|
|
|
void rocksdb_options_set_stats_dump_period_sec(
|
|
rocksdb_options_t* opt, unsigned int v) {
|
|
opt->rep.stats_dump_period_sec = v;
|
|
}
|
|
|
|
void rocksdb_options_set_advise_random_on_open(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.advise_random_on_open = v;
|
|
}
|
|
|
|
void rocksdb_options_set_access_hint_on_compaction_start(
|
|
rocksdb_options_t* opt, int v) {
|
|
switch(v) {
|
|
case 0:
|
|
opt->rep.access_hint_on_compaction_start = rocksdb::Options::NONE;
|
|
break;
|
|
case 1:
|
|
opt->rep.access_hint_on_compaction_start = rocksdb::Options::NORMAL;
|
|
break;
|
|
case 2:
|
|
opt->rep.access_hint_on_compaction_start = rocksdb::Options::SEQUENTIAL;
|
|
break;
|
|
case 3:
|
|
opt->rep.access_hint_on_compaction_start = rocksdb::Options::WILLNEED;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void rocksdb_options_set_use_adaptive_mutex(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.use_adaptive_mutex = v;
|
|
}
|
|
|
|
void rocksdb_options_set_bytes_per_sync(
|
|
rocksdb_options_t* opt, uint64_t v) {
|
|
opt->rep.bytes_per_sync = v;
|
|
}
|
|
|
|
void rocksdb_options_set_verify_checksums_in_compaction(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.verify_checksums_in_compaction = v;
|
|
}
|
|
|
|
void rocksdb_options_set_filter_deletes(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.filter_deletes = v;
|
|
}
|
|
|
|
void rocksdb_options_set_max_sequential_skip_in_iterations(
|
|
rocksdb_options_t* opt, uint64_t v) {
|
|
opt->rep.max_sequential_skip_in_iterations = v;
|
|
}
|
|
|
|
void rocksdb_options_set_max_write_buffer_number(rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_write_buffer_number = n;
|
|
}
|
|
|
|
void rocksdb_options_set_min_write_buffer_number_to_merge(rocksdb_options_t* opt, int n) {
|
|
opt->rep.min_write_buffer_number_to_merge = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_background_compactions(rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_background_compactions = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_background_flushes(rocksdb_options_t* opt, int n) {
|
|
opt->rep.max_background_flushes = n;
|
|
}
|
|
|
|
void rocksdb_options_set_max_log_file_size(rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.max_log_file_size = v;
|
|
}
|
|
|
|
void rocksdb_options_set_log_file_time_to_roll(rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.log_file_time_to_roll = v;
|
|
}
|
|
|
|
void rocksdb_options_set_keep_log_file_num(rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.keep_log_file_num = v;
|
|
}
|
|
|
|
void rocksdb_options_set_soft_rate_limit(rocksdb_options_t* opt, double v) {
|
|
opt->rep.soft_rate_limit = v;
|
|
}
|
|
|
|
void rocksdb_options_set_hard_rate_limit(rocksdb_options_t* opt, double v) {
|
|
opt->rep.hard_rate_limit = v;
|
|
}
|
|
|
|
void rocksdb_options_set_rate_limit_delay_max_milliseconds(
|
|
rocksdb_options_t* opt, unsigned int v) {
|
|
opt->rep.rate_limit_delay_max_milliseconds = v;
|
|
}
|
|
|
|
void rocksdb_options_set_max_manifest_file_size(
|
|
rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.max_manifest_file_size = v;
|
|
}
|
|
|
|
void rocksdb_options_set_table_cache_numshardbits(
|
|
rocksdb_options_t* opt, int v) {
|
|
opt->rep.table_cache_numshardbits = v;
|
|
}
|
|
|
|
void rocksdb_options_set_table_cache_remove_scan_count_limit(
|
|
rocksdb_options_t* opt, int v) {
|
|
opt->rep.table_cache_remove_scan_count_limit = v;
|
|
}
|
|
|
|
void rocksdb_options_set_arena_block_size(
|
|
rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.arena_block_size = v;
|
|
}
|
|
|
|
void rocksdb_options_set_disable_auto_compactions(rocksdb_options_t* opt, int disable) {
|
|
opt->rep.disable_auto_compactions = disable;
|
|
}
|
|
|
|
void rocksdb_options_set_delete_obsolete_files_period_micros(
|
|
rocksdb_options_t* opt, uint64_t v) {
|
|
opt->rep.delete_obsolete_files_period_micros = v;
|
|
}
|
|
|
|
void rocksdb_options_set_source_compaction_factor(
|
|
rocksdb_options_t* opt, int n) {
|
|
opt->rep.expanded_compaction_factor = n;
|
|
}
|
|
|
|
void rocksdb_options_prepare_for_bulk_load(rocksdb_options_t* opt) {
|
|
opt->rep.PrepareForBulkLoad();
|
|
}
|
|
|
|
void rocksdb_options_set_memtable_vector_rep(rocksdb_options_t *opt) {
|
|
static rocksdb::VectorRepFactory* factory = 0;
|
|
if (!factory) {
|
|
factory = new rocksdb::VectorRepFactory;
|
|
}
|
|
opt->rep.memtable_factory.reset(factory);
|
|
}
|
|
|
|
void rocksdb_options_set_memtable_prefix_bloom_bits(
|
|
rocksdb_options_t* opt, uint32_t v) {
|
|
opt->rep.memtable_prefix_bloom_bits = v;
|
|
}
|
|
|
|
void rocksdb_options_set_memtable_prefix_bloom_probes(
|
|
rocksdb_options_t* opt, uint32_t v) {
|
|
opt->rep.memtable_prefix_bloom_probes = v;
|
|
}
|
|
|
|
void rocksdb_options_set_hash_skip_list_rep(
|
|
rocksdb_options_t *opt, size_t bucket_count,
|
|
int32_t skiplist_height, int32_t skiplist_branching_factor) {
|
|
static rocksdb::MemTableRepFactory* factory = 0;
|
|
if (!factory) {
|
|
factory = rocksdb::NewHashSkipListRepFactory(
|
|
bucket_count, skiplist_height, skiplist_branching_factor);
|
|
}
|
|
opt->rep.memtable_factory.reset(factory);
|
|
}
|
|
|
|
void rocksdb_options_set_hash_link_list_rep(
|
|
rocksdb_options_t *opt, size_t bucket_count) {
|
|
static rocksdb::MemTableRepFactory* factory = 0;
|
|
if (!factory) {
|
|
factory = rocksdb::NewHashLinkListRepFactory(bucket_count);
|
|
}
|
|
opt->rep.memtable_factory.reset(factory);
|
|
}
|
|
|
|
void rocksdb_options_set_plain_table_factory(
|
|
rocksdb_options_t *opt, uint32_t user_key_len, int bloom_bits_per_key,
|
|
double hash_table_ratio, size_t index_sparseness) {
|
|
static rocksdb::TableFactory* factory = 0;
|
|
if (!factory) {
|
|
rocksdb::PlainTableOptions options;
|
|
options.user_key_len = user_key_len;
|
|
options.bloom_bits_per_key = bloom_bits_per_key;
|
|
options.hash_table_ratio = hash_table_ratio;
|
|
options.index_sparseness = index_sparseness;
|
|
|
|
factory = rocksdb::NewPlainTableFactory(options);
|
|
}
|
|
opt->rep.table_factory.reset(factory);
|
|
}
|
|
|
|
void rocksdb_options_set_max_successive_merges(
|
|
rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.max_successive_merges = v;
|
|
}
|
|
|
|
void rocksdb_options_set_min_partial_merge_operands(
|
|
rocksdb_options_t* opt, uint32_t v) {
|
|
opt->rep.min_partial_merge_operands = v;
|
|
}
|
|
|
|
void rocksdb_options_set_bloom_locality(
|
|
rocksdb_options_t* opt, uint32_t v) {
|
|
opt->rep.bloom_locality = v;
|
|
}
|
|
|
|
void rocksdb_options_set_allow_thread_local(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.allow_thread_local = v;
|
|
}
|
|
|
|
void rocksdb_options_set_inplace_update_support(
|
|
rocksdb_options_t* opt, unsigned char v) {
|
|
opt->rep.inplace_update_support = v;
|
|
}
|
|
|
|
void rocksdb_options_set_inplace_update_num_locks(
|
|
rocksdb_options_t* opt, size_t v) {
|
|
opt->rep.inplace_update_num_locks = v;
|
|
}
|
|
|
|
void rocksdb_options_set_compaction_style(rocksdb_options_t *opt, int style) {
|
|
opt->rep.compaction_style = static_cast<rocksdb::CompactionStyle>(style);
|
|
}
|
|
|
|
void rocksdb_options_set_universal_compaction_options(rocksdb_options_t *opt, rocksdb_universal_compaction_options_t *uco) {
|
|
opt->rep.compaction_options_universal = *(uco->rep);
|
|
}
|
|
|
|
void rocksdb_options_set_fifo_compaction_options(
|
|
rocksdb_options_t* opt,
|
|
rocksdb_fifo_compaction_options_t* fifo) {
|
|
opt->rep.compaction_options_fifo = fifo->rep;
|
|
}
|
|
|
|
/*
|
|
TODO:
|
|
DB::OpenForReadOnly
|
|
DB::MultiGet
|
|
DB::KeyMayExist
|
|
DB::GetOptions
|
|
DB::GetSortedWalFiles
|
|
DB::GetLatestSequenceNumber
|
|
DB::GetUpdatesSince
|
|
DB::GetDbIdentity
|
|
DB::RunManualCompaction
|
|
custom cache
|
|
table_properties_collectors
|
|
*/
|
|
|
|
rocksdb_compactionfilter_t* rocksdb_compactionfilter_create(
|
|
void* state,
|
|
void (*destructor)(void*),
|
|
unsigned char (*filter)(
|
|
void*,
|
|
int level,
|
|
const char* key, size_t key_length,
|
|
const char* existing_value, size_t value_length,
|
|
char** new_value, size_t *new_value_length,
|
|
unsigned char* value_changed),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_compactionfilter_t* result = new rocksdb_compactionfilter_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->filter_ = filter;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_compactionfilter_destroy(rocksdb_compactionfilter_t* filter) {
|
|
delete filter;
|
|
}
|
|
|
|
unsigned char rocksdb_compactionfiltercontext_is_full_compaction(
|
|
rocksdb_compactionfiltercontext_t* context) {
|
|
return context->rep.is_full_compaction;
|
|
}
|
|
|
|
unsigned char rocksdb_compactionfiltercontext_is_manual_compaction(
|
|
rocksdb_compactionfiltercontext_t* context) {
|
|
return context->rep.is_manual_compaction;
|
|
}
|
|
|
|
rocksdb_compactionfilterfactory_t* rocksdb_compactionfilterfactory_create(
|
|
void* state, void (*destructor)(void*),
|
|
rocksdb_compactionfilter_t* (*create_compaction_filter)(
|
|
void*, rocksdb_compactionfiltercontext_t* context),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_compactionfilterfactory_t* result =
|
|
new rocksdb_compactionfilterfactory_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->create_compaction_filter_ = create_compaction_filter;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_compactionfilterfactory_destroy(
|
|
rocksdb_compactionfilterfactory_t* factory) {
|
|
delete factory;
|
|
}
|
|
|
|
rocksdb_compactionfilterv2_t* rocksdb_compactionfilterv2_create(
|
|
void* state,
|
|
void (*destructor)(void*),
|
|
void (*filter)(void*, int level, size_t num_keys,
|
|
const char* const* keys_list, const size_t* keys_list_sizes,
|
|
const char* const* existing_values_list, const size_t* existing_values_list_sizes,
|
|
char** new_values_list, size_t* new_values_list_sizes,
|
|
unsigned char* to_delete_list),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_compactionfilterv2_t* result = new rocksdb_compactionfilterv2_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->filter_ = filter;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_compactionfilterv2_destroy(rocksdb_compactionfilterv2_t* filter) {
|
|
delete filter;
|
|
}
|
|
|
|
rocksdb_compactionfilterfactoryv2_t* rocksdb_compactionfilterfactoryv2_create(
|
|
void* state,
|
|
rocksdb_slicetransform_t* prefix_extractor,
|
|
void (*destructor)(void*),
|
|
rocksdb_compactionfilterv2_t* (*create_compaction_filter_v2)(
|
|
void* state, const rocksdb_compactionfiltercontext_t* context),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_compactionfilterfactoryv2_t* result = new rocksdb_compactionfilterfactoryv2_t(prefix_extractor);
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->create_compaction_filter_v2_ = create_compaction_filter_v2;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_compactionfilterfactoryv2_destroy(rocksdb_compactionfilterfactoryv2_t* factory) {
|
|
delete factory;
|
|
}
|
|
|
|
rocksdb_comparator_t* rocksdb_comparator_create(
|
|
void* state,
|
|
void (*destructor)(void*),
|
|
int (*compare)(
|
|
void*,
|
|
const char* a, size_t alen,
|
|
const char* b, size_t blen),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_comparator_t* result = new rocksdb_comparator_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->compare_ = compare;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_comparator_destroy(rocksdb_comparator_t* cmp) {
|
|
delete cmp;
|
|
}
|
|
|
|
rocksdb_filterpolicy_t* rocksdb_filterpolicy_create(
|
|
void* state,
|
|
void (*destructor)(void*),
|
|
char* (*create_filter)(
|
|
void*,
|
|
const char* const* key_array, const size_t* key_length_array,
|
|
int num_keys,
|
|
size_t* filter_length),
|
|
unsigned char (*key_may_match)(
|
|
void*,
|
|
const char* key, size_t length,
|
|
const char* filter, size_t filter_length),
|
|
void (*delete_filter)(
|
|
void*,
|
|
const char* filter, size_t filter_length),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_filterpolicy_t* result = new rocksdb_filterpolicy_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->create_ = create_filter;
|
|
result->key_match_ = key_may_match;
|
|
result->delete_filter_ = delete_filter;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_filterpolicy_destroy(rocksdb_filterpolicy_t* filter) {
|
|
delete filter;
|
|
}
|
|
|
|
rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) {
|
|
// Make a rocksdb_filterpolicy_t, but override all of its methods so
|
|
// they delegate to a NewBloomFilterPolicy() instead of user
|
|
// supplied C functions.
|
|
struct Wrapper : public rocksdb_filterpolicy_t {
|
|
const FilterPolicy* rep_;
|
|
~Wrapper() { delete rep_; }
|
|
const char* Name() const { return rep_->Name(); }
|
|
void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
|
return rep_->CreateFilter(keys, n, dst);
|
|
}
|
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const {
|
|
return rep_->KeyMayMatch(key, filter);
|
|
}
|
|
static void DoNothing(void*) { }
|
|
};
|
|
Wrapper* wrapper = new Wrapper;
|
|
wrapper->rep_ = NewBloomFilterPolicy(bits_per_key);
|
|
wrapper->state_ = nullptr;
|
|
wrapper->delete_filter_ = nullptr;
|
|
wrapper->destructor_ = &Wrapper::DoNothing;
|
|
return wrapper;
|
|
}
|
|
|
|
rocksdb_mergeoperator_t* rocksdb_mergeoperator_create(
|
|
void* state, void (*destructor)(void*),
|
|
char* (*full_merge)(void*, const char* key, size_t key_length,
|
|
const char* existing_value,
|
|
size_t existing_value_length,
|
|
const char* const* operands_list,
|
|
const size_t* operands_list_length, int num_operands,
|
|
unsigned char* success, size_t* new_value_length),
|
|
char* (*partial_merge)(void*, const char* key, size_t key_length,
|
|
const char* const* operands_list,
|
|
const size_t* operands_list_length, int num_operands,
|
|
unsigned char* success, size_t* new_value_length),
|
|
void (*delete_value)(void*, const char* value, size_t value_length),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_mergeoperator_t* result = new rocksdb_mergeoperator_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->full_merge_ = full_merge;
|
|
result->partial_merge_ = partial_merge;
|
|
result->delete_value_ = delete_value;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_mergeoperator_destroy(rocksdb_mergeoperator_t* merge_operator) {
|
|
delete merge_operator;
|
|
}
|
|
|
|
rocksdb_readoptions_t* rocksdb_readoptions_create() {
|
|
return new rocksdb_readoptions_t;
|
|
}
|
|
|
|
void rocksdb_readoptions_destroy(rocksdb_readoptions_t* opt) {
|
|
delete opt;
|
|
}
|
|
|
|
void rocksdb_readoptions_set_verify_checksums(
|
|
rocksdb_readoptions_t* opt,
|
|
unsigned char v) {
|
|
opt->rep.verify_checksums = v;
|
|
}
|
|
|
|
void rocksdb_readoptions_set_fill_cache(
|
|
rocksdb_readoptions_t* opt, unsigned char v) {
|
|
opt->rep.fill_cache = v;
|
|
}
|
|
|
|
void rocksdb_readoptions_set_snapshot(
|
|
rocksdb_readoptions_t* opt,
|
|
const rocksdb_snapshot_t* snap) {
|
|
opt->rep.snapshot = (snap ? snap->rep : nullptr);
|
|
}
|
|
|
|
void rocksdb_readoptions_set_read_tier(
|
|
rocksdb_readoptions_t* opt, int v) {
|
|
opt->rep.read_tier = static_cast<rocksdb::ReadTier>(v);
|
|
}
|
|
|
|
void rocksdb_readoptions_set_tailing(
|
|
rocksdb_readoptions_t* opt, unsigned char v) {
|
|
opt->rep.tailing = v;
|
|
}
|
|
|
|
rocksdb_writeoptions_t* rocksdb_writeoptions_create() {
|
|
return new rocksdb_writeoptions_t;
|
|
}
|
|
|
|
void rocksdb_writeoptions_destroy(rocksdb_writeoptions_t* opt) {
|
|
delete opt;
|
|
}
|
|
|
|
void rocksdb_writeoptions_set_sync(
|
|
rocksdb_writeoptions_t* opt, unsigned char v) {
|
|
opt->rep.sync = v;
|
|
}
|
|
|
|
void rocksdb_writeoptions_disable_WAL(rocksdb_writeoptions_t* opt, int disable) {
|
|
opt->rep.disableWAL = disable;
|
|
}
|
|
|
|
|
|
rocksdb_flushoptions_t* rocksdb_flushoptions_create() {
|
|
return new rocksdb_flushoptions_t;
|
|
}
|
|
|
|
void rocksdb_flushoptions_destroy(rocksdb_flushoptions_t* opt) {
|
|
delete opt;
|
|
}
|
|
|
|
void rocksdb_flushoptions_set_wait(
|
|
rocksdb_flushoptions_t* opt, unsigned char v) {
|
|
opt->rep.wait = v;
|
|
}
|
|
|
|
rocksdb_cache_t* rocksdb_cache_create_lru(size_t capacity) {
|
|
rocksdb_cache_t* c = new rocksdb_cache_t;
|
|
c->rep = NewLRUCache(capacity);
|
|
return c;
|
|
}
|
|
|
|
void rocksdb_cache_destroy(rocksdb_cache_t* cache) {
|
|
delete cache;
|
|
}
|
|
|
|
rocksdb_env_t* rocksdb_create_default_env() {
|
|
rocksdb_env_t* result = new rocksdb_env_t;
|
|
result->rep = Env::Default();
|
|
result->is_default = true;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_env_set_background_threads(rocksdb_env_t* env, int n) {
|
|
env->rep->SetBackgroundThreads(n);
|
|
}
|
|
|
|
void rocksdb_env_set_high_priority_background_threads(rocksdb_env_t* env, int n) {
|
|
env->rep->SetBackgroundThreads(n, Env::HIGH);
|
|
}
|
|
|
|
void rocksdb_env_destroy(rocksdb_env_t* env) {
|
|
if (!env->is_default) delete env->rep;
|
|
delete env;
|
|
}
|
|
|
|
rocksdb_slicetransform_t* rocksdb_slicetransform_create(
|
|
void* state,
|
|
void (*destructor)(void*),
|
|
char* (*transform)(
|
|
void*,
|
|
const char* key, size_t length,
|
|
size_t* dst_length),
|
|
unsigned char (*in_domain)(
|
|
void*,
|
|
const char* key, size_t length),
|
|
unsigned char (*in_range)(
|
|
void*,
|
|
const char* key, size_t length),
|
|
const char* (*name)(void*)) {
|
|
rocksdb_slicetransform_t* result = new rocksdb_slicetransform_t;
|
|
result->state_ = state;
|
|
result->destructor_ = destructor;
|
|
result->transform_ = transform;
|
|
result->in_domain_ = in_domain;
|
|
result->in_range_ = in_range;
|
|
result->name_ = name;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_slicetransform_destroy(rocksdb_slicetransform_t* st) {
|
|
delete st;
|
|
}
|
|
|
|
rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t prefixLen) {
|
|
struct Wrapper : public rocksdb_slicetransform_t {
|
|
const SliceTransform* rep_;
|
|
~Wrapper() { delete rep_; }
|
|
const char* Name() const { return rep_->Name(); }
|
|
Slice Transform(const Slice& src) const {
|
|
return rep_->Transform(src);
|
|
}
|
|
bool InDomain(const Slice& src) const {
|
|
return rep_->InDomain(src);
|
|
}
|
|
bool InRange(const Slice& src) const {
|
|
return rep_->InRange(src);
|
|
}
|
|
static void DoNothing(void*) { }
|
|
};
|
|
Wrapper* wrapper = new Wrapper;
|
|
wrapper->rep_ = rocksdb::NewFixedPrefixTransform(prefixLen);
|
|
wrapper->state_ = nullptr;
|
|
wrapper->destructor_ = &Wrapper::DoNothing;
|
|
return wrapper;
|
|
}
|
|
|
|
rocksdb_universal_compaction_options_t* rocksdb_universal_compaction_options_create() {
|
|
rocksdb_universal_compaction_options_t* result = new rocksdb_universal_compaction_options_t;
|
|
result->rep = new rocksdb::CompactionOptionsUniversal;
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_size_ratio(
|
|
rocksdb_universal_compaction_options_t* uco, int ratio) {
|
|
uco->rep->size_ratio = ratio;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_min_merge_width(
|
|
rocksdb_universal_compaction_options_t* uco, int w) {
|
|
uco->rep->min_merge_width = w;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_max_merge_width(
|
|
rocksdb_universal_compaction_options_t* uco, int w) {
|
|
uco->rep->max_merge_width = w;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_max_size_amplification_percent(
|
|
rocksdb_universal_compaction_options_t* uco, int p) {
|
|
uco->rep->max_size_amplification_percent = p;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_compression_size_percent(
|
|
rocksdb_universal_compaction_options_t* uco, int p) {
|
|
uco->rep->compression_size_percent = p;
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_set_stop_style(
|
|
rocksdb_universal_compaction_options_t* uco, int style) {
|
|
uco->rep->stop_style = static_cast<rocksdb::CompactionStopStyle>(style);
|
|
}
|
|
|
|
void rocksdb_universal_compaction_options_destroy(
|
|
rocksdb_universal_compaction_options_t* uco) {
|
|
delete uco->rep;
|
|
delete uco;
|
|
}
|
|
|
|
rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create() {
|
|
rocksdb_fifo_compaction_options_t* result = new rocksdb_fifo_compaction_options_t;
|
|
result->rep = CompactionOptionsFIFO();
|
|
return result;
|
|
}
|
|
|
|
void rocksdb_fifo_compaction_options_set_max_table_files_size(
|
|
rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size) {
|
|
fifo_opts->rep.max_table_files_size = size;
|
|
}
|
|
|
|
void rocksdb_fifo_compaction_options_destroy(
|
|
rocksdb_fifo_compaction_options_t* fifo_opts) {
|
|
delete fifo_opts;
|
|
}
|
|
|
|
void rocksdb_options_set_min_level_to_compress(rocksdb_options_t* opt, int level) {
|
|
if (level >= 0) {
|
|
assert(level <= opt->rep.num_levels);
|
|
opt->rep.compression_per_level.resize(opt->rep.num_levels);
|
|
for (int i = 0; i < level; i++) {
|
|
opt->rep.compression_per_level[i] = rocksdb::kNoCompression;
|
|
}
|
|
for (int i = level; i < opt->rep.num_levels; i++) {
|
|
opt->rep.compression_per_level[i] = opt->rep.compression;
|
|
}
|
|
}
|
|
}
|
|
|
|
int rocksdb_livefiles_count(
|
|
const rocksdb_livefiles_t* lf) {
|
|
return lf->rep.size();
|
|
}
|
|
|
|
const char* rocksdb_livefiles_name(
|
|
const rocksdb_livefiles_t* lf,
|
|
int index) {
|
|
return lf->rep[index].name.c_str();
|
|
}
|
|
|
|
int rocksdb_livefiles_level(
|
|
const rocksdb_livefiles_t* lf,
|
|
int index) {
|
|
return lf->rep[index].level;
|
|
}
|
|
|
|
size_t rocksdb_livefiles_size(
|
|
const rocksdb_livefiles_t* lf,
|
|
int index) {
|
|
return lf->rep[index].size;
|
|
}
|
|
|
|
const char* rocksdb_livefiles_smallestkey(
|
|
const rocksdb_livefiles_t* lf,
|
|
int index,
|
|
size_t* size) {
|
|
*size = lf->rep[index].smallestkey.size();
|
|
return lf->rep[index].smallestkey.data();
|
|
}
|
|
|
|
const char* rocksdb_livefiles_largestkey(
|
|
const rocksdb_livefiles_t* lf,
|
|
int index,
|
|
size_t* size) {
|
|
*size = lf->rep[index].largestkey.size();
|
|
return lf->rep[index].largestkey.data();
|
|
}
|
|
|
|
extern void rocksdb_livefiles_destroy(
|
|
const rocksdb_livefiles_t* lf) {
|
|
delete lf;
|
|
}
|
|
|
|
} // end extern "C"
|
|
|
|
#endif // ROCKSDB_LITE
|