Browse Source

temp work

main
GUJIEJASON 8 months ago
parent
commit
228b316445
4 changed files with 8 additions and 6 deletions
  1. +5
    -1
      db/db_impl.cc
  2. +1
    -1
      include/leveldb/options.h
  3. +0
    -2
      test/kv_test.cc
  4. +2
    -2
      test/value_field_test.cc

+ 5
- 1
db/db_impl.cc View File

@ -389,6 +389,7 @@ Status DBImpl::Recover(VersionEdit* edit, bool* save_manifest) {
// Recover in the order in which the logs were generated // Recover in the order in which the logs were generated
std::sort(logs.begin(), logs.end()); std::sort(logs.begin(), logs.end());
assert( logs.size() == 0 || logs[logs.size() - 1] >= versions_->ImmLogFileNumber() );
// for (size_t i = 0; i < logs.size(); i++) { // for (size_t i = 0; i < logs.size(); i++) {
// s = RecoverLogFile(logs[i], (i == logs.size() - 1), save_manifest, edit, // s = RecoverLogFile(logs[i], (i == logs.size() - 1), save_manifest, edit,
// &max_sequence); // &max_sequence);
@ -516,7 +517,8 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, bool last_log,
mem = new MemTable(internal_comparator_); mem = new MemTable(internal_comparator_);
mem->Ref(); mem->Ref();
} }
status = WriteBatchInternal::InsertInto(&batch, mem);
// status = WriteBatchInternal::InsertInto(&batch, mem);
status = WriteBatchInternal::InsertInto(&batch, mem,log_number,record_offset + 4);
MaybeIgnoreError(&status); MaybeIgnoreError(&status);
if (!status.ok()) { if (!status.ok()) {
break; break;
@ -545,6 +547,8 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, bool last_log,
break; break;
} }
} }
// 前面已经移除了一个头部了,所以偏移位置要个头部
record_offset += record.size() + log::vHeaderSize ;
} }
delete file; delete file;

+ 1
- 1
include/leveldb/options.h View File

@ -155,7 +155,7 @@ struct LEVELDB_EXPORT Options {
// gc put的时候kv分离的值 // gc put的时候kv分离的值
uint64_t background_garbage_collection_separate_ = 1024 * 1024 - 1; uint64_t background_garbage_collection_separate_ = 1024 * 1024 - 1;
// open log文件回收 // open log文件回收
bool start_garbage_collection = true;
bool start_garbage_collection = false;
}; };
// Options that control read operations // Options that control read operations

+ 0
- 2
test/kv_test.cc View File

@ -11,8 +11,6 @@ constexpr int long_value_size = 32;
constexpr int data_size = 512; constexpr int data_size = 512;
Status OpenDB(std::string dbName, DB **db) { Status OpenDB(std::string dbName, DB **db) {
Options options; Options options;
options.create_if_missing = true; options.create_if_missing = true;
return DB::Open(options, dbName, db); return DB::Open(options, dbName, db);

+ 2
- 2
test/value_field_test.cc View File

@ -7,8 +7,8 @@ using namespace leveldb;
Status OpenDB(const std::string& dbName, DB** db) { Status OpenDB(const std::string& dbName, DB** db) {
// 如果数据库已经存在,则删除它。 // 如果数据库已经存在,则删除它。
std::string rm_command = "rm -rf " + dbName;
system(rm_command.c_str());
// std::string rm_command = "rm -rf " + dbName;
// system(rm_command.c_str());
Options options; Options options;
options.create_if_missing = true; options.create_if_missing = true;

Loading…
Cancel
Save