Delete dead code
This commit is contained in:
parent
3dd8b53366
commit
64c95230ca
@ -10,7 +10,6 @@ set(SOURCES
|
||||
implementations/onblocks/datanodestore/DataLeafNode.cpp
|
||||
implementations/onblocks/datanodestore/DataInnerNode.cpp
|
||||
implementations/onblocks/datanodestore/DataNodeStore.cpp
|
||||
implementations/onblocks/datatreestore/impl/algorithms.cpp
|
||||
implementations/onblocks/datatreestore/impl/CachedValue.cpp
|
||||
implementations/onblocks/datatreestore/impl/LeafTraverser.cpp
|
||||
implementations/onblocks/datatreestore/LeafHandle.cpp
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "../datanodestore/DataLeafNode.h"
|
||||
#include "../utils/Math.h"
|
||||
|
||||
#include "impl/algorithms.h"
|
||||
|
||||
#include <cpp-utils/pointer/cast.h>
|
||||
#include <cpp-utils/pointer/optional_ownership_ptr.h>
|
||||
#include <cmath>
|
||||
|
@ -1,69 +0,0 @@
|
||||
#include "algorithms.h"
|
||||
#include <cpp-utils/pointer/cast.h>
|
||||
#include <blockstore/utils/BlockId.h>
|
||||
|
||||
#include "../../datanodestore/DataInnerNode.h"
|
||||
#include "../../datanodestore/DataNodeStore.h"
|
||||
#include <cpp-utils/assert/assert.h>
|
||||
|
||||
using std::function;
|
||||
using cpputils::optional_ownership_ptr;
|
||||
using cpputils::dynamic_pointer_move;
|
||||
using cpputils::unique_ref;
|
||||
using blobstore::onblocks::datanodestore::DataInnerNode;
|
||||
using blobstore::onblocks::datanodestore::DataNode;
|
||||
using blobstore::onblocks::datanodestore::DataNodeStore;
|
||||
using blockstore::BlockId;
|
||||
using boost::optional;
|
||||
using boost::none;
|
||||
|
||||
namespace blobstore {
|
||||
namespace onblocks {
|
||||
namespace datatreestore {
|
||||
namespace algorithms {
|
||||
|
||||
optional<unique_ref<DataInnerNode>> getLastChildAsInnerNode(DataNodeStore *nodeStore, const DataInnerNode &node) {
|
||||
BlockId blockId = node.readLastChild().blockId();
|
||||
auto lastChild = nodeStore->load(blockId);
|
||||
ASSERT(lastChild != none, "Couldn't load last child");
|
||||
return dynamic_pointer_move<DataInnerNode>(*lastChild);
|
||||
}
|
||||
|
||||
//Returns the lowest right border node meeting the condition specified (exclusive the leaf).
|
||||
//Returns nullptr, if no inner right border node meets the condition.
|
||||
optional_ownership_ptr<DataInnerNode> GetLowestInnerRightBorderNodeWithConditionOrNull(DataNodeStore *nodeStore, datanodestore::DataNode *rootNode, function<bool(const DataInnerNode &)> condition) {
|
||||
optional_ownership_ptr<DataInnerNode> currentNode = cpputils::WithoutOwnership(dynamic_cast<DataInnerNode*>(rootNode));
|
||||
optional_ownership_ptr<DataInnerNode> result = cpputils::null<DataInnerNode>();
|
||||
for (unsigned int i=0; i < rootNode->depth(); ++i) {
|
||||
//TODO This unnecessarily loads the leaf node in the last loop run
|
||||
auto lastChild = getLastChildAsInnerNode(nodeStore, *currentNode);
|
||||
if (condition(*currentNode)) {
|
||||
result = std::move(currentNode);
|
||||
}
|
||||
if (lastChild == none) {
|
||||
// lastChild is a leaf
|
||||
ASSERT(static_cast<int>(i) == rootNode->depth()-1, "Couldn't get last child as inner node but we're not deep enough yet for the last child to be a leaf");
|
||||
break;
|
||||
}
|
||||
currentNode = cpputils::WithOwnership(std::move(*lastChild));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
optional_ownership_ptr<DataInnerNode> GetLowestRightBorderNodeWithMoreThanOneChildOrNull(DataNodeStore *nodeStore, DataNode *rootNode) {
|
||||
return GetLowestInnerRightBorderNodeWithConditionOrNull(nodeStore, rootNode, [] (const datanodestore::DataInnerNode &node) {
|
||||
return node.numChildren() > 1;
|
||||
});
|
||||
}
|
||||
|
||||
optional_ownership_ptr<datanodestore::DataInnerNode> GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(datanodestore::DataNodeStore *nodeStore, datanodestore::DataNode *rootNode) {
|
||||
return GetLowestInnerRightBorderNodeWithConditionOrNull(nodeStore, rootNode, [] (const datanodestore::DataInnerNode &node) {
|
||||
return node.numChildren() < node.maxStoreableChildren();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATATREESTORE_IMPL_ALGORITHMS_H_
|
||||
#define MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_DATATREESTORE_IMPL_ALGORITHMS_H_
|
||||
|
||||
#include <cpp-utils/pointer/optional_ownership_ptr.h>
|
||||
|
||||
namespace blobstore {
|
||||
namespace onblocks {
|
||||
namespace datanodestore{
|
||||
class DataNode;
|
||||
class DataInnerNode;
|
||||
class DataNodeStore;
|
||||
}
|
||||
namespace datatreestore {
|
||||
namespace algorithms {
|
||||
|
||||
//Returns the lowest right border node with at least two children.
|
||||
//Returns nullptr, if all right border nodes have only one child (since the root is a right border node, this means that the whole tree has exactly one leaf)
|
||||
cpputils::optional_ownership_ptr<datanodestore::DataInnerNode> GetLowestRightBorderNodeWithMoreThanOneChildOrNull(datanodestore::DataNodeStore *nodeStore, datanodestore::DataNode *rootNode);
|
||||
|
||||
//Returns the lowest right border node with less than k children (not considering leaves).
|
||||
//Returns nullptr, if all right border nodes have k children (the tree is full)
|
||||
cpputils::optional_ownership_ptr<datanodestore::DataInnerNode> GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(datanodestore::DataNodeStore *nodeStore, datanodestore::DataNode *rootNode);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -12,8 +12,6 @@ set(SOURCES
|
||||
implementations/onblocks/datanodestore/DataNodeViewTest.cpp
|
||||
implementations/onblocks/datanodestore/DataNodeStoreTest.cpp
|
||||
implementations/onblocks/datatreestore/testutils/DataTreeTest.cpp
|
||||
implementations/onblocks/datatreestore/impl/GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest.cpp
|
||||
implementations/onblocks/datatreestore/impl/GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest.cpp
|
||||
implementations/onblocks/datatreestore/DataTreeTest_Performance.cpp
|
||||
implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp
|
||||
implementations/onblocks/datatreestore/DataTreeTest_NumStoredBytes.cpp
|
||||
|
@ -1,87 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../testutils/DataTreeTest.h"
|
||||
#include "blobstore/implementations/onblocks/datatreestore/DataTree.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataLeafNode.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataInnerNode.h"
|
||||
#include <blockstore/implementations/testfake/FakeBlockStore.h>
|
||||
#include "blobstore/implementations/onblocks/datatreestore/impl/algorithms.h"
|
||||
|
||||
|
||||
using blockstore::BlockId;
|
||||
using cpputils::Data;
|
||||
using namespace blobstore::onblocks::datatreestore::algorithms;
|
||||
|
||||
class GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest: public DataTreeTest {
|
||||
public:
|
||||
struct TestData {
|
||||
BlockId rootNode;
|
||||
BlockId expectedResult;
|
||||
};
|
||||
|
||||
void check(const TestData &testData) {
|
||||
auto root = nodeStore->load(testData.rootNode).value();
|
||||
auto result = GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(nodeStore, root.get());
|
||||
EXPECT_EQ(testData.expectedResult, result->blockId());
|
||||
}
|
||||
|
||||
TestData CreateTwoRightBorderNodes() {
|
||||
auto node = CreateInner({CreateLeaf()});
|
||||
return TestData{node->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateThreeRightBorderNodes() {
|
||||
auto node = CreateInner({CreateLeaf()});
|
||||
auto root = CreateInner({node.get()});
|
||||
return TestData{root->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateThreeRightBorderNodes_LastFull() {
|
||||
auto root = CreateInner({CreateFullTwoLevel()});
|
||||
return TestData{root->blockId(), root->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateLargerTree() {
|
||||
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||
return TestData{root->blockId(), node->blockId()};
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, Leaf) {
|
||||
auto leaf = nodeStore->createNewLeafNode(Data(0));
|
||||
auto result = GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(nodeStore, leaf.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, TwoRightBorderNodes) {
|
||||
auto testData = CreateTwoRightBorderNodes();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, ThreeRightBorderNodes) {
|
||||
auto testData = CreateThreeRightBorderNodes();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, ThreeRightBorderNodes_LastFull) {
|
||||
auto testData = CreateThreeRightBorderNodes_LastFull();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, LargerTree) {
|
||||
auto testData = CreateLargerTree();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, FullTwoLevelTree) {
|
||||
auto root = CreateFullTwoLevel();
|
||||
auto result = GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(nodeStore, root.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
TEST_F(GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNullTest, FullThreeLevelTree) {
|
||||
auto root = CreateFullThreeLevel();
|
||||
auto result = GetLowestInnerRightBorderNodeWithLessThanKChildrenOrNull(nodeStore, root.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../testutils/DataTreeTest.h"
|
||||
#include "blobstore/implementations/onblocks/datatreestore/DataTree.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataLeafNode.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataInnerNode.h"
|
||||
#include <blockstore/implementations/testfake/FakeBlockStore.h>
|
||||
#include "blobstore/implementations/onblocks/datatreestore/impl/algorithms.h"
|
||||
|
||||
|
||||
using blockstore::BlockId;
|
||||
using namespace blobstore::onblocks::datatreestore::algorithms;
|
||||
|
||||
class GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest: public DataTreeTest {
|
||||
public:
|
||||
struct TestData {
|
||||
BlockId rootNode;
|
||||
BlockId expectedResult;
|
||||
};
|
||||
|
||||
void check(const TestData &testData) {
|
||||
auto root = nodeStore->load(testData.rootNode).value();
|
||||
auto result = GetLowestRightBorderNodeWithMoreThanOneChildOrNull(nodeStore, root.get());
|
||||
EXPECT_EQ(testData.expectedResult, result->blockId());
|
||||
}
|
||||
|
||||
BlockId CreateLeafOnlyTree() {
|
||||
return CreateLeaf()->blockId();
|
||||
}
|
||||
|
||||
BlockId CreateTwoRightBorderNodes() {
|
||||
return CreateInner({CreateLeaf()})->blockId();
|
||||
}
|
||||
|
||||
BlockId CreateThreeRightBorderNodes() {
|
||||
return CreateInner({CreateInner({CreateLeaf()})})->blockId();
|
||||
}
|
||||
|
||||
TestData CreateThreeRightBorderNodes_LastFull() {
|
||||
auto node = CreateFullTwoLevel();
|
||||
auto root = CreateInner({node.get()});
|
||||
return TestData{root->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateLargerTree() {
|
||||
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||
return TestData{root->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateThreeLevelTreeWithRightBorderSingleNodeChain() {
|
||||
auto root = CreateInner({CreateFullTwoLevel(), CreateInner({CreateLeaf()})});
|
||||
return TestData{root->blockId(), root->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateThreeLevelTree() {
|
||||
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||
return TestData{root->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateFullTwoLevelTree() {
|
||||
auto node = CreateFullTwoLevel();
|
||||
return TestData{node->blockId(), node->blockId()};
|
||||
}
|
||||
|
||||
TestData CreateFullThreeLevelTree() {
|
||||
auto root = CreateFullThreeLevel();
|
||||
return TestData{root->blockId(), root->readLastChild().blockId()};
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, Leaf) {
|
||||
auto leaf = nodeStore->load(CreateLeafOnlyTree()).value();
|
||||
auto result = GetLowestRightBorderNodeWithMoreThanOneChildOrNull(nodeStore, leaf.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, TwoRightBorderNodes) {
|
||||
auto node = nodeStore->load(CreateTwoRightBorderNodes()).value();
|
||||
auto result = GetLowestRightBorderNodeWithMoreThanOneChildOrNull(nodeStore, node.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, ThreeRightBorderNodes) {
|
||||
auto node = nodeStore->load(CreateThreeRightBorderNodes()).value();
|
||||
auto result = GetLowestRightBorderNodeWithMoreThanOneChildOrNull(nodeStore, node.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, ThreeRightBorderNodes_LastFull) {
|
||||
auto testData = CreateThreeRightBorderNodes_LastFull();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, LargerTree) {
|
||||
auto testData = CreateLargerTree();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, FullTwoLevelTree) {
|
||||
auto testData = CreateFullTwoLevelTree();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, FullThreeLevelTree) {
|
||||
auto testData = CreateFullThreeLevelTree();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, ThreeLevelTreeWithRightBorderSingleNodeChain) {
|
||||
auto testData = CreateThreeLevelTreeWithRightBorderSingleNodeChain();
|
||||
check(testData);
|
||||
}
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithMoreThanOneChildOrNullTest, ThreeLevelTree) {
|
||||
auto testData = CreateThreeLevelTree();
|
||||
check(testData);
|
||||
}
|
Loading…
Reference in New Issue
Block a user