Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified btree_test
Binary file not shown.
Binary file modified content_addressable_demo
Binary file not shown.
Binary file modified content_hash_demo
Binary file not shown.
Binary file modified deduplication_demo
Binary file not shown.
17 changes: 9 additions & 8 deletions include/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include<vector>
#include<variant>
#include<string>
#include<memory>
#include "fraction.h"
#include "page_manager.h"
#include "content_storage.h"
Expand All @@ -15,17 +16,17 @@
template <typename KeyType, typename ValueType>
class BTree {
private:
Page<KeyType>* root;
std::shared_ptr<Page<KeyType>> root;
int maxKeysPerNode; // Maximum keys in each node
ContentStorage<KeyType> content_storage;

void insertNonFull(Page<KeyType>* root, const KeyType& key, const ValueType& value);
void splitChild(Page<KeyType>* parent, int index, Page<KeyType>* child);
void insertNonFull(std::shared_ptr<Page<KeyType>> root, const KeyType& key, const ValueType& value);
void splitChild(std::shared_ptr<Page<KeyType>> parent, int index, std::shared_ptr<Page<KeyType>> child);

void deleteFromNode(Page<KeyType>* node, const KeyType& key);
void borrowFromLeft(Page<KeyType>* parent, int index);
void borrowFromRight(Page<KeyType>* parent, int index);
void mergeNodes(Page<KeyType>* parent, int index);
void deleteFromNode(std::shared_ptr<Page<KeyType>> node, const KeyType& key);
void borrowFromLeft(std::shared_ptr<Page<KeyType>> parent, int index);
void borrowFromRight(std::shared_ptr<Page<KeyType>> parent, int index);
void mergeNodes(std::shared_ptr<Page<KeyType>> parent, int index);

public:
BTree(int maxKeys);
Expand All @@ -34,6 +35,6 @@ class BTree {
ValueType* search(const KeyType& key); // Public search method
void printStorageStats() const;

Page<KeyType> findKey(Page<KeyType>* node, const KeyType& key);
Page<KeyType> findKey(std::shared_ptr<Page<KeyType>> node, const KeyType& key);

};
Loading