@ -49,7 +49,7 @@ static void StartPhase(const char* name) {
}
}
# ifdef _MSC_VER
# ifdef _MSC_VER
# pragma warning(push)
# pragma warning(push)
# pragma warning (disable: 4996) // getenv security warning
# pragma warning(disable : 4996) // getenv security warning
# endif
# endif
static const char * GetTempDir ( void ) {
static const char * GetTempDir ( void ) {
const char * ret = getenv ( " TEST_TMPDIR " ) ;
const char * ret = getenv ( " TEST_TMPDIR " ) ;
@ -98,21 +98,15 @@ static void Free(char** ptr) {
}
}
}
}
static void CheckValue (
static void CheckValue ( char * err , const char * expected , char * * actual ,
char * err ,
const char * expected ,
char * * actual ,
size_t actual_length ) {
size_t actual_length ) {
CheckNoError ( err ) ;
CheckNoError ( err ) ;
CheckEqual ( expected , * actual , actual_length ) ;
CheckEqual ( expected , * actual , actual_length ) ;
Free ( actual ) ;
Free ( actual ) ;
}
}
static void CheckGet (
static void CheckGet ( rocksdb_t * db , const rocksdb_readoptions_t * options ,
rocksdb_t * db ,
const char * key , const char * expected ) {
const rocksdb_readoptions_t * options ,
const char * key ,
const char * expected ) {
char * err = NULL ;
char * err = NULL ;
size_t val_len ;
size_t val_len ;
char * val ;
char * val ;
@ -122,11 +116,8 @@ static void CheckGet(
Free ( & val ) ;
Free ( & val ) ;
}
}
static void CheckGetCF (
static void CheckGetCF ( rocksdb_t * db , const rocksdb_readoptions_t * options ,
rocksdb_t * db ,
rocksdb_column_family_handle_t * handle , const char * key ,
const rocksdb_readoptions_t * options ,
rocksdb_column_family_handle_t * handle ,
const char * key ,
const char * expected ) {
const char * expected ) {
char * err = NULL ;
char * err = NULL ;
size_t val_len ;
size_t val_len ;
@ -174,8 +165,8 @@ static void CheckMultiGetValues(size_t num_keys, char** values,
}
}
}
}
static void CheckIter ( rocksdb_iterator_t * iter ,
static void CheckIter ( rocksdb_iterator_t * iter , const char * key ,
const char * key , const char * val ) {
const char * val ) {
size_t len ;
size_t len ;
const char * str ;
const char * str ;
str = rocksdb_iter_key ( iter , & len ) ;
str = rocksdb_iter_key ( iter , & len ) ;
@ -185,10 +176,9 @@ static void CheckIter(rocksdb_iterator_t* iter,
}
}
// Callback from rocksdb_writebatch_iterate()
// Callback from rocksdb_writebatch_iterate()
static void CheckPut ( void * ptr ,
static void CheckPut ( void * ptr , const char * k , size_t klen , const char * v ,
const char * k , size_t klen ,
size_t vlen ) {
const char * v , size_t vlen ) {
int * state = ( int * ) ptr ;
int * state = ( int * ) ptr ;
CheckCondition ( * state < 2 ) ;
CheckCondition ( * state < 2 ) ;
switch ( * state ) {
switch ( * state ) {
case 0 :
case 0 :
@ -205,7 +195,7 @@ static void CheckPut(void* ptr,
// Callback from rocksdb_writebatch_iterate()
// Callback from rocksdb_writebatch_iterate()
static void CheckDel ( void * ptr , const char * k , size_t klen ) {
static void CheckDel ( void * ptr , const char * k , size_t klen ) {
int * state = ( int * ) ptr ;
int * state = ( int * ) ptr ;
CheckCondition ( * state = = 2 ) ;
CheckCondition ( * state = = 2 ) ;
CheckEqual ( " bar " , k , klen ) ;
CheckEqual ( " bar " , k , klen ) ;
( * state ) + + ;
( * state ) + + ;
@ -213,14 +203,16 @@ static void CheckDel(void* ptr, const char* k, size_t klen) {
static void CmpDestroy ( void * arg ) { ( void ) arg ; }
static void CmpDestroy ( void * arg ) { ( void ) arg ; }
static int CmpCompare ( void * arg , const char * a , size_t alen ,
static int CmpCompare ( void * arg , const char * a , size_t alen , const char * b ,
const char * b , size_t blen ) {
size_t blen ) {
( void ) arg ;
( void ) arg ;
size_t n = ( alen < blen ) ? alen : blen ;
size_t n = ( alen < blen ) ? alen : blen ;
int r = memcmp ( a , b , n ) ;
int r = memcmp ( a , b , n ) ;
if ( r = = 0 ) {
if ( r = = 0 ) {
if ( alen < blen ) r = - 1 ;
if ( alen < blen )
else if ( alen > blen ) r = + 1 ;
r = - 1 ;
else if ( alen > blen )
r = + 1 ;
}
}
return r ;
return r ;
}
}
@ -405,11 +397,9 @@ static const char* MergeOperatorName(void* arg) {
return " TestMergeOperator " ;
return " TestMergeOperator " ;
}
}
static char * MergeOperatorFullMerge (
static char * MergeOperatorFullMerge (
void * arg ,
void * arg , const char * key , size_t key_length , const char * existing_value ,
const char * key , size_t key_length ,
size_t existing_value_length , const char * const * operands_list ,
const char * existing_value , size_t existing_value_length ,
const size_t * operands_list_length , int num_operands ,
const char * const * operands_list , const size_t * operands_list_length ,
int num_operands ,
unsigned char * success , size_t * new_value_length ) {
unsigned char * success , size_t * new_value_length ) {
( void ) arg ;
( void ) arg ;
( void ) key ;
( void ) key ;
@ -425,12 +415,12 @@ static char* MergeOperatorFullMerge(
memcpy ( result , " fake " , 4 ) ;
memcpy ( result , " fake " , 4 ) ;
return result ;
return result ;
}
}
static char * MergeOperatorPartialMerge (
static char * MergeOperatorPartialMerge ( void * arg , const char * key ,
void * arg ,
size_t key_length ,
const char * key , size_t key_length ,
const char * const * operands_list ,
const char * const * operands_list , const size_t * operands_list_length ,
const size_t * operands_list_length ,
int num_operands ,
int num_operands , unsigned char * succes s ,
unsigned char * success , size_t * new_value_length ) {
size_t * new_value_length ) {
( void ) arg ;
( void ) arg ;
( void ) key ;
( void ) key ;
( void ) key_length ;
( void ) key_length ;
@ -444,10 +434,8 @@ static char* MergeOperatorPartialMerge(
return result ;
return result ;
}
}
static void CheckTxnGet (
static void CheckTxnGet ( rocksdb_transaction_t * txn ,
rocksdb_transaction_t * txn ,
const rocksdb_readoptions_t * options , const char * key ,
const rocksdb_readoptions_t * options ,
const char * key ,
const char * expected ) {
const char * expected ) {
char * err = NULL ;
char * err = NULL ;
size_t val_len ;
size_t val_len ;
@ -502,10 +490,8 @@ static void CheckTxnPinGetCF(rocksdb_transaction_t* txn,
rocksdb_pinnableslice_destroy ( p ) ;
rocksdb_pinnableslice_destroy ( p ) ;
}
}
static void CheckTxnDBGet (
static void CheckTxnDBGet ( rocksdb_transactiondb_t * txn_db ,
rocksdb_transactiondb_t * txn_db ,
const rocksdb_readoptions_t * options , const char * key ,
const rocksdb_readoptions_t * options ,
const char * key ,
const char * expected ) {
const char * expected ) {
char * err = NULL ;
char * err = NULL ;
size_t val_len ;
size_t val_len ;
@ -632,7 +618,7 @@ int main(int argc, char** argv) {
rocksdb_t * db ;
rocksdb_t * db ;
rocksdb_comparator_t * cmp ;
rocksdb_comparator_t * cmp ;
rocksdb_cache_t * cache ;
rocksdb_cache_t * cache ;
rocksdb_dbpath_t * dbpath ;
rocksdb_dbpath_t * dbpath ;
rocksdb_env_t * env ;
rocksdb_env_t * env ;
rocksdb_options_t * options ;
rocksdb_options_t * options ;
rocksdb_compactoptions_t * coptions ;
rocksdb_compactoptions_t * coptions ;
@ -649,30 +635,20 @@ int main(int argc, char** argv) {
char * err = NULL ;
char * err = NULL ;
int run = - 1 ;
int run = - 1 ;
snprintf ( dbname , sizeof ( dbname ) ,
snprintf ( dbname , sizeof ( dbname ) , " %s/rocksdb_c_test-%d " , GetTempDir ( ) ,
" %s/rocksdb_c_test-%d " ,
( ( int ) geteuid ( ) ) ) ;
GetTempDir ( ) ,
( ( int ) geteuid ( ) ) ) ;
snprintf ( dbbackupname , sizeof ( dbbackupname ) ,
snprintf ( dbbackupname , sizeof ( dbbackupname ) , " %s/rocksdb_c_test-%d-backup " ,
" %s/rocksdb_c_test-%d-backup " ,
GetTempDir ( ) , ( ( int ) geteuid ( ) ) ) ;
GetTempDir ( ) ,
( ( int ) geteuid ( ) ) ) ;
snprintf ( dbcheckpointname , sizeof ( dbcheckpointname ) ,
snprintf ( dbcheckpointname , sizeof ( dbcheckpointname ) ,
" %s/rocksdb_c_test-%d-checkpoint " ,
" %s/rocksdb_c_test-%d-checkpoint " , GetTempDir ( ) , ( ( int ) geteuid ( ) ) ) ;
GetTempDir ( ) ,
( ( int ) geteuid ( ) ) ) ;
snprintf ( sstfilename , sizeof ( sstfilename ) ,
snprintf ( sstfilename , sizeof ( sstfilename ) , " %s/rocksdb_c_test-%d-sst " ,
" %s/rocksdb_c_test-%d-sst " ,
GetTempDir ( ) , ( ( int ) geteuid ( ) ) ) ;
GetTempDir ( ) ,
( ( int ) geteuid ( ) ) ) ;
snprintf ( dbpathname , sizeof ( dbpathname ) ,
snprintf ( dbpathname , sizeof ( dbpathname ) , " %s/rocksdb_c_test-%d-dbpath " ,
" %s/rocksdb_c_test-%d-dbpath " ,
GetTempDir ( ) , ( ( int ) geteuid ( ) ) ) ;
GetTempDir ( ) ,
( ( int ) geteuid ( ) ) ) ;
StartPhase ( " create_objects " ) ;
StartPhase ( " create_objects " ) ;
cmp = rocksdb_comparator_create ( NULL , CmpDestroy , CmpCompare , CmpName ) ;
cmp = rocksdb_comparator_create ( NULL , CmpDestroy , CmpCompare , CmpName ) ;
@ -746,7 +722,8 @@ int main(int argc, char** argv) {
rocksdb_destroy_db ( options , dbbackupname , & err ) ;
rocksdb_destroy_db ( options , dbbackupname , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_backup_engine_t * be = rocksdb_backup_engine_open ( options , dbbackupname , & err ) ;
rocksdb_backup_engine_t * be =
rocksdb_backup_engine_open ( options , dbbackupname , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_backup_engine_create_new_backup ( be , db , & err ) ;
rocksdb_backup_engine_create_new_backup ( be , db , & err ) ;
@ -759,7 +736,8 @@ int main(int argc, char** argv) {
rocksdb_backup_engine_create_new_backup ( be , db , & err ) ;
rocksdb_backup_engine_create_new_backup ( be , db , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
const rocksdb_backup_engine_info_t * bei = rocksdb_backup_engine_get_backup_info ( be ) ;
const rocksdb_backup_engine_info_t * bei =
rocksdb_backup_engine_get_backup_info ( be ) ;
CheckCondition ( rocksdb_backup_engine_info_count ( bei ) > 1 ) ;
CheckCondition ( rocksdb_backup_engine_info_count ( bei ) > 1 ) ;
rocksdb_backup_engine_info_destroy ( bei ) ;
rocksdb_backup_engine_info_destroy ( bei ) ;
@ -778,9 +756,11 @@ int main(int argc, char** argv) {
rocksdb_destroy_db ( options , dbname , & err ) ;
rocksdb_destroy_db ( options , dbname , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_restore_options_t * restore_options = rocksdb_restore_options_create ( ) ;
rocksdb_restore_options_t * restore_options =
rocksdb_restore_options_create ( ) ;
rocksdb_restore_options_set_keep_log_files ( restore_options , 0 ) ;
rocksdb_restore_options_set_keep_log_files ( restore_options , 0 ) ;
rocksdb_backup_engine_restore_db_from_latest_backup ( be , dbname , dbname , restore_options , & err ) ;
rocksdb_backup_engine_restore_db_from_latest_backup ( be , dbname , dbname ,
restore_options , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_restore_options_destroy ( restore_options ) ;
rocksdb_restore_options_destroy ( restore_options ) ;
@ -799,7 +779,8 @@ int main(int argc, char** argv) {
rocksdb_destroy_db ( options , dbcheckpointname , & err ) ;
rocksdb_destroy_db ( options , dbcheckpointname , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_checkpoint_t * checkpoint = rocksdb_checkpoint_object_create ( db , & err ) ;
rocksdb_checkpoint_t * checkpoint =
rocksdb_checkpoint_object_create ( db , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_checkpoint_create ( checkpoint , dbcheckpointname , 0 , & err ) ;
rocksdb_checkpoint_create ( checkpoint , dbcheckpointname , 0 , & err ) ;
@ -976,10 +957,10 @@ int main(int argc, char** argv) {
StartPhase ( " writebatch_vectors " ) ;
StartPhase ( " writebatch_vectors " ) ;
{
{
rocksdb_writebatch_t * wb = rocksdb_writebatch_create ( ) ;
rocksdb_writebatch_t * wb = rocksdb_writebatch_create ( ) ;
const char * k_list [ 2 ] = { " z " , " ap " } ;
const char * k_list [ 2 ] = { " z " , " ap " } ;
const size_t k_sizes [ 2 ] = { 1 , 2 } ;
const size_t k_sizes [ 2 ] = { 1 , 2 } ;
const char * v_list [ 3 ] = { " x " , " y " , " z " } ;
const char * v_list [ 3 ] = { " x " , " y " , " z " } ;
const size_t v_sizes [ 3 ] = { 1 , 1 , 1 } ;
const size_t v_sizes [ 3 ] = { 1 , 1 , 1 } ;
rocksdb_writebatch_putv ( wb , 2 , k_list , k_sizes , 3 , v_list , v_sizes ) ;
rocksdb_writebatch_putv ( wb , 2 , k_list , k_sizes , 3 , v_list , v_sizes ) ;
rocksdb_write ( db , woptions , wb , & err ) ;
rocksdb_write ( db , woptions , wb , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
@ -1041,13 +1022,17 @@ int main(int argc, char** argv) {
CheckCondition ( count = = 3 ) ;
CheckCondition ( count = = 3 ) ;
size_t size ;
size_t size ;
char * value ;
char * value ;
value = rocksdb_writebatch_wi_get_from_batch ( wbi , options , " box " , 3 , & size , & err ) ;
value = rocksdb_writebatch_wi_get_from_batch ( wbi , options , " box " , 3 , & size ,
& err ) ;
CheckValue ( err , " c " , & value , size ) ;
CheckValue ( err , " c " , & value , size ) ;
value = rocksdb_writebatch_wi_get_from_batch ( wbi , options , " bar " , 3 , & size , & err ) ;
value = rocksdb_writebatch_wi_get_from_batch ( wbi , options , " bar " , 3 , & size ,
& err ) ;
CheckValue ( err , NULL , & value , size ) ;
CheckValue ( err , NULL , & value , size ) ;
value = rocksdb_writebatch_wi_get_from_batch_and_db ( wbi , db , roptions , " foo " , 3 , & size , & err ) ;
value = rocksdb_writebatch_wi_get_from_batch_and_db ( wbi , db , roptions ,
" foo " , 3 , & size , & err ) ;
CheckValue ( err , " hello " , & value , size ) ;
CheckValue ( err , " hello " , & value , size ) ;
value = rocksdb_writebatch_wi_get_from_batch_and_db ( wbi , db , roptions , " box " , 3 , & size , & err ) ;
value = rocksdb_writebatch_wi_get_from_batch_and_db ( wbi , db , roptions ,
" box " , 3 , & size , & err ) ;
CheckValue ( err , " c " , & value , size ) ;
CheckValue ( err , " c " , & value , size ) ;
rocksdb_write_writebatch_wi ( db , woptions , wbi , & err ) ;
rocksdb_write_writebatch_wi ( db , woptions , wbi , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
@ -1064,10 +1049,10 @@ int main(int argc, char** argv) {
StartPhase ( " writebatch_wi_vectors " ) ;
StartPhase ( " writebatch_wi_vectors " ) ;
{
{
rocksdb_writebatch_wi_t * wb = rocksdb_writebatch_wi_create ( 0 , 1 ) ;
rocksdb_writebatch_wi_t * wb = rocksdb_writebatch_wi_create ( 0 , 1 ) ;
const char * k_list [ 2 ] = { " z " , " ap " } ;
const char * k_list [ 2 ] = { " z " , " ap " } ;
const size_t k_sizes [ 2 ] = { 1 , 2 } ;
const size_t k_sizes [ 2 ] = { 1 , 2 } ;
const char * v_list [ 3 ] = { " x " , " y " , " z " } ;
const char * v_list [ 3 ] = { " x " , " y " , " z " } ;
const size_t v_sizes [ 3 ] = { 1 , 1 , 1 } ;
const size_t v_sizes [ 3 ] = { 1 , 1 , 1 } ;
rocksdb_writebatch_wi_putv ( wb , 2 , k_list , k_sizes , 3 , v_list , v_sizes ) ;
rocksdb_writebatch_wi_putv ( wb , 2 , k_list , k_sizes , 3 , v_list , v_sizes ) ;
rocksdb_write_writebatch_wi ( db , woptions , wb , & err ) ;
rocksdb_write_writebatch_wi ( db , woptions , wb , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
@ -1156,13 +1141,14 @@ int main(int argc, char** argv) {
StartPhase ( " multiget " ) ;
StartPhase ( " multiget " ) ;
{
{
const char * keys [ 3 ] = { " box " , " foo " , " notfound " } ;
const char * keys [ 3 ] = { " box " , " foo " , " notfound " } ;
const size_t keys_sizes [ 3 ] = { 3 , 3 , 8 } ;
const size_t keys_sizes [ 3 ] = { 3 , 3 , 8 } ;
char * vals [ 3 ] ;
char * vals [ 3 ] ;
size_t vals_sizes [ 3 ] ;
size_t vals_sizes [ 3 ] ;
char * errs [ 3 ] ;
char * errs [ 3 ] ;
const char * expected [ 3 ] = { " c " , " hello " , NULL } ;
const char * expected [ 3 ] = { " c " , " hello " , NULL } ;
rocksdb_multi_get ( db , roptions , 3 , keys , keys_sizes , vals , vals_sizes , errs ) ;
rocksdb_multi_get ( db , roptions , 3 , keys , keys_sizes , vals , vals_sizes ,
errs ) ;
CheckMultiGetValues ( 3 , vals , vals_sizes , errs , expected ) ;
CheckMultiGetValues ( 3 , vals , vals_sizes , errs , expected ) ;
}
}
@ -1180,10 +1166,10 @@ int main(int argc, char** argv) {
char keybuf [ 100 ] ;
char keybuf [ 100 ] ;
char valbuf [ 100 ] ;
char valbuf [ 100 ] ;
uint64_t sizes [ 2 ] ;
uint64_t sizes [ 2 ] ;
const char * start [ 2 ] = { " a " , " k00000000000000010000 " } ;
const char * start [ 2 ] = { " a " , " k00000000000000010000 " } ;
size_t start_len [ 2 ] = { 1 , 21 } ;
size_t start_len [ 2 ] = { 1 , 21 } ;
const char * limit [ 2 ] = { " k00000000000000010000 " , " z " } ;
const char * limit [ 2 ] = { " k00000000000000010000 " , " z " } ;
size_t limit_len [ 2 ] = { 21 , 1 } ;
size_t limit_len [ 2 ] = { 21 , 1 } ;
rocksdb_writeoptions_set_sync ( woptions , 0 ) ;
rocksdb_writeoptions_set_sync ( woptions , 0 ) ;
for ( i = 0 ; i < n ; i + + ) {
for ( i = 0 ; i < n ; i + + ) {
snprintf ( keybuf , sizeof ( keybuf ) , " k%020d " , i ) ;
snprintf ( keybuf , sizeof ( keybuf ) , " k%020d " , i ) ;
@ -1393,8 +1379,8 @@ int main(int argc, char** argv) {
factory ) ;
factory ) ;
db = CheckCompaction ( db , options_with_filter_factory , roptions , woptions ) ;
db = CheckCompaction ( db , options_with_filter_factory , roptions , woptions ) ;
rocksdb_options_set_compaction_filter_factory (
rocksdb_options_set_compaction_filter_factory ( options_with_filter_factory ,
options_with_filter_factory , NULL ) ;
NULL ) ;
rocksdb_options_destroy ( options_with_filter_factory ) ;
rocksdb_options_destroy ( options_with_filter_factory ) ;
}
}
@ -1449,7 +1435,8 @@ int main(int argc, char** argv) {
rocksdb_close ( db ) ;
rocksdb_close ( db ) ;
size_t cflen ;
size_t cflen ;
char * * column_fams = rocksdb_list_column_families ( db_options , dbname , & cflen , & err ) ;
char * * column_fams =
rocksdb_list_column_families ( db_options , dbname , & cflen , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
CheckEqual ( " default " , column_fams [ 0 ] , 7 ) ;
CheckEqual ( " default " , column_fams [ 0 ] , 7 ) ;
CheckEqual ( " cf1 " , column_fams [ 1 ] , 3 ) ;
CheckEqual ( " cf1 " , column_fams [ 1 ] , 3 ) ;
@ -1465,7 +1452,8 @@ int main(int argc, char** argv) {
LoadAndCheckLatestOptions ( dbname , env , false , cache , NULL , 2 , cf_names ,
LoadAndCheckLatestOptions ( dbname , env , false , cache , NULL , 2 , cf_names ,
NULL ) ;
NULL ) ;
db = rocksdb_open_column_families ( db_options , dbname , 2 , cf_names , cf_opts , handles , & err ) ;
db = rocksdb_open_column_families ( db_options , dbname , 2 , cf_names , cf_opts ,
handles , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_put_cf ( db , woptions , handles [ 1 ] , " foo " , 3 , " hello " , 5 , & err ) ;
rocksdb_put_cf ( db , woptions , handles [ 1 ] , " foo " , 3 , " hello " , 5 , & err ) ;
@ -1483,11 +1471,10 @@ int main(int argc, char** argv) {
& err ) ;
& err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_flushoptions_t * flush_options = rocksdb_flushoptions_create ( ) ;
rocksdb_flushoptions_t * flush_options = rocksdb_flushoptions_create ( ) ;
rocksdb_flushoptions_set_wait ( flush_options , 1 ) ;
rocksdb_flushoptions_set_wait ( flush_options , 1 ) ;
rocksdb_flush_cf ( db , flush_options , handles [ 1 ] , & err ) ;
rocksdb_flush_cf ( db , flush_options , handles [ 1 ] , & err ) ;
CheckNoError ( err )
CheckNoError ( err ) rocksdb_flushoptions_destroy ( flush_options ) ;
rocksdb_flushoptions_destroy ( flush_options ) ;
CheckGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ;
CheckGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ;
CheckPinGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ;
CheckPinGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ;
@ -1524,13 +1511,15 @@ int main(int argc, char** argv) {
rocksdb_flush_wal ( db , 1 , & err ) ;
rocksdb_flush_wal ( db , 1 , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
const char * keys [ 3 ] = { " box " , " box " , " barfooxx " } ;
const char * keys [ 3 ] = { " box " , " box " , " barfooxx " } ;
const rocksdb_column_family_handle_t * get_handles [ 3 ] = { handles [ 0 ] , handles [ 1 ] , handles [ 1 ] } ;
const rocksdb_column_family_handle_t * get_handles [ 3 ] = {
const size_t keys_sizes [ 3 ] = { 3 , 3 , 8 } ;
handles [ 0 ] , handles [ 1 ] , handles [ 1 ] } ;
const size_t keys_sizes [ 3 ] = { 3 , 3 , 8 } ;
char * vals [ 3 ] ;
char * vals [ 3 ] ;
size_t vals_sizes [ 3 ] ;
size_t vals_sizes [ 3 ] ;
char * errs [ 3 ] ;
char * errs [ 3 ] ;
rocksdb_multi_get_cf ( db , roptions , get_handles , 3 , keys , keys_sizes , vals , vals_sizes , errs ) ;
rocksdb_multi_get_cf ( db , roptions , get_handles , 3 , keys , keys_sizes , vals ,
vals_sizes , errs ) ;
int i ;
int i ;
for ( i = 0 ; i < 3 ; i + + ) {
for ( i = 0 ; i < 3 ; i + + ) {
@ -1592,7 +1581,8 @@ int main(int argc, char** argv) {
}
}
}
}
rocksdb_iterator_t * iter = rocksdb_create_iterator_cf ( db , roptions , handles [ 1 ] ) ;
rocksdb_iterator_t * iter =
rocksdb_create_iterator_cf ( db , roptions , handles [ 1 ] ) ;
CheckCondition ( ! rocksdb_iter_valid ( iter ) ) ;
CheckCondition ( ! rocksdb_iter_valid ( iter ) ) ;
rocksdb_iter_seek_to_first ( iter ) ;
rocksdb_iter_seek_to_first ( iter ) ;
CheckCondition ( rocksdb_iter_valid ( iter ) ) ;
CheckCondition ( rocksdb_iter_valid ( iter ) ) ;
@ -1605,9 +1595,11 @@ int main(int argc, char** argv) {
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_iter_destroy ( iter ) ;
rocksdb_iter_destroy ( iter ) ;
rocksdb_column_family_handle_t * iters_cf_handles [ 2 ] = { handles [ 0 ] , handles [ 1 ] } ;
rocksdb_column_family_handle_t * iters_cf_handles [ 2 ] = { handles [ 0 ] ,
handles [ 1 ] } ;
rocksdb_iterator_t * iters_handles [ 2 ] ;
rocksdb_iterator_t * iters_handles [ 2 ] ;
rocksdb_create_iterators ( db , roptions , iters_cf_handles , iters_handles , 2 , & err ) ;
rocksdb_create_iterators ( db , roptions , iters_cf_handles , iters_handles , 2 ,
& err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
iter = iters_handles [ 0 ] ;
iter = iters_handles [ 0 ] ;
@ -1652,7 +1644,8 @@ int main(int argc, char** argv) {
{
{
// Create new database
// Create new database
rocksdb_options_set_allow_mmap_reads ( options , 1 ) ;
rocksdb_options_set_allow_mmap_reads ( options , 1 ) ;
rocksdb_options_set_prefix_extractor ( options , rocksdb_slicetransform_create_fixed_prefix ( 3 ) ) ;
rocksdb_options_set_prefix_extractor (
options , rocksdb_slicetransform_create_fixed_prefix ( 3 ) ) ;
rocksdb_options_set_hash_skip_list_rep ( options , 5000 , 4 , 4 ) ;
rocksdb_options_set_hash_skip_list_rep ( options , 5000 , 4 , 4 ) ;
rocksdb_options_set_plain_table_factory ( options , 4 , 10 , 0.75 , 16 ) ;
rocksdb_options_set_plain_table_factory ( options , 4 , 10 , 0.75 , 16 ) ;
rocksdb_options_set_allow_concurrent_memtable_write ( options , 0 ) ;
rocksdb_options_set_allow_concurrent_memtable_write ( options , 0 ) ;
@ -1747,7 +1740,8 @@ int main(int argc, char** argv) {
// amount of memory used within memtables should grow
// amount of memory used within memtables should grow
CheckCondition ( rocksdb_approximate_memory_usage_get_mem_table_total ( mu2 ) > =
CheckCondition ( rocksdb_approximate_memory_usage_get_mem_table_total ( mu2 ) > =
rocksdb_approximate_memory_usage_get_mem_table_total ( mu1 ) ) ;
rocksdb_approximate_memory_usage_get_mem_table_total ( mu1 ) ) ;
CheckCondition ( rocksdb_approximate_memory_usage_get_mem_table_unflushed ( mu2 ) > =
CheckCondition (
rocksdb_approximate_memory_usage_get_mem_table_unflushed ( mu2 ) > =
rocksdb_approximate_memory_usage_get_mem_table_unflushed ( mu1 ) ) ;
rocksdb_approximate_memory_usage_get_mem_table_unflushed ( mu1 ) ) ;
rocksdb_memory_consumers_destroy ( consumers ) ;
rocksdb_memory_consumers_destroy ( consumers ) ;
@ -2839,10 +2833,14 @@ int main(int argc, char** argv) {
db = rocksdb_open ( options , dbname , & err ) ;
db = rocksdb_open ( options , dbname , & err ) ;
CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " a " , 1 , " 0 " , 1 , & err ) ; CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " a " , 1 , " 0 " , 1 , & err ) ;
rocksdb_put ( db , woptions , " foo " , 3 , " bar " , 3 , & err ) ; CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " foo1 " , 4 , " bar1 " , 4 , & err ) ; CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " foo " , 3 , " bar " , 3 , & err ) ;
rocksdb_put ( db , woptions , " g1 " , 2 , " 0 " , 1 , & err ) ; CheckNoError ( err ) ;
CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " foo1 " , 4 , " bar1 " , 4 , & err ) ;
CheckNoError ( err ) ;
rocksdb_put ( db , woptions , " g1 " , 2 , " 0 " , 1 , & err ) ;
CheckNoError ( err ) ;
// testing basic case with no iterate_upper_bound and no prefix_extractor
// testing basic case with no iterate_upper_bound and no prefix_extractor
{
{
@ -3021,7 +3019,8 @@ int main(int argc, char** argv) {
// iterate
// iterate
rocksdb_transaction_put ( txn , " bar " , 3 , " hi " , 2 , & err ) ;
rocksdb_transaction_put ( txn , " bar " , 3 , " hi " , 2 , & err ) ;
rocksdb_iterator_t * iter = rocksdb_transaction_create_iterator ( txn , roptions ) ;
rocksdb_iterator_t * iter =
rocksdb_transaction_create_iterator ( txn , roptions ) ;
CheckCondition ( ! rocksdb_iter_valid ( iter ) ) ;
CheckCondition ( ! rocksdb_iter_valid ( iter ) ) ;
rocksdb_iter_seek_to_first ( iter ) ;
rocksdb_iter_seek_to_first ( iter ) ;
CheckCondition ( rocksdb_iter_valid ( iter ) ) ;
CheckCondition ( rocksdb_iter_valid ( iter ) ) ;