diff --git a/implementations/onblocks/datanodestore/DataInnerNode.cpp b/implementations/onblocks/datanodestore/DataInnerNode.cpp index e508b1c1..537e5d5d 100644 --- a/implementations/onblocks/datanodestore/DataInnerNode.cpp +++ b/implementations/onblocks/datanodestore/DataInnerNode.cpp @@ -20,7 +20,7 @@ DataInnerNode::DataInnerNode(DataNodeView view) DataInnerNode::~DataInnerNode() { } -unique_ref DataInnerNode::InitializeNewNode(unique_ptr block, const DataNode &first_child) { +unique_ref DataInnerNode::InitializeNewNode(unique_ref block, const DataNode &first_child) { DataNodeView node(std::move(block)); node.setDepth(first_child.depth() + 1); node.setSize(1); diff --git a/implementations/onblocks/datanodestore/DataInnerNode.h b/implementations/onblocks/datanodestore/DataInnerNode.h index 6f814390..31019748 100644 --- a/implementations/onblocks/datanodestore/DataInnerNode.h +++ b/implementations/onblocks/datanodestore/DataInnerNode.h @@ -11,7 +11,7 @@ namespace datanodestore { class DataInnerNode: public DataNode { public: - static cpputils::unique_ref InitializeNewNode(std::unique_ptr block, const DataNode &first_child_key); + static cpputils::unique_ref InitializeNewNode(cpputils::unique_ref block, const DataNode &first_child_key); DataInnerNode(DataNodeView block); virtual ~DataInnerNode(); diff --git a/implementations/onblocks/datanodestore/DataLeafNode.cpp b/implementations/onblocks/datanodestore/DataLeafNode.cpp index c88ee7f0..72ddbaf4 100644 --- a/implementations/onblocks/datanodestore/DataLeafNode.cpp +++ b/implementations/onblocks/datanodestore/DataLeafNode.cpp @@ -21,7 +21,7 @@ DataLeafNode::DataLeafNode(DataNodeView view) DataLeafNode::~DataLeafNode() { } -unique_ref DataLeafNode::InitializeNewNode(unique_ptr block) { +unique_ref DataLeafNode::InitializeNewNode(unique_ref block) { DataNodeView node(std::move(block)); node.setDepth(0); node.setSize(0); diff --git a/implementations/onblocks/datanodestore/DataLeafNode.h b/implementations/onblocks/datanodestore/DataLeafNode.h index f021d2a3..25e68059 100644 --- a/implementations/onblocks/datanodestore/DataLeafNode.h +++ b/implementations/onblocks/datanodestore/DataLeafNode.h @@ -11,7 +11,7 @@ class DataInnerNode; class DataLeafNode: public DataNode { public: - static cpputils::unique_ref InitializeNewNode(std::unique_ptr block); + static cpputils::unique_ref InitializeNewNode(cpputils::unique_ref block); DataLeafNode(DataNodeView block); virtual ~DataLeafNode(); diff --git a/implementations/onblocks/datanodestore/DataNodeStore.cpp b/implementations/onblocks/datanodestore/DataNodeStore.cpp index 513a6040..a8a57abe 100644 --- a/implementations/onblocks/datanodestore/DataNodeStore.cpp +++ b/implementations/onblocks/datanodestore/DataNodeStore.cpp @@ -30,7 +30,8 @@ DataNodeStore::~DataNodeStore() { unique_ref DataNodeStore::load(unique_ptr block) { assert(block->size() == _layout.blocksizeBytes()); - DataNodeView node(std::move(block)); + //TODO Don't use cpputils::nullcheck, but make the parameter a unique_ref + DataNodeView node(cpputils::nullcheck(std::move(block)).value()); if (node.Depth() == 0) { return make_unique_ref(std::move(node)); @@ -65,7 +66,8 @@ optional> DataNodeStore::load(const Key &key) { unique_ref DataNodeStore::createNewNodeAsCopyFrom(const DataNode &source) { assert(source.node().layout().blocksizeBytes() == _layout.blocksizeBytes()); // This might be violated if source is from a different DataNodeStore auto newBlock = blockstore::utils::copyToNewBlock(_blockstore.get(), source.node().block()); - return load(std::move(newBlock)); + //TODO Don't use to_unique_ptr + return load(cpputils::to_unique_ptr(std::move(newBlock))); } unique_ref DataNodeStore::overwriteNodeWith(unique_ref target, const DataNode &source) { @@ -85,7 +87,8 @@ unique_ref DataNodeStore::overwriteNodeWith(unique_ref targe void DataNodeStore::remove(unique_ref node) { auto block = node->node().releaseBlock(); cpputils::to_unique_ptr(std::move(node)).reset(); // Call destructor - _blockstore->remove(std::move(block)); + //TODO Don't use to_unique_ptr + _blockstore->remove(cpputils::to_unique_ptr(std::move(block))); } uint64_t DataNodeStore::numNodes() const { diff --git a/implementations/onblocks/datanodestore/DataNodeView.h b/implementations/onblocks/datanodestore/DataNodeView.h index 558f559b..5e342fba 100644 --- a/implementations/onblocks/datanodestore/DataNodeView.h +++ b/implementations/onblocks/datanodestore/DataNodeView.h @@ -6,7 +6,7 @@ #include "../BlobStoreOnBlocks.h" #include "DataInnerNode_ChildEntry.h" -#include "messmer/cpp-utils/macros.h" +#include #include #include @@ -59,7 +59,7 @@ private: class DataNodeView { public: - DataNodeView(std::unique_ptr block): _block(std::move(block)) { + DataNodeView(cpputils::unique_ref block): _block(std::move(block)) { } virtual ~DataNodeView() {} @@ -104,7 +104,7 @@ public: return DataNodeLayout(_block->size()); } - std::unique_ptr releaseBlock() { + cpputils::unique_ref releaseBlock() { return std::move(_block); } @@ -126,7 +126,7 @@ private: return (Type*)(((const int8_t*)_block->data())+offset); } - std::unique_ptr _block; + cpputils::unique_ref _block; DISALLOW_COPY_AND_ASSIGN(DataNodeView); diff --git a/test/implementations/onblocks/datanodestore/DataInnerNodeTest.cpp b/test/implementations/onblocks/datanodestore/DataInnerNodeTest.cpp index 134ed779..c45c66cd 100644 --- a/test/implementations/onblocks/datanodestore/DataInnerNodeTest.cpp +++ b/test/implementations/onblocks/datanodestore/DataInnerNodeTest.cpp @@ -135,7 +135,8 @@ TEST_F(DataInnerNodeTest, InitializesCorrectly) { TEST_F(DataInnerNodeTest, ReinitializesCorrectly) { auto key = InitializeInnerNodeAddLeafReturnKey(); - auto node = DataInnerNode::InitializeNewNode(blockStore->load(key), *leaf); + //TODO Don't use cpputils::nullcheck + auto node = DataInnerNode::InitializeNewNode(cpputils::nullcheck(blockStore->load(key)).value(), *leaf); EXPECT_EQ(1u, node->numChildren()); EXPECT_EQ(leaf->key(), node->getChild(0)->key()); diff --git a/test/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp b/test/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp index d70de338..4bf59ac6 100644 --- a/test/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp +++ b/test/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp @@ -140,7 +140,8 @@ TEST_F(DataLeafNodeTest, InitializesCorrectly) { TEST_F(DataLeafNodeTest, ReinitializesCorrectly) { auto key = InitializeLeafGrowAndReturnKey(); - auto leaf = DataLeafNode::InitializeNewNode(blockStore->load(key)); + //TODO Don't use nullcheck + auto leaf = DataLeafNode::InitializeNewNode(cpputils::nullcheck(blockStore->load(key)).value()); EXPECT_EQ(0u, leaf->numBytes()); } diff --git a/test/implementations/onblocks/datanodestore/DataNodeViewTest.cpp b/test/implementations/onblocks/datanodestore/DataNodeViewTest.cpp index bf43eb9f..04c4005c 100644 --- a/test/implementations/onblocks/datanodestore/DataNodeViewTest.cpp +++ b/test/implementations/onblocks/datanodestore/DataNodeViewTest.cpp @@ -40,7 +40,8 @@ TEST_P(DataNodeViewDepthTest, DepthIsStored) { DataNodeView view(std::move(block)); view.setDepth(GetParam()); } - DataNodeView view(blockStore->load(key)); + //TODO Don't use nullcheck + DataNodeView view(cpputils::nullcheck(blockStore->load(key)).value()); EXPECT_EQ(GetParam(), view.Depth()); } @@ -55,7 +56,8 @@ TEST_P(DataNodeViewSizeTest, SizeIsStored) { DataNodeView view(std::move(block)); view.setSize(GetParam()); } - DataNodeView view(blockStore->load(key)); + //TODO Don't use nullcheck + DataNodeView view(cpputils::nullcheck(blockStore->load(key)).value()); EXPECT_EQ(GetParam(), view.Size()); } @@ -67,7 +69,8 @@ TEST_F(DataNodeViewTest, DataIsStored) { DataNodeView view(std::move(block)); view.write(randomData.data(), 0, randomData.size()); } - DataNodeView view(blockStore->load(key)); + //TODO Don't use nullcheck + DataNodeView view(cpputils::nullcheck(blockStore->load(key)).value()); EXPECT_EQ(0, std::memcmp(view.data(), randomData.data(), randomData.size())); } @@ -76,12 +79,14 @@ TEST_F(DataNodeViewTest, HeaderAndBodyDontOverlap) { auto block = blockStore->create(Data(BLOCKSIZE_BYTES)); auto key = block->key(); { + //TODO Don't use nullcheck DataNodeView view(std::move(block)); view.setDepth(3); view.setSize(1000000000u); view.write(randomData.data(), 0, DATASIZE_BYTES); } - DataNodeView view(blockStore->load(key)); + //TODO Don't use nullcheck + DataNodeView view(cpputils::nullcheck(blockStore->load(key)).value()); EXPECT_EQ(3, view.Depth()); EXPECT_EQ(1000000000u, view.Size()); EXPECT_EQ(0, std::memcmp(view.data(), randomData.data(), DATASIZE_BYTES));