#include "parallelaccessdatatreestore/DataTreeRef.h" #include "parallelaccessdatatreestore/ParallelAccessDataTreeStore.h" #include #include "datanodestore/DataLeafNode.h" #include "datanodestore/DataNodeStore.h" #include "datatreestore/DataTreeStore.h" #include "datatreestore/DataTree.h" #include "BlobStoreOnBlocks.h" #include "BlobOnBlocks.h" #include using std::unique_ptr; using std::make_unique; using cpputils::unique_ref; using cpputils::make_unique_ref; using blockstore::BlockStore; using blockstore::parallelaccess::ParallelAccessBlockStore; using blockstore::Key; using cpputils::dynamic_pointer_move; using boost::optional; using boost::none; namespace blobstore { namespace onblocks { using datanodestore::DataNodeStore; using datatreestore::DataTreeStore; using parallelaccessdatatreestore::ParallelAccessDataTreeStore; BlobStoreOnBlocks::BlobStoreOnBlocks(unique_ptr blockStore, uint32_t blocksizeBytes) : _dataTreeStore(make_unique(make_unique(make_unique(make_unique(std::move(blockStore)), blocksizeBytes)))) { } BlobStoreOnBlocks::~BlobStoreOnBlocks() { } unique_ref BlobStoreOnBlocks::create() { return make_unique_ref(_dataTreeStore->createNewTree()); } optional> BlobStoreOnBlocks::load(const Key &key) { auto tree = _dataTreeStore->load(key); if (tree == nullptr) { return none; } return optional>(make_unique_ref(std::move(tree))); } void BlobStoreOnBlocks::remove(unique_ref blob) { auto _blob = dynamic_pointer_move(blob); assert(_blob != none); _dataTreeStore->remove((*_blob)->releaseTree()); } } }