#pragma once #ifndef MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATANODESTORE_DATANODESTORE_H_ #define MESSMER_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(cpputils::unique_ref blockstore, uint32_t blocksizeBytes); virtual ~DataNodeStore(); static constexpr uint8_t MAX_DEPTH = 10; DataNodeLayout layout() const; boost::optional> load(const blockstore::Key &key); cpputils::unique_ref createNewLeafNode(); cpputils::unique_ref createNewInnerNode(const DataNode &first_child); cpputils::unique_ref createNewNodeAsCopyFrom(const DataNode &source); cpputils::unique_ref overwriteNodeWith(cpputils::unique_ref target, const DataNode &source); void remove(cpputils::unique_ref node); void removeSubtree(cpputils::unique_ref node); uint64_t numNodes() const; //TODO Test overwriteNodeWith(), createNodeAsCopyFrom(), removeSubtree() private: cpputils::unique_ref load(cpputils::unique_ref block); cpputils::unique_ref _blockstore; const DataNodeLayout _layout; DISALLOW_COPY_AND_ASSIGN(DataNodeStore); }; } } } #endif