|
|
@ -26,16 +26,16 @@ CompactedDBImpl::CompactedDBImpl(const DBOptions& options, |
|
|
|
version_(nullptr), |
|
|
|
version_(nullptr), |
|
|
|
user_comparator_(nullptr) {} |
|
|
|
user_comparator_(nullptr) {} |
|
|
|
|
|
|
|
|
|
|
|
CompactedDBImpl::~CompactedDBImpl() { |
|
|
|
CompactedDBImpl::~CompactedDBImpl() {} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t CompactedDBImpl::FindFile(const Slice& key) { |
|
|
|
size_t CompactedDBImpl::FindFile(const Slice& key) { |
|
|
|
size_t right = files_.num_files - 1; |
|
|
|
size_t right = files_.num_files - 1; |
|
|
|
auto cmp = [&](const FdWithKeyRange& f, const Slice& k) -> bool { |
|
|
|
auto cmp = [&](const FdWithKeyRange& f, const Slice& k) -> bool { |
|
|
|
return user_comparator_->Compare(ExtractUserKey(f.largest_key), k) < 0; |
|
|
|
return user_comparator_->Compare(ExtractUserKey(f.largest_key), k) < 0; |
|
|
|
}; |
|
|
|
}; |
|
|
|
return static_cast<size_t>(std::lower_bound(files_.files, |
|
|
|
return static_cast<size_t>( |
|
|
|
files_.files + right, key, cmp) - files_.files); |
|
|
|
std::lower_bound(files_.files, files_.files + right, key, cmp) - |
|
|
|
|
|
|
|
files_.files); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Status CompactedDBImpl::Get(const ReadOptions& options, ColumnFamilyHandle*, |
|
|
|
Status CompactedDBImpl::Get(const ReadOptions& options, ColumnFamilyHandle*, |
|
|
@ -228,8 +228,8 @@ Status CompactedDBImpl::Init(const Options& options) { |
|
|
|
return Status::NotSupported("no file exists"); |
|
|
|
return Status::NotSupported("no file exists"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Status CompactedDBImpl::Open(const Options& options, |
|
|
|
Status CompactedDBImpl::Open(const Options& options, const std::string& dbname, |
|
|
|
const std::string& dbname, DB** dbptr) { |
|
|
|
DB** dbptr) { |
|
|
|
*dbptr = nullptr; |
|
|
|
*dbptr = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
if (options.max_open_files != -1) { |
|
|
|
if (options.max_open_files != -1) { |
|
|
|