diff --git a/.idea/misc.xml b/.idea/misc.xml index 0b76fe5..12c8875 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,11 @@ + + diff --git a/benchmarks/db_bench.cc b/benchmarks/db_bench.cc index 8e3f4e7..e600e69 100644 --- a/benchmarks/db_bench.cc +++ b/benchmarks/db_bench.cc @@ -74,7 +74,7 @@ static int FLAGS_reads = -1; static int FLAGS_threads = 1; // Size of each value -static int FLAGS_value_size = 100; +static int FLAGS_value_size = 1000; // Arrange to generate values that shrink to this fraction of // their original size after compression @@ -852,8 +852,13 @@ class Benchmark { for (int j = 0; j < entries_per_batch_; j++) { const int k = seq ? i + j : thread->rand.Uniform(FLAGS_num); key.Set(k); - batch.Put(key.slice(), gen.Generate(value_size_)); - bytes += value_size_ + key.slice().size(); + auto value = gen.Generate(value_size_); + FieldArray field_array = { + {"1", value.ToString()}, + }; + auto encoded_value = Fields(field_array).Serialize(); + batch.Put(key.slice(), Slice(encoded_value)); + bytes += encoded_value.size() + key.slice().size(); thread->stats.FinishedSingleOp(); } s = db_->Write(write_options_, &batch); diff --git a/db/db_impl.cc b/db/db_impl.cc index 6db14f3..1f190b7 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -257,6 +257,9 @@ void DBImpl::RemoveObsoleteFiles() { case kTableFile: keep = (live.find(number) != live.end()); break; + case kVTableFile: + keep = (live.find(number) != live.end()); + break; case kTempFile: // Any temp files that are currently being written to must // be recorded in pending_outputs_, which is inserted into "live" @@ -1153,8 +1156,12 @@ Status DBImpl::Get(const ReadOptions& options, const Slice& key, s = current->Get(options, lkey, value, &stats); have_stat_update = true; } - auto fields = Fields(Slice(*value)); - *value = fields["1"]; + if (s.ok()) { + auto fields = Fields(Slice(*value)); + *value = fields["1"]; + } else { + *value = ""; + } mutex_.Lock(); } @@ -1203,7 +1210,11 @@ Status DBImpl::Get(const ReadOptions& options, const Slice& key, s = current->Get(options, lkey, value, &stats); have_stat_update = true; } - *fields = Fields(Slice(*value)); + if (s.ok()) { + *fields = Fields(Slice(*value)); + } else { + *fields = Fields(); + } mutex_.Lock(); } diff --git a/db/filename.cc b/db/filename.cc index e526249..561fcb6 100644 --- a/db/filename.cc +++ b/db/filename.cc @@ -112,6 +112,8 @@ bool ParseFileName(const std::string& filename, uint64_t* number, *type = kTableFile; } else if (suffix == Slice(".dbtmp")) { *type = kTempFile; + } else if (suffix == Slice(".vtb")) { + *type = kVTableFile; } else { return false; } diff --git a/db/filename.h b/db/filename.h index 563c6d8..9b80f8e 100644 --- a/db/filename.h +++ b/db/filename.h @@ -25,7 +25,8 @@ enum FileType { kDescriptorFile, kCurrentFile, kTempFile, - kInfoLogFile // Either the current one, or an old one + kInfoLogFile, // Either the current one, or an old one + kVTableFile }; // Return the name of the log file with the specified number