@ -21,23 +21,23 @@
# include "rocksdb/env.h"
# include "rocksdb/env.h"
# include "rocksdb/filter_policy.h"
# include "rocksdb/filter_policy.h"
# include "rocksdb/iterator.h"
# include "rocksdb/iterator.h"
# include "rocksdb/memtablerep.h"
# include "rocksdb/merge_operator.h"
# include "rocksdb/merge_operator.h"
# include "rocksdb/options.h"
# include "rocksdb/options.h"
# include "rocksdb/status.h"
# include "rocksdb/rate_limiter.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/slice_transform.h"
# include "rocksdb/statistics.h"
# include "rocksdb/status.h"
# include "rocksdb/table.h"
# include "rocksdb/table.h"
# include "rocksdb/rate_limiter.h"
# include "rocksdb/universal_compaction .h"
# include "rocksdb/utilities/backupable_db.h"
# include "rocksdb/utilities/backupable_db.h"
# include "rocksdb/utilities/write_batch_with_index .h"
# include "rocksdb/utilities/checkpoint .h"
# include "utilities/merge_operators .h"
# include "rocksdb/utilities/optimistic_transaction_db .h"
# include "rocksdb/utilities/transaction.h"
# include "rocksdb/utilities/transaction.h"
# include "rocksdb/utilities/transaction_db.h"
# include "rocksdb/utilities/transaction_db.h"
# include "rocksdb/utilities/optimistic_transaction_db.h"
# include "rocksdb/utilities/write_batch_with_index.h"
# include "rocksdb/utilities/checkpoint.h"
# include "rocksdb/write_batch.h"
# include "utilities/merge_operators.h"
using rocksdb : : BytewiseComparator ;
using rocksdb : : BytewiseComparator ;
using rocksdb : : Cache ;
using rocksdb : : Cache ;
@ -2111,7 +2111,8 @@ void rocksdb_options_enable_statistics(rocksdb_options_t* opt) {
opt - > rep . statistics = rocksdb : : CreateDBStatistics ( ) ;
opt - > rep . statistics = rocksdb : : CreateDBStatistics ( ) ;
}
}
void rocksdb_options_set_skip_stats_update_on_db_open ( rocksdb_options_t * opt , unsigned char val ) {
void rocksdb_options_set_skip_stats_update_on_db_open ( rocksdb_options_t * opt ,
unsigned char val ) {
opt - > rep . skip_stats_update_on_db_open = val ;
opt - > rep . skip_stats_update_on_db_open = val ;
}
}
@ -3476,8 +3477,8 @@ void rocksdb_transactiondb_put(rocksdb_transactiondb_t* txn_db,
const rocksdb_writeoptions_t * options ,
const rocksdb_writeoptions_t * options ,
const char * key , size_t klen , const char * val ,
const char * key , size_t klen , const char * val ,
size_t vlen , char * * errptr ) {
size_t vlen , char * * errptr ) {
SaveError ( errptr , txn_db - > rep - > Put ( options - > rep , Slice ( key , klen ) ,
SaveError ( errptr ,
Slice ( val , vlen ) ) ) ;
txn_db - > rep - > Put ( options - > rep , Slice ( key , klen ) , Slice ( val , vlen ) ) ) ;
}
}
void rocksdb_transactiondb_put_cf ( rocksdb_transactiondb_t * txn_db ,
void rocksdb_transactiondb_put_cf ( rocksdb_transactiondb_t * txn_db ,
@ -3511,8 +3512,8 @@ void rocksdb_transactiondb_merge(rocksdb_transactiondb_t* txn_db,
const rocksdb_writeoptions_t * options ,
const rocksdb_writeoptions_t * options ,
const char * key , size_t klen , const char * val ,
const char * key , size_t klen , const char * val ,
size_t vlen , char * * errptr ) {
size_t vlen , char * * errptr ) {
SaveError ( errptr ,
SaveError ( errptr , txn_db - > rep - > Merge ( options - > rep , Slice ( key , klen ) ,
txn_db - > rep - > Merge ( options - > rep , Slice ( key , klen ) , Slice ( val , vlen ) ) ) ;
Slice ( val , vlen ) ) ) ;
}
}
// Delete a key inside a transaction
// Delete a key inside a transaction
@ -3550,6 +3551,15 @@ rocksdb_iterator_t* rocksdb_transaction_create_iterator(
return result ;
return result ;
}
}
// Create an iterator inside a transaction with column family
rocksdb_iterator_t * rocksdb_transaction_create_iterator_cf (
rocksdb_transaction_t * txn , const rocksdb_readoptions_t * options ,
rocksdb_column_family_handle_t * column_family ) {
rocksdb_iterator_t * result = new rocksdb_iterator_t ;
result - > rep = txn - > rep - > GetIterator ( options - > rep , column_family - > rep ) ;
return result ;
}
// Create an iterator outside a transaction
// Create an iterator outside a transaction
rocksdb_iterator_t * rocksdb_transactiondb_create_iterator (
rocksdb_iterator_t * rocksdb_transactiondb_create_iterator (
rocksdb_transactiondb_t * txn_db , const rocksdb_readoptions_t * options ) {
rocksdb_transactiondb_t * txn_db , const rocksdb_readoptions_t * options ) {
@ -3575,8 +3585,7 @@ rocksdb_checkpoint_t* rocksdb_transactiondb_checkpoint_object_create(
}
}
rocksdb_optimistictransactiondb_t * rocksdb_optimistictransactiondb_open (
rocksdb_optimistictransactiondb_t * rocksdb_optimistictransactiondb_open (
const rocksdb_options_t * options , const char * name ,
const rocksdb_options_t * options , const char * name , char * * errptr ) {
char * * errptr ) {
OptimisticTransactionDB * otxn_db ;
OptimisticTransactionDB * otxn_db ;
if ( SaveError ( errptr , OptimisticTransactionDB : : Open (
if ( SaveError ( errptr , OptimisticTransactionDB : : Open (
options - > rep , std : : string ( name ) , & otxn_db ) ) ) {
options - > rep , std : : string ( name ) , & otxn_db ) ) ) {
@ -3588,6 +3597,56 @@ rocksdb_optimistictransactiondb_t* rocksdb_optimistictransactiondb_open(
return result ;
return result ;
}
}
rocksdb_optimistictransactiondb_t *
rocksdb_optimistictransactiondb_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 ) ) ) ;
}
OptimisticTransactionDB * otxn_db ;
std : : vector < ColumnFamilyHandle * > handles ;
if ( SaveError ( errptr , OptimisticTransactionDB : : Open (
DBOptions ( db_options - > rep ) , std : : string ( name ) ,
column_families , & handles , & otxn_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_optimistictransactiondb_t * result =
new rocksdb_optimistictransactiondb_t ;
result - > rep = otxn_db ;
return result ;
}
rocksdb_t * rocksdb_optimistictransactiondb_get_base_db (
rocksdb_optimistictransactiondb_t * otxn_db ) {
DB * base_db = otxn_db - > rep - > GetBaseDB ( ) ;
if ( base_db ! = nullptr ) {
rocksdb_t * result = new rocksdb_t ;
result - > rep = base_db ;
return result ;
}
return nullptr ;
}
void rocksdb_optimistictransactiondb_close_base_db ( rocksdb_t * base_db ) {
delete base_db ;
}
rocksdb_transaction_t * rocksdb_optimistictransaction_begin (
rocksdb_transaction_t * rocksdb_optimistictransaction_begin (
rocksdb_optimistictransactiondb_t * otxn_db ,
rocksdb_optimistictransactiondb_t * otxn_db ,
const rocksdb_writeoptions_t * write_options ,
const rocksdb_writeoptions_t * write_options ,