From b2906538dfb745c19f4f86e7ec5c0a3fcfaa8565 Mon Sep 17 00:00:00 2001 From: Damian Li Date: Sat, 2 Nov 2024 13:45:55 -0400 Subject: [PATCH] code cleaning --- Memory/Memtable/Memtable.h | 3 --- Storage/SstFileManager/SstFileManager.cpp | 2 +- Storage/SstFileManager/SstFileManager.h | 4 ---- kv/KeyValue.cpp | 3 ++- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Memory/Memtable/Memtable.h b/Memory/Memtable/Memtable.h index 84d178f..1db0e16 100644 --- a/Memory/Memtable/Memtable.h +++ b/Memory/Memtable/Memtable.h @@ -39,9 +39,6 @@ class Memtable { // Flush the memtable to disk (SST file) void flushToDisk(); - // set sstFileManager degree - void setSstFileManager_BTree_Degree(int degree) {sstFileManager->setDegree(degree);}; - // get current size int get_currentSize() const {return currentSize;}; diff --git a/Storage/SstFileManager/SstFileManager.cpp b/Storage/SstFileManager/SstFileManager.cpp index 82b0708..9d21353 100644 --- a/Storage/SstFileManager/SstFileManager.cpp +++ b/Storage/SstFileManager/SstFileManager.cpp @@ -16,7 +16,7 @@ namespace fs = std::filesystem; // Constructor SSTFileManager::SSTFileManager(const std::string& dbDirectory) - : dbDirectory(dbDirectory), degree(degree) { + : dbDirectory(dbDirectory) { // std::cout << "SSTFileManager initialized with directory: " << dbDirectory << " and degree: " << degree << std::endl; // Ensure the database directory exists if (!fs::exists(dbDirectory)) { diff --git a/Storage/SstFileManager/SstFileManager.h b/Storage/SstFileManager/SstFileManager.h index 329bf43..4f8feda 100644 --- a/Storage/SstFileManager/SstFileManager.h +++ b/Storage/SstFileManager/SstFileManager.h @@ -28,8 +28,6 @@ class SSTFileManager { // Scan keys within a range across all SST files void scan(const KeyValueWrapper& startKey, const KeyValueWrapper& endKey, std::vector& result); - // set degree - void setDegree(int _degree) {degree = _degree;}; // set path void setPath(string _path) {dbDirectory = _path;}; @@ -41,8 +39,6 @@ class SSTFileManager { // Directory where SST files are stored std::string dbDirectory; - // B+ tree degree - int degree; // List of SST files (DiskBTree instances) std::vector> sstFiles; diff --git a/kv/KeyValue.cpp b/kv/KeyValue.cpp index 0c9ea01..37e8865 100644 --- a/kv/KeyValue.cpp +++ b/kv/KeyValue.cpp @@ -244,7 +244,8 @@ std::string KeyValueWrapper::keyValueTypeToString(KeyValue::KeyValueType type) c } size_t KeyValueWrapper::getSerializedSize() const { - return sizeof(kv.key_case()) + sizeof(kv.value_case()) + sizeof(kv.key_type()) + sizeof(kv.value_type()) + sizeof(size_t); + // sizeof kv pair + sequence number + tombstone + return sizeof(kv.key_case()) + sizeof(kv.value_case()) + sizeof(kv.key_type()) + sizeof(kv.value_type()) + sizeof(size_t) + sizeof(uint64_t); }