Uses clang-format for C/C++ code

Uses the same configuration as RocksDB
pull/398/head
Tpt 2 years ago committed by Thomas Tanon
parent 03df957427
commit c8caf805fa
  1. 7
      .github/workflows/tests.yml
  2. 3
      oxrocksdb-sys/api/.clang-format
  3. 56
      oxrocksdb-sys/api/build_version.cc
  4. 387
      oxrocksdb-sys/api/c.cc
  5. 216
      oxrocksdb-sys/api/c.h

@ -250,6 +250,13 @@ jobs:
- run: cargo install typos-cli || true - run: cargo install typos-cli || true
- run: typos - run: typos
clang_fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt install -y clang-format
- run: clang-format --Werror --dry-run oxrocksdb-sys/api/*
fuzz_changes: fuzz_changes:
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
runs-on: ubuntu-latest runs-on: ubuntu-latest

@ -0,0 +1,3 @@
---
BasedOnStyle: Google
...

@ -2,37 +2,39 @@
#include <memory> #include <memory>
#include "rocksdb/version.h"
#include "rocksdb/utilities/object_registry.h" #include "rocksdb/utilities/object_registry.h"
#include "rocksdb/version.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
std::unordered_map<std::string, RegistrarFunc> ObjectRegistry::builtins_ = {}; std::unordered_map<std::string, RegistrarFunc> ObjectRegistry::builtins_ = {};
const std::unordered_map<std::string, std::string>& GetRocksBuildProperties() { const std::unordered_map<std::string, std::string>& GetRocksBuildProperties() {
static std::unique_ptr<std::unordered_map<std::string, std::string>> props(new std::unordered_map<std::string, std::string>()); static std::unique_ptr<std::unordered_map<std::string, std::string>> props(
return *props; new std::unordered_map<std::string, std::string>());
} return *props;
}
std::string GetRocksVersionAsString(bool with_patch) { std::string GetRocksVersionAsString(bool with_patch) {
std::string version = std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR); std::string version =
if (with_patch) { std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR);
return version + "." + std::to_string(ROCKSDB_PATCH); if (with_patch) {
} else { return version + "." + std::to_string(ROCKSDB_PATCH);
return version; } else {
} return version;
} }
}
std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose) { std::string GetRocksBuildInfoAsString(const std::string& program,
std::string info = program + " (RocksDB) " + GetRocksVersionAsString(true); bool verbose) {
if (verbose) { std::string info = program + " (RocksDB) " + GetRocksVersionAsString(true);
for (const auto& it : GetRocksBuildProperties()) { if (verbose) {
info.append("\n "); for (const auto& it : GetRocksBuildProperties()) {
info.append(it.first); info.append("\n ");
info.append(": "); info.append(it.first);
info.append(it.second); info.append(": ");
} info.append(it.second);
}
return info;
} }
} // namespace ROCKSDB_NAMESPACE }
return info;
}
} // namespace ROCKSDB_NAMESPACE

@ -1,19 +1,20 @@
#include "../rocksdb/db/c.cc" #include "../rocksdb/db/c.cc"
#include "c.h" #include "c.h"
static bool SaveStatus(rocksdb_status_t* target, const Status source) { static bool SaveStatus(rocksdb_status_t* target, const Status source) {
target->code = static_cast<rocksdb_status_code_t>(source.code()); target->code = static_cast<rocksdb_status_code_t>(source.code());
target->subcode = static_cast<rocksdb_status_subcode_t>(source.subcode()); target->subcode = static_cast<rocksdb_status_subcode_t>(source.subcode());
target->severity = static_cast<rocksdb_status_severity_t>(source.severity()); target->severity = static_cast<rocksdb_status_severity_t>(source.severity());
if(source.ok()) { if (source.ok()) {
target->string = nullptr; target->string = nullptr;
} else { } else {
std::string msg = source.ToString(); std::string msg = source.ToString();
char *string = new char[msg.size() + 1]; //we need extra char for NUL char* string = new char[msg.size() + 1]; // we need extra char for NUL
memcpy(string, msg.c_str(), msg.size() + 1); memcpy(string, msg.c_str(), msg.size() + 1);
target->string = string; target->string = string;
} }
return !source.ok(); return !source.ok();
} }
extern "C" { extern "C" {
@ -43,17 +44,17 @@ rocksdb_t* rocksdb_open_for_read_only_column_families_with_status(
unsigned char error_if_wal_file_exists, rocksdb_status_t* statusptr) { unsigned char error_if_wal_file_exists, rocksdb_status_t* statusptr) {
std::vector<ColumnFamilyDescriptor> column_families; std::vector<ColumnFamilyDescriptor> column_families;
for (int i = 0; i < num_column_families; i++) { for (int i = 0; i < num_column_families; i++) {
column_families.push_back(ColumnFamilyDescriptor( column_families.emplace_back(ColumnFamilyDescriptor(
std::string(column_family_names[i]), std::string(column_family_names[i]),
ColumnFamilyOptions(column_family_options[i]->rep))); ColumnFamilyOptions(column_family_options[i]->rep)));
} }
DB* db; DB* db;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
if (SaveStatus(statusptr, if (SaveStatus(statusptr, DB::OpenForReadOnly(DBOptions(db_options->rep),
DB::OpenForReadOnly(DBOptions(db_options->rep), std::string(name),
std::string(name), column_families, column_families, &handles, &db,
&handles, &db, error_if_wal_file_exists))) { error_if_wal_file_exists))) {
return nullptr; return nullptr;
} }
@ -69,235 +70,239 @@ rocksdb_t* rocksdb_open_for_read_only_column_families_with_status(
} }
void rocksdb_try_catch_up_with_primary_with_status( void rocksdb_try_catch_up_with_primary_with_status(
rocksdb_t* db, rocksdb_status_t* statusptr) { rocksdb_t* db, rocksdb_status_t* statusptr) {
SaveStatus(statusptr, db->rep->TryCatchUpWithPrimary()); SaveStatus(statusptr, db->rep->TryCatchUpWithPrimary());
} }
rocksdb_t* rocksdb_open_as_secondary_column_families_with_status( rocksdb_t* rocksdb_open_as_secondary_column_families_with_status(
const rocksdb_options_t* db_options, const char* name, const rocksdb_options_t* db_options, const char* name,
const char* secondary_path, int num_column_families, const char* secondary_path, int num_column_families,
const char* const* column_family_names, const char* const* column_family_names,
const rocksdb_options_t* const* column_family_options, const rocksdb_options_t* const* column_family_options,
rocksdb_column_family_handle_t** column_family_handles, rocksdb_column_family_handle_t** column_family_handles,
rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
std::vector<ColumnFamilyDescriptor> column_families; std::vector<ColumnFamilyDescriptor> column_families;
for (int i = 0; i != num_column_families; ++i) { for (int i = 0; i != num_column_families; ++i) {
column_families.emplace_back( column_families.emplace_back(
std::string(column_family_names[i]), std::string(column_family_names[i]),
ColumnFamilyOptions(column_family_options[i]->rep)); ColumnFamilyOptions(column_family_options[i]->rep));
} }
DB* db; DB* db;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
if (SaveStatus(statusptr, DB::OpenAsSecondary(DBOptions(db_options->rep), if (SaveStatus(statusptr, DB::OpenAsSecondary(
std::string(name), DBOptions(db_options->rep), std::string(name),
std::string(secondary_path), std::string(secondary_path), column_families,
column_families, &handles, &db))) { &handles, &db))) {
return nullptr; return nullptr;
} }
for (size_t i = 0; i != handles.size(); ++i) { for (size_t i = 0; i != handles.size(); ++i) {
rocksdb_column_family_handle_t* c_handle = rocksdb_column_family_handle_t* c_handle =
new rocksdb_column_family_handle_t; new rocksdb_column_family_handle_t;
c_handle->rep = handles[i]; c_handle->rep = handles[i];
column_family_handles[i] = c_handle; column_family_handles[i] = c_handle;
} }
rocksdb_t* result = new rocksdb_t; rocksdb_t* result = new rocksdb_t;
result->rep = db; result->rep = db;
return result; return result;
} }
rocksdb_transactiondb_t* rocksdb_transactiondb_open_column_families_with_status( rocksdb_transactiondb_t* rocksdb_transactiondb_open_column_families_with_status(
const rocksdb_options_t* options, const rocksdb_options_t* options,
const rocksdb_transactiondb_options_t* txn_db_options, const char* name, const rocksdb_transactiondb_options_t* txn_db_options, const char* name,
int num_column_families, const char* const* column_family_names, int num_column_families, const char* const* column_family_names,
const rocksdb_options_t* const* column_family_options, const rocksdb_options_t* const* column_family_options,
rocksdb_column_family_handle_t** column_family_handles, rocksdb_status_t* statusptr) { rocksdb_column_family_handle_t** column_family_handles,
std::vector<ColumnFamilyDescriptor> column_families; rocksdb_status_t* statusptr) {
for (int i = 0; i < num_column_families; i++) { std::vector<ColumnFamilyDescriptor> column_families;
column_families.push_back(ColumnFamilyDescriptor( for (int i = 0; i < num_column_families; i++) {
std::string(column_family_names[i]), column_families.emplace_back(ColumnFamilyDescriptor(
ColumnFamilyOptions(column_family_options[i]->rep))); std::string(column_family_names[i]),
} ColumnFamilyOptions(column_family_options[i]->rep)));
}
TransactionDB* txn_db; TransactionDB* txn_db;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
if (SaveStatus(statusptr, TransactionDB::Open(options->rep, txn_db_options->rep, if (SaveStatus(statusptr,
std::string(name), column_families, TransactionDB::Open(options->rep, txn_db_options->rep,
&handles, &txn_db))) { std::string(name), column_families,
return nullptr; &handles, &txn_db))) {
} return nullptr;
}
for (size_t i = 0; i < handles.size(); i++) { for (size_t i = 0; i < handles.size(); i++) {
rocksdb_column_family_handle_t* c_handle = rocksdb_column_family_handle_t* c_handle =
new rocksdb_column_family_handle_t; new rocksdb_column_family_handle_t;
c_handle->rep = handles[i]; c_handle->rep = handles[i];
column_family_handles[i] = c_handle; column_family_handles[i] = c_handle;
} }
rocksdb_transactiondb_t* result = new rocksdb_transactiondb_t; rocksdb_transactiondb_t* result = new rocksdb_transactiondb_t;
result->rep = txn_db; result->rep = txn_db;
return result; return result;
} }
rocksdb_pinnableslice_t* rocksdb_transactiondb_get_pinned_cf_with_status( rocksdb_pinnableslice_t* rocksdb_transactiondb_get_pinned_cf_with_status(
rocksdb_transactiondb_t* db, const rocksdb_readoptions_t* options, rocksdb_transactiondb_t* db, const rocksdb_readoptions_t* options,
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr) { size_t keylen, rocksdb_status_t* statusptr) {
rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t; rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t;
Status s = db->rep->Get(options->rep, column_family->rep, Slice(key, keylen), Status s = db->rep->Get(options->rep, column_family->rep, Slice(key, keylen),
&v->rep); &v->rep);
if (!s.ok()) { if (!s.ok()) {
delete v; delete v;
if (!s.IsNotFound()) { if (!s.IsNotFound()) {
SaveStatus(statusptr, s); SaveStatus(statusptr, s);
}
return nullptr;
} }
return v; return nullptr;
}
return v;
} }
void rocksdb_transactiondb_put_cf_with_status(rocksdb_transactiondb_t* txn_db, void rocksdb_transactiondb_put_cf_with_status(
const rocksdb_writeoptions_t* options, rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options,
rocksdb_column_family_handle_t* column_family, rocksdb_column_family_handle_t* column_family, const char* key,
const char* key, size_t keylen, size_t keylen, const char* val, size_t vallen,
const char* val, size_t vallen, rocksdb_status_t* statusptr) {
rocksdb_status_t* statusptr) { SaveStatus(statusptr,
SaveStatus(statusptr, txn_db->rep->Put(options->rep, column_family->rep, txn_db->rep->Put(options->rep, column_family->rep,
Slice(key, keylen), Slice(val, vallen))); Slice(key, keylen), Slice(val, vallen)));
} }
void rocksdb_transactiondb_flush_cf_with_status( void rocksdb_transactiondb_flush_cf_with_status(
rocksdb_transactiondb_t* db, rocksdb_transactiondb_t* db, const rocksdb_flushoptions_t* options,
const rocksdb_flushoptions_t* options, rocksdb_column_family_handle_t* column_family,
rocksdb_column_family_handle_t* column_family, rocksdb_status_t* statusptr) {
rocksdb_status_t* statusptr) { SaveStatus(statusptr, db->rep->Flush(options->rep, column_family->rep));
SaveStatus(statusptr, db->rep->Flush(options->rep, column_family->rep));
} }
void rocksdb_transactiondb_compact_range_cf_opt_with_status(rocksdb_transactiondb_t* db, void rocksdb_transactiondb_compact_range_cf_opt_with_status(
rocksdb_column_family_handle_t* column_family, rocksdb_transactiondb_t* db, rocksdb_column_family_handle_t* column_family,
rocksdb_compactoptions_t* opt, rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len,
const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, rocksdb_status_t* statusptr) {
const char* limit_key, size_t limit_key_len, Slice a, b;
rocksdb_status_t* statusptr) { SaveStatus(
Slice a, b; statusptr,
SaveStatus(statusptr, db->rep->CompactRange( db->rep->CompactRange(
opt->rep, column_family->rep, opt->rep, column_family->rep,
// Pass nullptr Slice if corresponding "const char*" is nullptr // Pass nullptr Slice if corresponding "const char*" is nullptr
(start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr), (start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr),
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr))); (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr)));
} }
void rocksdb_transactiondb_ingest_external_files_with_status( void rocksdb_transactiondb_ingest_external_files_with_status(
rocksdb_transactiondb_t* db, const rocksdb_ingestexternalfilearg_t* list, rocksdb_transactiondb_t* db, const rocksdb_ingestexternalfilearg_t* list,
const size_t list_len, rocksdb_status_t* statusptr) { const size_t list_len, rocksdb_status_t* statusptr) {
std::vector<rocksdb::IngestExternalFileArg> args(list_len); std::vector<rocksdb::IngestExternalFileArg> args(list_len);
for (size_t i = 0; i < list_len; ++i) { for (size_t i = 0; i < list_len; ++i) {
args[i].column_family = list[i].column_family->rep; args[i].column_family = list[i].column_family->rep;
std::vector<std::string> files(list[i].external_files_len); std::vector<std::string> files(list[i].external_files_len);
for (size_t j = 0; j < list[i].external_files_len; ++j) { for (size_t j = 0; j < list[i].external_files_len; ++j) {
files[j] = std::string(list[i].external_files[j]); files[j] = std::string(list[i].external_files[j]);
}
args[i].external_files = files;
args[i].options = list[i].options->rep;
} }
SaveStatus(statusptr, db->rep->IngestExternalFiles(args)); args[i].external_files = files;
args[i].options = list[i].options->rep;
}
SaveStatus(statusptr, db->rep->IngestExternalFiles(args));
} }
void rocksdb_transactiondb_create_checkpoint_with_status( void rocksdb_transactiondb_create_checkpoint_with_status(
rocksdb_transactiondb_t* db, const char* checkpoint_dir, rocksdb_transactiondb_t* db, const char* checkpoint_dir,
rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
Checkpoint* checkpoint; Checkpoint* checkpoint;
Status s = Checkpoint::Create(db->rep, &checkpoint); Status s = Checkpoint::Create(db->rep, &checkpoint);
if (!s.ok()) { if (!s.ok()) {
SaveStatus(statusptr, s); SaveStatus(statusptr, s);
return; return;
} }
SaveStatus(statusptr, checkpoint->CreateCheckpoint(std::string(checkpoint_dir))); SaveStatus(statusptr,
delete checkpoint; checkpoint->CreateCheckpoint(std::string(checkpoint_dir)));
delete checkpoint;
} }
void rocksdb_transaction_commit_with_status(rocksdb_transaction_t* txn,
void rocksdb_transaction_commit_with_status(rocksdb_transaction_t* txn, rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
SaveStatus(statusptr, txn->rep->Commit()); SaveStatus(statusptr, txn->rep->Commit());
} }
void rocksdb_transaction_rollback_with_status(rocksdb_transaction_t* txn, rocksdb_status_t* statusptr) { void rocksdb_transaction_rollback_with_status(rocksdb_transaction_t* txn,
SaveStatus(statusptr, txn->rep->Rollback()); rocksdb_status_t* statusptr) {
SaveStatus(statusptr, txn->rep->Rollback());
} }
rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_cf_with_status( rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_cf_with_status(
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr) { size_t keylen, rocksdb_status_t* statusptr) {
rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t; rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t;
Status s = txn->rep->Get(options->rep, column_family->rep, Slice(key, keylen), Status s = txn->rep->Get(options->rep, column_family->rep, Slice(key, keylen),
&v->rep); &v->rep);
if (!s.ok()) { if (!s.ok()) {
delete v; delete v;
if (!s.IsNotFound()) { if (!s.IsNotFound()) {
SaveStatus(statusptr, s); SaveStatus(statusptr, s);
}
return nullptr;
} }
return v; return nullptr;
}
return v;
} }
rocksdb_pinnableslice_t* rocksdb_transaction_get_for_update_pinned_cf_with_status( rocksdb_pinnableslice_t*
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_transaction_get_for_update_pinned_cf_with_status(
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
size_t keylen, rocksdb_status_t* statusptr) { rocksdb_column_family_handle_t* column_family, const char* key,
rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t; size_t keylen, rocksdb_status_t* statusptr) {
Status s = txn->rep->GetForUpdate(options->rep, column_family->rep, Slice(key, keylen), rocksdb_pinnableslice_t* v = new rocksdb_pinnableslice_t;
&v->rep); Status s = txn->rep->GetForUpdate(options->rep, column_family->rep,
if (!s.ok()) { Slice(key, keylen), &v->rep);
delete v; if (!s.ok()) {
if (!s.IsNotFound()) { delete v;
SaveStatus(statusptr, s); if (!s.IsNotFound()) {
} SaveStatus(statusptr, s);
return nullptr;
} }
return v; return nullptr;
}
return v;
} }
void rocksdb_transaction_put_cf_with_status(rocksdb_transaction_t* txn, void rocksdb_transaction_put_cf_with_status(
rocksdb_column_family_handle_t* column_family, rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family,
const char* key, size_t klen, const char* val, const char* key, size_t klen, const char* val, size_t vlen,
size_t vlen, rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
SaveStatus(statusptr, txn->rep->Put(column_family->rep, Slice(key, klen), SaveStatus(statusptr, txn->rep->Put(column_family->rep, Slice(key, klen),
Slice(val, vlen))); Slice(val, vlen)));
} }
void rocksdb_transaction_delete_cf_with_status( void rocksdb_transaction_delete_cf_with_status(
rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family,
const char* key, size_t klen, rocksdb_status_t* statusptr) { const char* key, size_t klen, rocksdb_status_t* statusptr) {
SaveStatus(statusptr, txn->rep->Delete(column_family->rep, Slice(key, klen))); SaveStatus(statusptr, txn->rep->Delete(column_family->rep, Slice(key, klen)));
} }
void rocksdb_sstfilewriter_open_with_status(rocksdb_sstfilewriter_t* writer, void rocksdb_sstfilewriter_open_with_status(rocksdb_sstfilewriter_t* writer,
const char* name, rocksdb_status_t* statusptr) { const char* name,
SaveStatus(statusptr, writer->rep->Open(std::string(name))); rocksdb_status_t* statusptr) {
SaveStatus(statusptr, writer->rep->Open(std::string(name)));
} }
void rocksdb_sstfilewriter_put_with_status(rocksdb_sstfilewriter_t* writer,
void rocksdb_sstfilewriter_put_with_status(rocksdb_sstfilewriter_t* writer, const char* key, const char* key, size_t keylen,
size_t keylen, const char* val, size_t vallen, const char* val, size_t vallen,
rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
SaveStatus(statusptr, writer->rep->Put(Slice(key, keylen), Slice(val, vallen))); SaveStatus(statusptr,
writer->rep->Put(Slice(key, keylen), Slice(val, vallen)));
} }
void rocksdb_sstfilewriter_finish_with_status(rocksdb_sstfilewriter_t* writer, void rocksdb_sstfilewriter_finish_with_status(rocksdb_sstfilewriter_t* writer,
rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
SaveStatus(statusptr, writer->rep->Finish(nullptr)); SaveStatus(statusptr, writer->rep->Finish(nullptr));
} }
void rocksdb_iter_get_status(const rocksdb_iterator_t* iter,
void rocksdb_iter_get_status(const rocksdb_iterator_t* iter, rocksdb_status_t* statusptr) { rocksdb_status_t* statusptr) {
SaveStatus(statusptr, iter->rep->status()); SaveStatus(statusptr, iter->rep->status());
} }
rocksdb_readoptions_t* rocksdb_readoptions_create_copy(
rocksdb_readoptions_t* rocksdb_readoptions_create_copy(rocksdb_readoptions_t* options) { rocksdb_readoptions_t* options) {
return new rocksdb_readoptions_t(*options); return new rocksdb_readoptions_t(*options);
} }
} }

@ -7,62 +7,62 @@ extern "C" {
#endif #endif
typedef enum rocksdb_status_code_t { typedef enum rocksdb_status_code_t {
rocksdb_status_code_ok = 0, rocksdb_status_code_ok = 0,
rocksdb_status_code_not_found = 1, rocksdb_status_code_not_found = 1,
rocksdb_status_code_corruption = 2, rocksdb_status_code_corruption = 2,
rocksdb_status_code_not_supported = 3, rocksdb_status_code_not_supported = 3,
rocksdb_status_code_invalid_argument = 4, rocksdb_status_code_invalid_argument = 4,
rocksdb_status_code_io_error = 5, rocksdb_status_code_io_error = 5,
rocksdb_status_code_merge_in_progress = 6, rocksdb_status_code_merge_in_progress = 6,
rocksdb_status_code_incomplete = 7, rocksdb_status_code_incomplete = 7,
rocksdb_status_code_shutdown_in_progress = 8, rocksdb_status_code_shutdown_in_progress = 8,
rocksdb_status_code_timed_out = 9, rocksdb_status_code_timed_out = 9,
rocksdb_status_code_aborted = 10, rocksdb_status_code_aborted = 10,
rocksdb_status_code_busy = 11, rocksdb_status_code_busy = 11,
rocksdb_status_code_expired = 12, rocksdb_status_code_expired = 12,
rocksdb_status_code_try_again = 13, rocksdb_status_code_try_again = 13,
rocksdb_status_code_compaction_too_large = 14, rocksdb_status_code_compaction_too_large = 14,
rocksdb_status_code_column_family_dropped = 15, rocksdb_status_code_column_family_dropped = 15,
} rocksdb_status_code_t; } rocksdb_status_code_t;
typedef enum rocksdb_status_subcode_t { typedef enum rocksdb_status_subcode_t {
rocksdb_status_subcode_none = 0, rocksdb_status_subcode_none = 0,
rocksdb_status_subcode_mutex_timeout = 1, rocksdb_status_subcode_mutex_timeout = 1,
rocksdb_status_subcode_lock_timeout = 2, rocksdb_status_subcode_lock_timeout = 2,
rocksdb_status_subcode_lock_limit = 3, rocksdb_status_subcode_lock_limit = 3,
rocksdb_status_subcode_no_space = 4, rocksdb_status_subcode_no_space = 4,
rocksdb_status_subcode_deadlock = 5, rocksdb_status_subcode_deadlock = 5,
rocksdb_status_subcode_stale_file = 6, rocksdb_status_subcode_stale_file = 6,
rocksdb_status_subcode_memory_limit = 7, rocksdb_status_subcode_memory_limit = 7,
rocksdb_status_subcode_space_limit = 8, rocksdb_status_subcode_space_limit = 8,
rocksdb_status_subcode_path_not_found = 9, rocksdb_status_subcode_path_not_found = 9,
rocksdb_status_subcode_merge_operands_insufficient_capacity = 10, rocksdb_status_subcode_merge_operands_insufficient_capacity = 10,
rocksdb_status_subcode_manual_compaction_paused = 11, rocksdb_status_subcode_manual_compaction_paused = 11,
rocksdb_status_subcode_overwritten = 12, rocksdb_status_subcode_overwritten = 12,
rocksdb_status_subcode_txn_not_prepared = 13, rocksdb_status_subcode_txn_not_prepared = 13,
rocksdb_status_subcode_io_fenced = 14, rocksdb_status_subcode_io_fenced = 14,
} rocksdb_status_subcode_t; } rocksdb_status_subcode_t;
typedef enum rocksdb_status_severity_t { typedef enum rocksdb_status_severity_t {
rocksdb_status_severity_none = 0, rocksdb_status_severity_none = 0,
rocksdb_status_severity_soft_error = 1, rocksdb_status_severity_soft_error = 1,
rocksdb_status_severity_hard_error = 2, rocksdb_status_severity_hard_error = 2,
rocksdb_status_severity_fatal_error = 3, rocksdb_status_severity_fatal_error = 3,
rocksdb_status_severity_unrecoverable_error = 4, rocksdb_status_severity_unrecoverable_error = 4,
} rocksdb_status_severity_t; } rocksdb_status_severity_t;
typedef struct rocksdb_status_t { typedef struct rocksdb_status_t {
rocksdb_status_code_t code; rocksdb_status_code_t code;
rocksdb_status_subcode_t subcode; rocksdb_status_subcode_t subcode;
rocksdb_status_severity_t severity; rocksdb_status_severity_t severity;
const char* string; const char* string;
} rocksdb_status_t; } rocksdb_status_t;
typedef struct rocksdb_ingestexternalfilearg_t { typedef struct rocksdb_ingestexternalfilearg_t {
rocksdb_column_family_handle_t* column_family; rocksdb_column_family_handle_t* column_family;
char const* const* external_files; char const* const* external_files;
size_t external_files_len; size_t external_files_len;
rocksdb_ingestexternalfileoptions_t* options; rocksdb_ingestexternalfileoptions_t* options;
} rocksdb_ingestexternalfilearg_t; } rocksdb_ingestexternalfilearg_t;
rocksdb_pinnableslice_t* rocksdb_get_pinned_cf_with_status( rocksdb_pinnableslice_t* rocksdb_get_pinned_cf_with_status(
@ -70,9 +70,8 @@ rocksdb_pinnableslice_t* rocksdb_get_pinned_cf_with_status(
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr); size_t keylen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_t*
rocksdb_open_for_read_only_column_families_with_status(
extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_for_read_only_column_families_with_status(
const rocksdb_options_t* db_options, const char* name, const rocksdb_options_t* db_options, const char* name,
int num_column_families, const char* const* column_family_names, int num_column_families, const char* const* column_family_names,
const rocksdb_options_t* const* column_family_options, const rocksdb_options_t* const* column_family_options,
@ -80,93 +79,100 @@ extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_for_read_only_column_families
unsigned char error_if_wal_file_exists, rocksdb_status_t* statusptr); unsigned char error_if_wal_file_exists, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_try_catch_up_with_primary_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_try_catch_up_with_primary_with_status(
rocksdb_t* db, rocksdb_status_t* statusptr); rocksdb_t* db, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_as_secondary_column_families_with_status(
const rocksdb_options_t* options, const char* name,
const char* secondary_path, int num_column_families,
const char* const* column_family_names,
const rocksdb_options_t* const* column_family_options,
rocksdb_column_family_handle_t** column_family_handles,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_t* rocksdb_transactiondb_open_column_families_with_status( extern ROCKSDB_LIBRARY_API rocksdb_t*
const rocksdb_options_t* options, rocksdb_open_as_secondary_column_families_with_status(
const rocksdb_transactiondb_options_t* txn_db_options, const char* name, const rocksdb_options_t* options, const char* name,
int num_column_families, const char* const* column_family_names, const char* secondary_path, int num_column_families,
const rocksdb_options_t* const* column_family_options, const char* const* column_family_names,
rocksdb_column_family_handle_t** column_family_handles, rocksdb_status_t* statusptr); const rocksdb_options_t* const* column_family_options,
rocksdb_column_family_handle_t** column_family_handles,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_t*
rocksdb_transactiondb_open_column_families_with_status(
const rocksdb_options_t* options,
const rocksdb_transactiondb_options_t* txn_db_options, const char* name,
int num_column_families, const char* const* column_family_names,
const rocksdb_options_t* const* column_family_options,
rocksdb_column_family_handle_t** column_family_handles,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_transactiondb_get_pinned_cf_with_status( extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t*
rocksdb_transactiondb_t* db, const rocksdb_readoptions_t* options, rocksdb_transactiondb_get_pinned_cf_with_status(
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_transactiondb_t* db, const rocksdb_readoptions_t* options,
size_t keylen, rocksdb_status_t* statusptr); rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put_cf_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put_cf_with_status(
rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options,
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, const char* val, size_t vallen, rocksdb_status_t* statusptr); size_t keylen, const char* val, size_t vallen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush_cf_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush_cf_with_status(
rocksdb_transactiondb_t* db, const rocksdb_flushoptions_t* options, rocksdb_transactiondb_t* db, const rocksdb_flushoptions_t* options,
rocksdb_column_family_handle_t* column_family, rocksdb_status_t* statusptr); rocksdb_column_family_handle_t* column_family, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_compact_range_cf_opt_with_status(
rocksdb_transactiondb_t* db, rocksdb_column_family_handle_t* column_family,
rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len,
const char* limit_key, size_t limit_key_len, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_ingest_external_files_with_status( extern ROCKSDB_LIBRARY_API void
rocksdb_transactiondb_t* db, const rocksdb_ingestexternalfilearg_t* list, rocksdb_transactiondb_compact_range_cf_opt_with_status(
const size_t list_len, rocksdb_status_t* statusptr); rocksdb_transactiondb_t* db, rocksdb_column_family_handle_t* column_family,
rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len,
const char* limit_key, size_t limit_key_len, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_create_checkpoint_with_status( extern ROCKSDB_LIBRARY_API void
rocksdb_transactiondb_t* db, const char* checkpoint_dir, rocksdb_status_t* statusptr); rocksdb_transactiondb_ingest_external_files_with_status(
rocksdb_transactiondb_t* db, const rocksdb_ingestexternalfilearg_t* list,
const size_t list_len, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void
rocksdb_transactiondb_create_checkpoint_with_status(
rocksdb_transactiondb_t* db, const char* checkpoint_dir,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transaction_commit_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transaction_commit_with_status(
rocksdb_transaction_t* txn, rocksdb_status_t* statusptr); rocksdb_transaction_t* txn, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback_with_status(
rocksdb_transaction_t* txn, rocksdb_status_t* statusptr); rocksdb_transaction_t* txn, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_cf_with_status( extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t*
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_transaction_get_pinned_cf_with_status(
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
size_t keylen, rocksdb_status_t* statusptr); rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_transaction_get_for_update_pinned_cf_with_status( extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t*
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_transaction_get_for_update_pinned_cf_with_status(
rocksdb_column_family_handle_t* column_family, const char* key, rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
size_t keylen, rocksdb_status_t* statusptr); rocksdb_column_family_handle_t* column_family, const char* key,
size_t keylen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put_cf_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put_cf_with_status(
rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family,
const char* key, size_t klen, const char* val, size_t vlen, rocksdb_status_t* statusptr); const char* key, size_t klen, const char* val, size_t vlen,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete_cf_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete_cf_with_status(
rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family,
const char* key, size_t klen, rocksdb_status_t* statusptr); const char* key, size_t klen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_open_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_open_with_status(
rocksdb_sstfilewriter_t* writer, const char* name, rocksdb_status_t* statusptr); rocksdb_sstfilewriter_t* writer, const char* name,
rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_put_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_put_with_status(
rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen,
const char* val, size_t vallen, rocksdb_status_t* statusptr); const char* val, size_t vallen, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_finish_with_status( extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_finish_with_status(
rocksdb_sstfilewriter_t* writer, rocksdb_status_t* statusptr); rocksdb_sstfilewriter_t* writer, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API void rocksdb_iter_get_status( extern ROCKSDB_LIBRARY_API void rocksdb_iter_get_status(
const rocksdb_iterator_t*, rocksdb_status_t* statusptr); const rocksdb_iterator_t*, rocksdb_status_t* statusptr);
extern ROCKSDB_LIBRARY_API rocksdb_readoptions_t* rocksdb_readoptions_create_copy( extern ROCKSDB_LIBRARY_API rocksdb_readoptions_t*
rocksdb_readoptions_t*); rocksdb_readoptions_create_copy(rocksdb_readoptions_t*);
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save