13
13
#include " port/atomic_pointer.h"
14
14
#include " table/block_based_table_factory.h"
15
15
#include " table/plain_table_factory.h"
16
+ #include " table/table_builder.h"
16
17
#include " util/histogram.h"
17
18
#include " util/testharness.h"
18
19
#include " util/testutil.h"
@@ -57,12 +58,13 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
57
58
int num_keys2, int num_iter, int prefix_len,
58
59
bool if_query_empty_keys, bool for_iterator,
59
60
bool through_db) {
61
+ rocksdb::InternalKeyComparator ikc (opts.comparator );
62
+
60
63
Slice prefix = Slice ();
61
64
62
65
std::string file_name = test::TmpDir ()
63
66
+ " /rocksdb_table_reader_benchmark" ;
64
67
std::string dbname = test::TmpDir () + " /rocksdb_table_reader_bench_db" ;
65
- ReadOptions ro;
66
68
WriteOptions wo;
67
69
unique_ptr<WritableFile> file;
68
70
Env* env = Env::Default ();
@@ -71,7 +73,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
71
73
Status s;
72
74
if (!through_db) {
73
75
env->NewWritableFile (file_name, &file, env_options);
74
- tb = opts.table_factory ->NewTableBuilder (opts, file.get (),
76
+ tb = opts.table_factory ->NewTableBuilder (opts, ikc, file.get (),
75
77
CompressionType::kNoCompression );
76
78
} else {
77
79
s = DB::Open (opts, dbname, &db);
@@ -102,8 +104,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
102
104
Status s = env->NewRandomAccessFile (file_name, &raf, env_options);
103
105
uint64_t file_size;
104
106
env->GetFileSize (file_name, &file_size);
105
- s = opts.table_factory ->NewTableReader (opts, env_options, std::move (raf),
106
- file_size, &table_reader);
107
+ s = opts.table_factory ->NewTableReader (
108
+ opts, env_options, ikc, std::move (raf), file_size, &table_reader);
107
109
}
108
110
109
111
Random rnd (301 );
@@ -127,9 +129,10 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
127
129
uint64_t start_micros = env->NowMicros ();
128
130
port::MemoryBarrier ();
129
131
if (!through_db) {
130
- s = table_reader->Get (ro, key, arg, DummySaveValue, nullptr );
132
+ s = table_reader->Get (read_options, key, arg, DummySaveValue,
133
+ nullptr );
131
134
} else {
132
- s = db->Get (ro , key, &result);
135
+ s = db->Get (read_options , key, &result);
133
136
}
134
137
port::MemoryBarrier ();
135
138
hist.Add (env->NowMicros () - start_micros);
@@ -237,10 +240,9 @@ int main(int argc, char** argv) {
237
240
rocksdb::EnvOptions env_options;
238
241
options.create_if_missing = true ;
239
242
options.compression = rocksdb::CompressionType::kNoCompression ;
240
- options.internal_comparator =
241
- new rocksdb::InternalKeyComparator (options.comparator );
242
243
243
244
if (FLAGS_plain_table) {
245
+ ro.prefix_seek = true ;
244
246
options.allow_mmap_reads = true ;
245
247
env_options.use_mmap_reads = true ;
246
248
tf = new rocksdb::PlainTableFactory (16 , (FLAGS_prefix_len == 16 ) ? 0 : 8 ,
0 commit comments