Przeglądaj źródła

ver1 bug fix again

main
李畅 8 miesięcy temu
rodzic
commit
52e7b38f62
2 zmienionych plików z 49 dodań i 3 usunięć
  1. +28
    -0
      .vscode/tasks.json
  2. +21
    -3
      benchmarks/db_bench_new.cc

+ 28
- 0
.vscode/tasks.json Wyświetl plik

@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++-11 build active file",
"command": "/usr/bin/g++-11",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

+ 21
- 3
benchmarks/db_bench_new.cc Wyświetl plik

@ -53,6 +53,9 @@ static const char* FLAGS_benchmarks = // TODO: findkeysbyfield()
"readrandom," // Extra run to allow previous compactions to quiesce
"readseq,"
"readreverse,"
"fillgivenseq,"
"fillgivenrandom,"
"findkeysbyfield,"
"compact,"
"readrandom,"
"readseq,"
@ -137,6 +140,14 @@ namespace leveldb {
namespace {
leveldb::Env* g_env = nullptr;
void EncodeNonIndexValue(const Slice& value, std::string* res) {
enum Type : unsigned char {
kNonIndexValue = 2,
};
res->push_back(kNonIndexValue);
res->append(value.ToString());
}
class CountComparator : public Comparator {
public:
CountComparator(const Comparator* wrapped) : wrapped_(wrapped) {}
@ -872,7 +883,11 @@ class Benchmark {
FieldArray field_array = {
{"1", value.ToString()},
};
auto encoded_value = Fields(field_array).Serialize();
// auto encoded_value = Fields(field_array).Serialize();
auto field_str = Fields(field_array).Serialize();
std::string encoded_value;
EncodeNonIndexValue(field_str, &encoded_value);
batch.Put(key.slice(), Slice(encoded_value));
bytes += encoded_value.size() + key.slice().size();
@ -993,8 +1008,11 @@ class Benchmark {
field_array = {
{"1", value.ToString()},
};
}
auto encoded_value = Fields(field_array).Serialize();
}
auto field_str = Fields(field_array).Serialize();
std::string encoded_value;
EncodeNonIndexValue(field_str, &encoded_value);
batch.Put(key.slice(), Slice(encoded_value));
bytes += encoded_value.size() + key.slice().size();

Ładowanie…
Anuluj
Zapisz