Browse Source

Merge commit '028f65641a7959fa1bc7faa56dbc93e70e324d2d'

main
cyq 1 month ago
parent
commit
fc087d03ef
2 changed files with 4 additions and 6 deletions
  1. +1
    -3
      README.md
  2. +3
    -3
      db/version_set.cc

+ 1
- 3
README.md View File

@ -1,5 +1,5 @@
# 实验报告
仓库地址 https://gitea.shuishan.net.cn/10225501448/leveldb_ttl/src/branch/main
## 1. 设计思路和实现过程
### 1.1 实验总体流程介绍
@ -16,8 +16,6 @@ lookup key一定需要一个当前时间在查询中进行比较,因此不再
![alt text](pics/f535cd48ec424ab7e91e200092b3bb0.png)
为了便于对于新编码的操作,我们也修改了相应的`ParsedInternalKey`结构体和`parseInternalKey`函数等。
//这里或许可以多贴一点代码
### 1.3 写入
新的put接口多了一个默认参数ttl,当调用时不加这个参数,则这一次写入没有ttl,与原来的leveldb写入逻辑一致。否则需要进行两处的修改:

+ 3
- 3
db/version_set.cc View File

@ -107,7 +107,7 @@ int FindFile(const InternalKeyComparator& icmp,
}
while(right < files.size()) {
printf("file ind %d num %d largest deadtime %d parsed deadtime %d\n",
printf("file ind %d num %lu largest deadtime %lu parsed deadtime %lu\n",
right,files[right]->number,files[right]->largest_deadtime,parsed.deadTime);
if(files[right]->largest_deadtime >= parsed.deadTime) {
break;
@ -303,7 +303,7 @@ void Version::ForEachOverlapping(Slice user_key, Slice internal_key, void* arg,
const Comparator* ucmp = vset_->icmp_.user_comparator();
ParsedInternalKey parsed;
ParseInternalKey(internal_key,&parsed);
printf("parsed lookup deadtime : %d\n",parsed.deadTime);
printf("parsed lookup deadtime : %lu\n",parsed.deadTime);
// Search level-0 in order from newest to oldest.
std::vector<FileMetaData*> tmp;
tmp.reserve(files_[0].size());
@ -380,7 +380,7 @@ Status Version::Get(const ReadOptions& options, const LookupKey& k,
state->s = state->vset->table_cache_->Get(*state->options, f->number,
f->file_size, state->ikey,
&state->saver, SaveValue);
printf("file level %d num %d\n",level,f->number);
printf("file level %d num %lu\n", level, f->number);
std::cout<<"state->s ->saver.state: "<<state->s.ok()<<" "<<state->saver.state<<std::endl;
if (!state->s.ok()) {
state->found = true;

Loading…
Cancel
Save