#include "db/vlog_manager.h"

namespace leveldb{
namespace vlog{
    void VlogManager::AddVlogFile(uint64_t vlogfile_number, SequentialFile* seq_file, WritableFile* write_file){
        if(vlog_table_.find(vlogfile_number) == vlog_table_.end()){
            vlog_table_[vlogfile_number] = seq_file;
            writable_to_sequential_[write_file] = seq_file;
        }
        else{
            //Do Nothing
        }
    }
    SequentialFile* VlogManager::GetVlogFile(uint64_t vlogfile_number){
        auto it = vlog_table_.find(vlogfile_number);
        if(it != vlog_table_.end()){
            return it->second;
        }
        else return nullptr;
    }
    bool VlogManager::IsEmpty(){
        return vlog_table_.size() == 0;
    }
    // 标记一个vlog文件有一个新的无效的value，pzy
    void VlogManager::MarkVlogValueInvalid(uint64_t vlogfile_number, uint64_t offset) {
        auto vlog_file = GetVlogFile(vlogfile_number);
        if (vlog_file) {
            vlog_file->MarkValueInvalid(offset); // 调用具体文件的标记逻辑
        }
    }

}// namespace vlog
}