@ -20,6 +20,14 @@
// NOTE that if FLAGS_test_batches_snapshots is set, the test will have
// different behavior. See comment of the flag for details.
# ifndef GFLAGS
# include <cstdio>
int main ( ) {
fprintf ( stderr , " Please install gflags to run rocksdb tools \n " ) ;
return 1 ;
}
# else
# include <sys/types.h>
# include <stdio.h>
# include <stdlib.h>
@ -45,8 +53,11 @@
# include "hdfs/env_hdfs.h"
# include "utilities/merge_operators.h"
static const long KB = 1024 ;
using GFLAGS : : ParseCommandLineFlags ;
using GFLAGS : : RegisterFlagValidator ;
using GFLAGS : : SetUsageMessage ;
static const long KB = 1024 ;
static bool ValidateUint32Range ( const char * flagname , uint64_t value ) {
if ( value > std : : numeric_limits < uint32_t > : : max ( ) ) {
@ -61,7 +72,7 @@ static bool ValidateUint32Range(const char* flagname, uint64_t value) {
DEFINE_uint64 ( seed , 2341234 , " Seed for PRNG " ) ;
static const bool FLAGS_seed_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_seed , & ValidateUint32Range ) ;
RegisterFlagValidator ( & FLAGS_seed , & ValidateUint32Range ) ;
DEFINE_int64 ( max_key , 1 * KB * KB ,
" Max number of key/values to place in database " ) ;
@ -185,7 +196,7 @@ static bool ValidateInt32Positive(const char* flagname, int32_t value) {
}
DEFINE_int32 ( reopen , 10 , " Number of times database reopens " ) ;
static const bool FLAGS_reopen_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_reopen , & ValidateInt32Positive ) ;
RegisterFlagValidator ( & FLAGS_reopen , & ValidateInt32Positive ) ;
DEFINE_int32 ( bloom_bits , 10 , " Bloom filter bits per key. "
" Negative means use default settings. " ) ;
@ -213,8 +224,7 @@ DEFINE_int32(kill_random_test, 0,
" If non-zero, kill at various points in source code with "
" probability 1/this " ) ;
static const bool FLAGS_kill_random_test_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_kill_random_test ,
& ValidateInt32Positive ) ;
RegisterFlagValidator ( & FLAGS_kill_random_test , & ValidateInt32Positive ) ;
extern int rocksdb_kill_odds ;
DEFINE_bool ( disable_wal , false , " If true, do not write WAL for write. " ) ;
@ -241,32 +251,32 @@ static bool ValidateInt32Percent(const char* flagname, int32_t value) {
DEFINE_int32 ( readpercent , 10 ,
" Ratio of reads to total workload (expressed as a percentage) " ) ;
static const bool FLAGS_readpercent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_readpercent , & ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_readpercent , & ValidateInt32Percent ) ;
DEFINE_int32 ( prefixpercent , 20 ,
" Ratio of prefix iterators to total workload (expressed as a "
" percentage) " ) ;
static const bool FLAGS_prefixpercent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_prefixpercent , & ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_prefixpercent , & ValidateInt32Percent ) ;
DEFINE_int32 ( writepercent , 45 ,
" Ratio of deletes to total workload (expressed as a percentage) " ) ;
static const bool FLAGS_writepercent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_writepercent , & ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_writepercent , & ValidateInt32Percent ) ;
DEFINE_int32 ( delpercent , 15 ,
" Ratio of deletes to total workload (expressed as a percentage) " ) ;
static const bool FLAGS_delpercent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_delpercent , & ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_delpercent , & ValidateInt32Percent ) ;
DEFINE_int32 ( iterpercent , 10 , " Ratio of iterations to total workload "
" (expressed as a percentage) " ) ;
static const bool FLAGS_iterpercent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_iterpercent , & ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_iterpercent , & ValidateInt32Percent ) ;
DEFINE_uint64 ( num_iterations , 10 , " Number of iterations per MultiIterate run " ) ;
static const bool FLAGS_num_iterations_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_num_iterations , & ValidateUint32Range ) ;
RegisterFlagValidator ( & FLAGS_num_iterations , & ValidateUint32Range ) ;
DEFINE_bool ( disable_seek_compaction , false ,
" Option to disable compation triggered by read. " ) ;
@ -304,19 +314,18 @@ static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
DEFINE_uint64 ( ops_per_thread , 1200000 , " Number of operations per thread. " ) ;
static const bool FLAGS_ops_per_thread_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_ops_per_thread , & ValidateUint32Range ) ;
RegisterFlagValidator ( & FLAGS_ops_per_thread , & ValidateUint32Range ) ;
DEFINE_uint64 ( log2_keys_per_lock , 2 , " Log2 of number of keys per lock " ) ;
static const bool FLAGS_log2_keys_per_lock_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_log2_keys_per_lock ,
& ValidateUint32Range ) ;
RegisterFlagValidator ( & FLAGS_log2_keys_per_lock , & ValidateUint32Range ) ;
DEFINE_int32 ( purge_redundant_percent , 50 ,
" Percentage of times we want to purge redundant keys in memory "
" before flushing " ) ;
static const bool FLAGS_purge_redundant_percent_dummy __attribute__ ( ( unused ) ) =
google : : RegisterFlagValidator ( & FLAGS_purge_redundant_percent ,
& ValidateInt32Percent ) ;
RegisterFlagValidator ( & FLAGS_purge_redundant_percent ,
& ValidateInt32Percent ) ;
DEFINE_bool ( filter_deletes , false , " On true, deletes use KeyMayExist to drop "
" the delete if key not present " ) ;
@ -356,7 +365,7 @@ static bool ValidatePrefixSize(const char* flagname, int32_t value) {
}
DEFINE_int32 ( prefix_size , 7 , " Control the prefix size for HashSkipListRep " ) ;
static const bool FLAGS_prefix_size_dummy =
google : : RegisterFlagValidator ( & FLAGS_prefix_size , & ValidatePrefixSize ) ;
RegisterFlagValidator ( & FLAGS_prefix_size , & ValidatePrefixSize ) ;
DEFINE_bool ( use_merge , false , " On true, replaces all writes with a Merge "
" that behaves like a Put " ) ;
@ -1666,9 +1675,9 @@ class StressTest {
} // namespace rocksdb
int main ( int argc , char * * argv ) {
google : : SetUsageMessage ( std : : string ( " \n USAGE: \n " ) + std : : string ( argv [ 0 ] ) +
" [OPTIONS]... " ) ;
google : : ParseCommandLineFlags ( & argc , & argv , true ) ;
SetUsageMessage ( std : : string ( " \n USAGE: \n " ) + std : : string ( argv [ 0 ] ) +
" [OPTIONS]... " ) ;
ParseCommandLineFlags ( & argc , & argv , true ) ;
if ( FLAGS_statistics ) {
dbstats = rocksdb : : CreateDBStatistics ( ) ;
@ -1730,3 +1739,5 @@ int main(int argc, char** argv) {
return 1 ;
}
}
# endif // GFLAGS