|
|
@ -63,6 +63,10 @@ static const char* FLAGS_benchmarks = |
|
|
|
"readreverse," |
|
|
|
"fill100K," |
|
|
|
"crc32c," |
|
|
|
"CreateIndex," |
|
|
|
"FindKeysByField," |
|
|
|
"QueryByIndex," |
|
|
|
"DeleteIndex," |
|
|
|
"snappycomp," |
|
|
|
"snappyuncomp," |
|
|
|
"zstdcomp," |
|
|
@ -635,6 +639,14 @@ class Benchmark { |
|
|
|
method = &Benchmark::Compact; |
|
|
|
} else if (name == Slice("crc32c")) { |
|
|
|
method = &Benchmark::Crc32c; |
|
|
|
} else if (name == Slice("CreateIndex")) { |
|
|
|
method = &Benchmark::CreateIndex; |
|
|
|
} else if (name == Slice("FindKeysByField")) { |
|
|
|
method = &Benchmark::FindKeysByField; |
|
|
|
} else if (name == Slice("QueryByIndex")) { |
|
|
|
method = &Benchmark::QueryByIndex; |
|
|
|
} else if (name == Slice("DeleteIndex")) { |
|
|
|
method = &Benchmark::DeleteIndex; |
|
|
|
} else if (name == Slice("snappycomp")) { |
|
|
|
method = &Benchmark::SnappyCompress; |
|
|
|
} else if (name == Slice("snappyuncomp")) { |
|
|
@ -664,7 +676,7 @@ class Benchmark { |
|
|
|
} else { |
|
|
|
delete db_; |
|
|
|
db_ = nullptr; |
|
|
|
//DestroyDB(FLAGS_db, Options());
|
|
|
|
DestroyDB(FLAGS_db, Options()); |
|
|
|
Open(); |
|
|
|
} |
|
|
|
} |
|
|
@ -821,7 +833,7 @@ class Benchmark { |
|
|
|
options.compression = |
|
|
|
FLAGS_compression ? kSnappyCompression : kNoCompression; |
|
|
|
// Status s = DB::Open(options, FLAGS_db, &db_);
|
|
|
|
fielddb::DestroyDB(FLAGS_db, options); |
|
|
|
//fielddb::DestroyDB(FLAGS_db, options);
|
|
|
|
db_ = new FieldDB(); |
|
|
|
Status s = FieldDB::OpenFieldDB(options, FLAGS_db, &db_); |
|
|
|
if (!s.ok()) { |
|
|
@ -870,7 +882,7 @@ class Benchmark { |
|
|
|
{"age", age}, |
|
|
|
{"tag", tag} |
|
|
|
}; |
|
|
|
Slice value = SerializeValue(fields); |
|
|
|
std::string value = SerializeValue(fields); |
|
|
|
batch.Put(key.slice(), value); |
|
|
|
bytes += value.size() + key.slice().size(); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
@ -1078,6 +1090,27 @@ class Benchmark { |
|
|
|
g_env->RemoveFile(fname); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void CreateIndex(ThreadState* thread) { |
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
void FindKeysByField(ThreadState* thread) { |
|
|
|
Field f = {"age", "20"}; |
|
|
|
std::vector<std::string> res; |
|
|
|
res = db_->FindKeysByField(f); |
|
|
|
} |
|
|
|
|
|
|
|
void QueryByIndex(ThreadState* thread) { |
|
|
|
Field f = {"age", "20"}; |
|
|
|
Status s; |
|
|
|
db_->QueryByIndex(f, &s); |
|
|
|
} |
|
|
|
|
|
|
|
void DeleteIndex(ThreadState* thread) { |
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} // namespace leveldb
|
|
|
|