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/db/db_impl.cc b/db/db_impl.cc index 535a1d3..299b249 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -260,6 +260,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" @@ -1215,8 +1218,12 @@ Status DBImpl::Get(const ReadOptions& options, const Slice& key, if (s.ok()) { s = DecodeValue(value); } - auto fields = Fields(Slice(*value)); - *value = fields["1"]; + if (s.ok()) { + auto fields = Fields(Slice(*value)); + *value = fields["1"]; + } else { + *value = ""; + } mutex_.Lock(); } @@ -1268,7 +1275,11 @@ Status DBImpl::Get(const ReadOptions& options, const Slice& key, if (s.ok()) { s = DecodeValue(value); } - *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 21c306a..baaa512 100644 --- a/db/filename.cc +++ b/db/filename.cc @@ -117,6 +117,8 @@ bool ParseFileName(const std::string& filename, uint64_t* number, *type = kTableFile; } else if (suffix == Slice(".dbtmp")) { *type = kTempFile; + } else if (suffix == Slice(".vrb")) { + *type = kVTableFile; } else { return false; } diff --git a/db/filename.h b/db/filename.h index 06cf019..f777104 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, + kVTableFile// Either the current one, or an old one }; // Return the name of the log file with the specified number diff --git a/test/test_basicio.cc b/test/test_basicio.cc index 5510c66..2654077 100644 --- a/test/test_basicio.cc +++ b/test/test_basicio.cc @@ -3,7 +3,7 @@ #include "leveldb/db.h" using namespace leveldb; -constexpr int value_size = 2000; +constexpr int value_size = 2048; constexpr int data_size = 128 << 20; std::map data;