20
20
// NOTE that if FLAGS_test_batches_snapshots is set, the test will have
21
21
// different behavior. See comment of the flag for details.
22
22
23
+ #ifndef GFLAGS
24
+ #include < cstdio>
25
+ int main () {
26
+ fprintf (stderr, " Please install gflags to run rocksdb tools\n " );
27
+ return 1 ;
28
+ }
29
+ #else
30
+
23
31
#include < sys/types.h>
24
32
#include < stdio.h>
25
33
#include < stdlib.h>
45
53
#include " hdfs/env_hdfs.h"
46
54
#include " utilities/merge_operators.h"
47
55
48
- static const long KB = 1024 ;
56
+ using GFLAGS::ParseCommandLineFlags;
57
+ using GFLAGS::RegisterFlagValidator;
58
+ using GFLAGS::SetUsageMessage;
49
59
60
+ static const long KB = 1024 ;
50
61
51
62
static bool ValidateUint32Range (const char * flagname, uint64_t value) {
52
63
if (value > std::numeric_limits<uint32_t >::max ()) {
@@ -61,7 +72,7 @@ static bool ValidateUint32Range(const char* flagname, uint64_t value) {
61
72
62
73
DEFINE_uint64 (seed, 2341234 , " Seed for PRNG" );
63
74
static const bool FLAGS_seed_dummy __attribute__ ((unused)) =
64
- google:: RegisterFlagValidator(&FLAGS_seed, &ValidateUint32Range);
75
+ RegisterFlagValidator(&FLAGS_seed, &ValidateUint32Range);
65
76
66
77
DEFINE_int64 (max_key, 1 * KB* KB,
67
78
" Max number of key/values to place in database" );
@@ -185,7 +196,7 @@ static bool ValidateInt32Positive(const char* flagname, int32_t value) {
185
196
}
186
197
DEFINE_int32 (reopen, 10 , " Number of times database reopens" );
187
198
static const bool FLAGS_reopen_dummy __attribute__ ((unused)) =
188
- google:: RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive);
199
+ RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive);
189
200
190
201
DEFINE_int32 (bloom_bits, 10 , " Bloom filter bits per key. "
191
202
" Negative means use default settings." );
@@ -213,8 +224,7 @@ DEFINE_int32(kill_random_test, 0,
213
224
" If non-zero, kill at various points in source code with "
214
225
" probability 1/this" );
215
226
static const bool FLAGS_kill_random_test_dummy __attribute__ ((unused)) =
216
- google::RegisterFlagValidator(&FLAGS_kill_random_test,
217
- &ValidateInt32Positive);
227
+ RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive);
218
228
extern int rocksdb_kill_odds;
219
229
220
230
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) {
241
251
DEFINE_int32 (readpercent, 10 ,
242
252
" Ratio of reads to total workload (expressed as a percentage)" );
243
253
static const bool FLAGS_readpercent_dummy __attribute__ ((unused)) =
244
- google:: RegisterFlagValidator(&FLAGS_readpercent, &ValidateInt32Percent);
254
+ RegisterFlagValidator(&FLAGS_readpercent, &ValidateInt32Percent);
245
255
246
256
DEFINE_int32 (prefixpercent, 20 ,
247
257
" Ratio of prefix iterators to total workload (expressed as a"
248
258
" percentage)" );
249
259
static const bool FLAGS_prefixpercent_dummy __attribute__ ((unused)) =
250
- google:: RegisterFlagValidator(&FLAGS_prefixpercent, &ValidateInt32Percent);
260
+ RegisterFlagValidator(&FLAGS_prefixpercent, &ValidateInt32Percent);
251
261
252
262
DEFINE_int32 (writepercent, 45 ,
253
263
" Ratio of deletes to total workload (expressed as a percentage)" );
254
264
static const bool FLAGS_writepercent_dummy __attribute__ ((unused)) =
255
- google:: RegisterFlagValidator(&FLAGS_writepercent, &ValidateInt32Percent);
265
+ RegisterFlagValidator(&FLAGS_writepercent, &ValidateInt32Percent);
256
266
257
267
DEFINE_int32 (delpercent, 15 ,
258
268
" Ratio of deletes to total workload (expressed as a percentage)" );
259
269
static const bool FLAGS_delpercent_dummy __attribute__ ((unused)) =
260
- google:: RegisterFlagValidator(&FLAGS_delpercent, &ValidateInt32Percent);
270
+ RegisterFlagValidator(&FLAGS_delpercent, &ValidateInt32Percent);
261
271
262
272
DEFINE_int32 (iterpercent, 10 , " Ratio of iterations to total workload"
263
273
" (expressed as a percentage)" );
264
274
static const bool FLAGS_iterpercent_dummy __attribute__ ((unused)) =
265
- google:: RegisterFlagValidator(&FLAGS_iterpercent, &ValidateInt32Percent);
275
+ RegisterFlagValidator(&FLAGS_iterpercent, &ValidateInt32Percent);
266
276
267
277
DEFINE_uint64 (num_iterations, 10 , " Number of iterations per MultiIterate run" );
268
278
static const bool FLAGS_num_iterations_dummy __attribute__ ((unused)) =
269
- google:: RegisterFlagValidator(&FLAGS_num_iterations, &ValidateUint32Range);
279
+ RegisterFlagValidator(&FLAGS_num_iterations, &ValidateUint32Range);
270
280
271
281
DEFINE_bool (disable_seek_compaction, false ,
272
282
" Option to disable compation triggered by read." );
@@ -304,19 +314,18 @@ static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
304
314
305
315
DEFINE_uint64 (ops_per_thread, 1200000 , " Number of operations per thread." );
306
316
static const bool FLAGS_ops_per_thread_dummy __attribute__ ((unused)) =
307
- google:: RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
317
+ RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
308
318
309
319
DEFINE_uint64 (log2_keys_per_lock, 2 , " Log2 of number of keys per lock" );
310
320
static const bool FLAGS_log2_keys_per_lock_dummy __attribute__ ((unused)) =
311
- google::RegisterFlagValidator(&FLAGS_log2_keys_per_lock,
312
- &ValidateUint32Range);
321
+ RegisterFlagValidator(&FLAGS_log2_keys_per_lock, &ValidateUint32Range);
313
322
314
323
DEFINE_int32 (purge_redundant_percent, 50 ,
315
324
" Percentage of times we want to purge redundant keys in memory "
316
325
" before flushing" );
317
326
static const bool FLAGS_purge_redundant_percent_dummy __attribute__ ((unused)) =
318
- google:: RegisterFlagValidator(&FLAGS_purge_redundant_percent,
319
- &ValidateInt32Percent);
327
+ RegisterFlagValidator(&FLAGS_purge_redundant_percent,
328
+ &ValidateInt32Percent);
320
329
321
330
DEFINE_bool (filter_deletes, false , " On true, deletes use KeyMayExist to drop"
322
331
" the delete if key not present" );
@@ -356,7 +365,7 @@ static bool ValidatePrefixSize(const char* flagname, int32_t value) {
356
365
}
357
366
DEFINE_int32 (prefix_size, 7 , " Control the prefix size for HashSkipListRep" );
358
367
static const bool FLAGS_prefix_size_dummy =
359
- google:: RegisterFlagValidator (&FLAGS_prefix_size, &ValidatePrefixSize);
368
+ RegisterFlagValidator (&FLAGS_prefix_size, &ValidatePrefixSize);
360
369
361
370
DEFINE_bool (use_merge, false , " On true, replaces all writes with a Merge "
362
371
" that behaves like a Put" );
@@ -1666,9 +1675,9 @@ class StressTest {
1666
1675
} // namespace rocksdb
1667
1676
1668
1677
int main (int argc, char ** argv) {
1669
- google:: SetUsageMessage (std::string (" \n USAGE:\n " ) + std::string (argv[0 ]) +
1670
- " [OPTIONS]..." );
1671
- google:: ParseCommandLineFlags (&argc, &argv, true );
1678
+ SetUsageMessage (std::string (" \n USAGE:\n " ) + std::string (argv[0 ]) +
1679
+ " [OPTIONS]..." );
1680
+ ParseCommandLineFlags (&argc, &argv, true );
1672
1681
1673
1682
if (FLAGS_statistics) {
1674
1683
dbstats = rocksdb::CreateDBStatistics ();
@@ -1730,3 +1739,5 @@ int main(int argc, char** argv) {
1730
1739
return 1 ;
1731
1740
}
1732
1741
}
1742
+
1743
+ #endif // GFLAGS
0 commit comments