#pragma once #ifndef BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATANODESTORE_DATANODESTORE_H_ #define BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATANODESTORE_DATANODESTORE_H_ #include #include "messmer/cpp-utils/macros.h" #include "DataNodeView.h" #include namespace blockstore{ class Block; class BlockStore; } namespace blobstore { namespace onblocks { namespace datanodestore { class DataNode; class DataLeafNode; class DataInnerNode; class DataNodeStore { public: DataNodeStore(std::unique_ptr blockstore, uint32_t blocksizeBytes); virtual ~DataNodeStore(); static constexpr uint8_t MAX_DEPTH = 10; DataNodeLayout layout() const; std::unique_ptr load(const blockstore::Key &key); std::unique_ptr createNewLeafNode(); std::unique_ptr createNewInnerNode(const DataNode &first_child); std::unique_ptr createNewNodeAsCopyFrom(const DataNode &source); std::unique_ptr overwriteNodeWith(std::unique_ptr target, const DataNode &source); void remove(std::unique_ptr node); void removeSubtree(std::unique_ptr node); uint64_t numNodes() const; //TODO Test overwriteNodeWith(), createNodeAsCopyFrom(), removeSubtree() private: std::unique_ptr load(std::unique_ptr block); std::unique_ptr _blockstore; const DataNodeLayout _layout; DISALLOW_COPY_AND_ASSIGN(DataNodeStore); }; } } } #endif