data: performance optimization NameHierarchy
* For performance reasons nodes now store a serialized version of their name hierarchy directly. Removed NameHierarchy table from database.
This commit is contained in:
@@ -8,94 +8,6 @@
|
||||
class SqliteStorageTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_storage_adds_name_hierarchy_element_successfully()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int elementCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
storage.addNameHierarchyElement("a");
|
||||
storage.commitTransaction();
|
||||
elementCount = storage.getNameHierarchyElementCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(1, elementCount);
|
||||
}
|
||||
|
||||
void test_storage_removes_name_hierarchy_element_successfully()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int elementCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int elementId = storage.addNameHierarchyElement("a");
|
||||
storage.removeNameHierarchyElement(elementId);
|
||||
storage.commitTransaction();
|
||||
elementCount = storage.getNameHierarchyElementCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(0, elementCount);
|
||||
}
|
||||
|
||||
void test_storage_finds_name_hierarchy_elements_by_name()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int insertedElementId = -1;
|
||||
int foundElementId = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
insertedElementId = storage.addNameHierarchyElement("a");
|
||||
storage.commitTransaction();
|
||||
foundElementId = storage.getNameHierarchyElementIdByName("a");
|
||||
}
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT(foundElementId != -1);
|
||||
TS_ASSERT_EQUALS(insertedElementId, foundElementId);
|
||||
}
|
||||
|
||||
void test_storage_finds_name_hierarchy_elements_by_name_and_parent_id()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int insertedChildElementId = -1;
|
||||
int foundElementId = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int insertedParentElementId = storage.addNameHierarchyElement("a");
|
||||
insertedChildElementId = storage.addNameHierarchyElement("a", insertedParentElementId);
|
||||
storage.addNameHierarchyElement("a", storage.addNameHierarchyElement("b"));
|
||||
storage.commitTransaction();
|
||||
foundElementId = storage.getNameHierarchyElementIdByName("a", insertedParentElementId);
|
||||
}
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT(foundElementId != -1);
|
||||
TS_ASSERT_EQUALS(insertedChildElementId, foundElementId);
|
||||
}
|
||||
|
||||
void test_storage_automatically_removes_name_hierarchy_element_child_when_deleting_parent()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int elementCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int parentId = storage.addNameHierarchyElement("a");
|
||||
storage.removeNameHierarchyElement(parentId);
|
||||
storage.commitTransaction();
|
||||
elementCount = storage.getNameHierarchyElementCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(0, elementCount);
|
||||
}
|
||||
|
||||
void test_storage_adds_node_successfully()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
@@ -103,8 +15,7 @@ public:
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int nameId = storage.addNameHierarchyElement("a");
|
||||
storage.addNode(0, nameId, false);
|
||||
storage.addNode(0, "a", false);
|
||||
storage.commitTransaction();
|
||||
nodeCount = storage.getNodeCount();
|
||||
}
|
||||
@@ -120,8 +31,7 @@ public:
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int nameId = storage.addNameHierarchyElement("a");
|
||||
int nodeId = storage.addNode(0, nameId, false);
|
||||
int nodeId = storage.addNode(0, "a", false);
|
||||
storage.removeElement(nodeId);
|
||||
storage.commitTransaction();
|
||||
nodeCount = storage.getNodeCount();
|
||||
@@ -138,10 +48,8 @@ public:
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int sourceNameId = storage.addNameHierarchyElement("a");
|
||||
int sourceNodeId = storage.addNode(0, sourceNameId, false);
|
||||
int targetNameId = storage.addNameHierarchyElement("b");
|
||||
int targetNodeId = storage.addNode(0, targetNameId, false);
|
||||
int sourceNodeId = storage.addNode(0, "a", false);
|
||||
int targetNodeId = storage.addNode(0, "b", false);
|
||||
storage.addEdge(0, sourceNodeId, targetNodeId);
|
||||
storage.commitTransaction();
|
||||
edgeCount = storage.getEdgeCount();
|
||||
@@ -158,10 +66,8 @@ public:
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
storage.beginTransaction();
|
||||
int sourceNameId = storage.addNameHierarchyElement("a");
|
||||
int sourceNodeId = storage.addNode(0, sourceNameId, false);
|
||||
int targetNameId = storage.addNameHierarchyElement("b");
|
||||
int targetNodeId = storage.addNode(0, targetNameId, false);
|
||||
int sourceNodeId = storage.addNode(0, "a", false);
|
||||
int targetNodeId = storage.addNode(0, "b", false);
|
||||
int edgeId = storage.addEdge(0, sourceNodeId, targetNodeId);
|
||||
storage.removeElement(edgeId);
|
||||
storage.commitTransaction();
|
||||
|
||||
Reference in New Issue
Block a user