Repository: marmotta
Updated Branches:
  refs/heads/develop 6be5dc757 -> 5491d5fd0


Ostrich: remove URI compression code, as it is currently not fully implemented


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/5491d5fd
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/5491d5fd
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/5491d5fd

Branch: refs/heads/develop
Commit: 5491d5fd0aedfbde6cce00d7b41fe40b626b1431
Parents: 6be5dc7
Author: Sebastian Schaffert <[email protected]>
Authored: Sun Nov 20 14:47:42 2016 +0100
Committer: Sebastian Schaffert <[email protected]>
Committed: Sun Nov 20 14:47:42 2016 +0100

----------------------------------------------------------------------
 .../ostrich/backend/model/rdf_namespaces.cc     |  26 ++++
 .../ostrich/backend/model/rdf_namespaces.h      | 120 +++++++++++++++++++
 .../backend/persistence/base_persistence.cc     |  28 -----
 .../backend/persistence/base_persistence.h      | 118 ------------------
 .../backend/persistence/leveldb_persistence.cc  |   1 -
 libraries/ostrich/backend/test/CMakeLists.txt   |   2 +-
 libraries/ostrich/backend/test/NamespaceTest.cc |  65 ++++++++++
 .../ostrich/backend/test/PersistenceTest.cc     |  51 --------
 8 files changed, 212 insertions(+), 199 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/model/rdf_namespaces.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/model/rdf_namespaces.cc 
b/libraries/ostrich/backend/model/rdf_namespaces.cc
index 3f54017..ba54dc1 100644
--- a/libraries/ostrich/backend/model/rdf_namespaces.cc
+++ b/libraries/ostrich/backend/model/rdf_namespaces.cc
@@ -37,6 +37,32 @@ const std::map<std::string, std::string>& 
NamespacesByPrefix() {
     return kNamespacePrefixes;
 }
 
+// Apply prefix substitution for well-known URIs to save disk space.
+// Modifies the string passed as argument.
+void EncodeWellknownURI(std::string* uri) {
+    for (auto& ns : NamespacesByPrefix()) {
+        if (uri->compare(0, ns.second.size(), ns.second) == 0) {
+            std::string tmp = ns.first;
+            tmp += uri->substr(ns.second.size());
+            uri->swap(tmp);
+            return;
+        }
+    }
+}
+
+// Unapply prefix substitution for well-known URIs.
+// Modifies the string passed as argument.
+void DecodeWellknownURI(std::string* uri) {
+    for (auto& ns : NamespacesByPrefix()) {
+        if (uri->compare(0, ns.first.size(), ns.first) == 0) {
+            std::string tmp = ns.second;
+            tmp += uri->substr(ns.first.size());
+            uri->swap(tmp);
+            return;
+        }
+    }
+}
+
 }  // namespace rdf
 }  // namespace marmotta
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/model/rdf_namespaces.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/model/rdf_namespaces.h 
b/libraries/ostrich/backend/model/rdf_namespaces.h
index 793ac2f..126dc2b 100644
--- a/libraries/ostrich/backend/model/rdf_namespaces.h
+++ b/libraries/ostrich/backend/model/rdf_namespaces.h
@@ -21,6 +21,8 @@
 #include <map>
 #include <string>
 
+#include "model/rdf_model.h"
+
 // Contains maps of well-known default namespaces.
 namespace marmotta {
 namespace rdf {
@@ -29,6 +31,124 @@ namespace rdf {
 // namespace URI.
 const std::map<std::string, std::string>& NamespacesByPrefix();
 
+// Apply prefix substitution for well-known URIs to save disk space.
+// Modifies the string passed as argument.
+void EncodeWellknownURI(std::string* uri);
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Replaces the uri string of the URI with the encoded one
+inline void EncodeWellknownURI(proto::URI* value){
+    EncodeWellknownURI(value->mutable_uri());
+}
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Replaces the uri string of the type URI with the encoded one
+inline void EncodeWellknownURI(proto::DatatypeLiteral* value) {
+    EncodeWellknownURI(value->mutable_datatype());
+}
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Cases:
+// - value is a URI: replace the uri string with the encoded one
+// - otherwise: do nothing
+inline void EncodeWellknownURI(proto::Resource* value) {
+    if (value->has_uri()) {
+        EncodeWellknownURI(value->mutable_uri());
+    }
+}
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Cases:
+// - value is a URI: replace the uri string with the encoded one
+// - value is a DatatypeLiteral: replace type URI with encoded one
+// - otherwise: do nothing
+inline void EncodeWellknownURI(proto::Value* value) {
+    if (value->has_resource()) {
+        EncodeWellknownURI(value->mutable_resource());
+    } else if (value->has_literal() && 
value->mutable_literal()->has_dataliteral()) {
+        EncodeWellknownURI(value->mutable_literal()->mutable_dataliteral());
+    }
+}
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Performs prefix substitution for subject, predicate, object and context.
+inline void EncodeWellknownURI(proto::Statement* stmt) {
+    if (stmt->has_subject()) {
+        EncodeWellknownURI(stmt->mutable_subject());
+    }
+    if (stmt->has_predicate()) {
+        EncodeWellknownURI(stmt->mutable_predicate());
+    }
+    if (stmt->has_object()) {
+        EncodeWellknownURI(stmt->mutable_object());
+    }
+    if (stmt->has_context()) {
+        EncodeWellknownURI(stmt->mutable_context());
+    }
+}
+
+// Compatibility placeholder, does nothing for namespaces.
+inline void EncodeWellknownURI(proto::Namespace* ns) {}
+
+// Unapply prefix substitution for well-known URIs.
+// Modifies the string passed as argument.
+void DecodeWellknownURI(std::string* uri);
+
+// Unapply prefix substitution for well-known URIs.
+// Replaces the uri string of the URI with the decoded one
+inline void DecodeWellknownURI(proto::URI* value){
+    DecodeWellknownURI(value->mutable_uri());
+}
+
+// Unapply prefix substitution for well-known URIs.
+// Replaces the uri string of the type URI with the decoded one
+inline void DecodeWellknownURI(proto::DatatypeLiteral* value) {
+    DecodeWellknownURI(value->mutable_datatype());
+}
+
+// Unapply prefix substitution for well-known URIs.
+// Cases:
+// - value is a URI: replace the uri string with the decoded one
+// - otherwise: do nothing
+inline void DecodeWellknownURI(proto::Resource* value) {
+    if (value->has_uri()) {
+        DecodeWellknownURI(value->mutable_uri());
+    }
+}
+
+// Unapply prefix substitution for well-known URIs.
+// Cases:
+// - value is a URI: replace the uri string with the decoded one
+// - value is a DatatypeLiteral: replace type URI with decoded one
+// - otherwise: do nothing
+inline void DecodeWellknownURI(proto::Value* value) {
+    if (value->has_resource()) {
+        DecodeWellknownURI(value->mutable_resource());
+    } else if (value->has_literal() && 
value->mutable_literal()->has_dataliteral()) {
+        DecodeWellknownURI(value->mutable_literal()->mutable_dataliteral());
+    }
+}
+
+// Apply prefix substitution for well-known URIs to save disk space.
+// Performs prefix substitution for subject, predicate, object and context.
+inline void DecodeWellknownURI(proto::Statement* stmt) {
+    if (stmt->has_subject()) {
+        DecodeWellknownURI(stmt->mutable_subject());
+    }
+    if (stmt->has_predicate()) {
+        DecodeWellknownURI(stmt->mutable_predicate());
+    }
+    if (stmt->has_object()) {
+        DecodeWellknownURI(stmt->mutable_object());
+    }
+    if (stmt->has_context()) {
+        DecodeWellknownURI(stmt->mutable_context());
+    }
+}
+
+// Compatibility placeholder, does nothing for namespaces.
+inline void DecodeWellknownURI(proto::Namespace* ns) {}
+
 }  // namespace rdf
 }  // namespace marmotta
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/persistence/base_persistence.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/base_persistence.cc 
b/libraries/ostrich/backend/persistence/base_persistence.cc
index ce1727b..1358763 100644
--- a/libraries/ostrich/backend/persistence/base_persistence.cc
+++ b/libraries/ostrich/backend/persistence/base_persistence.cc
@@ -188,34 +188,6 @@ bool Matches(const Statement& pattern, const Statement& 
stmt) {
     }
     return !(pattern.has_object() && stmt.object() != pattern.object());
 }
-
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Modifies the string passed as argument.
-void EncodeWellknownURI(std::string* uri) {
-    for (auto& ns : rdf::NamespacesByPrefix()) {
-        if (uri->compare(0, ns.second.size(), ns.second) == 0) {
-            std::string tmp = ns.first;
-            tmp += uri->substr(ns.second.size());
-            uri->swap(tmp);
-            return;
-        }
-    }
-}
-
-// Unapply prefix substitution for well-known URIs.
-// Modifies the string passed as argument.
-void DecodeWellknownURI(std::string* uri) {
-    for (auto& ns : rdf::NamespacesByPrefix()) {
-        if (uri->compare(0, ns.first.size(), ns.first) == 0) {
-            std::string tmp = ns.second;
-            tmp += uri->substr(ns.first.size());
-            uri->swap(tmp);
-            return;
-        }
-    }
-}
-
 }  // namespace persistence
 }  // namespace marmotta
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/persistence/base_persistence.h
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/base_persistence.h 
b/libraries/ostrich/backend/persistence/base_persistence.h
index f1cc494..d182518 100644
--- a/libraries/ostrich/backend/persistence/base_persistence.h
+++ b/libraries/ostrich/backend/persistence/base_persistence.h
@@ -27,123 +27,6 @@
 namespace marmotta {
 namespace persistence {
 
-// Apply prefix substitution for well-known URIs to save disk space.
-// Modifies the string passed as argument.
-void EncodeWellknownURI(std::string* uri);
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Replaces the uri string of the URI with the encoded one
-inline void EncodeWellknownURI(rdf::proto::URI* value){
-    EncodeWellknownURI(value->mutable_uri());
-}
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Replaces the uri string of the type URI with the encoded one
-inline void EncodeWellknownURI(rdf::proto::DatatypeLiteral* value) {
-    EncodeWellknownURI(value->mutable_datatype());
-}
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Cases:
-// - value is a URI: replace the uri string with the encoded one
-// - otherwise: do nothing
-inline void EncodeWellknownURI(rdf::proto::Resource* value) {
-    if (value->has_uri()) {
-        EncodeWellknownURI(value->mutable_uri());
-    }
-}
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Cases:
-// - value is a URI: replace the uri string with the encoded one
-// - value is a DatatypeLiteral: replace type URI with encoded one
-// - otherwise: do nothing
-inline void EncodeWellknownURI(rdf::proto::Value* value) {
-    if (value->has_resource()) {
-        EncodeWellknownURI(value->mutable_resource());
-    } else if (value->has_literal() && 
value->mutable_literal()->has_dataliteral()) {
-        EncodeWellknownURI(value->mutable_literal()->mutable_dataliteral());
-    }
-}
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Performs prefix substitution for subject, predicate, object and context.
-inline void EncodeWellknownURI(rdf::proto::Statement* stmt) {
-    if (stmt->has_subject()) {
-        EncodeWellknownURI(stmt->mutable_subject());
-    }
-    if (stmt->has_predicate()) {
-        EncodeWellknownURI(stmt->mutable_predicate());
-    }
-    if (stmt->has_object()) {
-        EncodeWellknownURI(stmt->mutable_object());
-    }
-    if (stmt->has_context()) {
-        EncodeWellknownURI(stmt->mutable_context());
-    }
-}
-
-// Compatibility placeholder, does nothing for namespaces.
-inline void EncodeWellknownURI(rdf::proto::Namespace* ns) {}
-
-// Unapply prefix substitution for well-known URIs.
-// Modifies the string passed as argument.
-void DecodeWellknownURI(std::string* uri);
-
-// Unapply prefix substitution for well-known URIs.
-// Replaces the uri string of the URI with the decoded one
-inline void DecodeWellknownURI(rdf::proto::URI* value){
-    DecodeWellknownURI(value->mutable_uri());
-}
-
-// Unapply prefix substitution for well-known URIs.
-// Replaces the uri string of the type URI with the decoded one
-inline void DecodeWellknownURI(rdf::proto::DatatypeLiteral* value) {
-    DecodeWellknownURI(value->mutable_datatype());
-}
-
-// Unapply prefix substitution for well-known URIs.
-// Cases:
-// - value is a URI: replace the uri string with the decoded one
-// - otherwise: do nothing
-inline void DecodeWellknownURI(rdf::proto::Resource* value) {
-    if (value->has_uri()) {
-        DecodeWellknownURI(value->mutable_uri());
-    }
-}
-
-// Unapply prefix substitution for well-known URIs.
-// Cases:
-// - value is a URI: replace the uri string with the decoded one
-// - value is a DatatypeLiteral: replace type URI with decoded one
-// - otherwise: do nothing
-inline void DecodeWellknownURI(rdf::proto::Value* value) {
-    if (value->has_resource()) {
-        DecodeWellknownURI(value->mutable_resource());
-    } else if (value->has_literal() && 
value->mutable_literal()->has_dataliteral()) {
-        DecodeWellknownURI(value->mutable_literal()->mutable_dataliteral());
-    }
-}
-
-// Apply prefix substitution for well-known URIs to save disk space.
-// Performs prefix substitution for subject, predicate, object and context.
-inline void DecodeWellknownURI(rdf::proto::Statement* stmt) {
-    if (stmt->has_subject()) {
-        DecodeWellknownURI(stmt->mutable_subject());
-    }
-    if (stmt->has_predicate()) {
-        DecodeWellknownURI(stmt->mutable_predicate());
-    }
-    if (stmt->has_object()) {
-        DecodeWellknownURI(stmt->mutable_object());
-    }
-    if (stmt->has_context()) {
-        DecodeWellknownURI(stmt->mutable_context());
-    }
-}
-
-// Compatibility placeholder, does nothing for namespaces.
-inline void DecodeWellknownURI(rdf::proto::Namespace* ns) {}
 
 // Length of key in bytes per field S, P, O and C.
 constexpr int kKeyLength = 16;
@@ -307,7 +190,6 @@ class DBIterator : public util::CloseableIterator<T> {
     const T& next() override {
         // Parse current position, then iterate to next position for next call.
         proto.ParseFromString(it->value().ToString());
-        DecodeWellknownURI(&proto);
         it->Next();
         return proto;
     };

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/persistence/leveldb_persistence.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/persistence/leveldb_persistence.cc 
b/libraries/ostrich/backend/persistence/leveldb_persistence.cc
index a14542b..c84c57c 100644
--- a/libraries/ostrich/backend/persistence/leveldb_persistence.cc
+++ b/libraries/ostrich/backend/persistence/leveldb_persistence.cc
@@ -498,7 +498,6 @@ int64_t LevelDBPersistence::RemoveStatements(
 
     int64_t count = 0;
 
-    std::string bufs, bufp, bufo, bufc;
     GetStatements(pattern, [&](const Statement stmt) -> bool {
         Key key(stmt);
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/test/CMakeLists.txt 
b/libraries/ostrich/backend/test/CMakeLists.txt
index a24e395..8aaf419 100644
--- a/libraries/ostrich/backend/test/CMakeLists.txt
+++ b/libraries/ostrich/backend/test/CMakeLists.txt
@@ -6,7 +6,7 @@ include_directories(${RAPTOR_INCLUDE_DIR}/raptor2)
 
 add_library(gtest STATIC gtest/gtest.h gmock/gmock.h gmock-gtest-all.cc)
 
-add_executable(model_tests StatementTest.cc main.cc)
+add_executable(model_tests NamespaceTest.cc StatementTest.cc main.cc)
 target_link_libraries(model_tests gtest marmotta_model ${GLOG_LIBRARY})
 
 add_executable(sparql_tests SparqlTest.cc main.cc)

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/test/NamespaceTest.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/test/NamespaceTest.cc 
b/libraries/ostrich/backend/test/NamespaceTest.cc
new file mode 100644
index 0000000..9fc37e3
--- /dev/null
+++ b/libraries/ostrich/backend/test/NamespaceTest.cc
@@ -0,0 +1,65 @@
+//
+// Created by wastl on 18.04.15.
+//
+
+#include "gtest/gtest.h"
+#include "model/rdf_model.h"
+#include "model/rdf_operators.h"
+#include "model/rdf_namespaces.h"
+
+namespace marmotta {
+namespace rdf {
+
+TEST(NamespaceTest, EncodeURI) {
+    std::string uri1 = "http://www.w3.org/2002/07/owl#sameAs";;
+    std::string uri2 = "http://marmotta.apache.org/test/uri1";;
+
+    EncodeWellknownURI(&uri1);
+    EXPECT_EQ("owl:sameAs", uri1);
+
+    EncodeWellknownURI(&uri2);
+    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, uri2);
+}
+
+TEST(NamespaceTest, EncodeURIProto) {
+    rdf::URI uri1 = "http://www.w3.org/2002/07/owl#sameAs";;
+    rdf::URI uri2 = "http://marmotta.apache.org/test/uri1";;
+
+    rdf::proto::URI msg1 = uri1.getMessage();
+    rdf::proto::URI msg2 = uri2.getMessage();
+
+    EncodeWellknownURI(&msg1);
+    EXPECT_EQ("owl:sameAs", msg1.uri());
+
+    EncodeWellknownURI(&msg2);
+    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, msg2.uri());
+}
+
+
+TEST(NamespaceTest, DecodeURI) {
+    std::string uri1 = "owl:sameAs";
+    std::string uri2 = "http://marmotta.apache.org/test/uri1";;
+
+    DecodeWellknownURI(&uri1);
+    EXPECT_EQ("http://www.w3.org/2002/07/owl#sameAs";, uri1);
+
+    DecodeWellknownURI(&uri2);
+    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, uri2);
+}
+
+TEST(NamespaceTest, DecodeURIProto) {
+    rdf::URI uri1 = "owl:sameAs";
+    rdf::URI uri2 = "http://marmotta.apache.org/test/uri1";;
+
+    rdf::proto::URI msg1 = uri1.getMessage();
+    rdf::proto::URI msg2 = uri2.getMessage();
+
+    DecodeWellknownURI(&msg1);
+    EXPECT_EQ("http://www.w3.org/2002/07/owl#sameAs";, msg1.uri());
+
+    DecodeWellknownURI(&msg2);
+    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, msg2.uri());
+}
+
+}  // namespace rdf
+}  // namespace marmotta
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5491d5fd/libraries/ostrich/backend/test/PersistenceTest.cc
----------------------------------------------------------------------
diff --git a/libraries/ostrich/backend/test/PersistenceTest.cc 
b/libraries/ostrich/backend/test/PersistenceTest.cc
index 7f37d92..5626adb 100644
--- a/libraries/ostrich/backend/test/PersistenceTest.cc
+++ b/libraries/ostrich/backend/test/PersistenceTest.cc
@@ -60,57 +60,6 @@ TEST(KeyTest, BoundsDiffer) {
     }
 }
 
-TEST(URITest, EncodeURI) {
-    std::string uri1 = "http://www.w3.org/2002/07/owl#sameAs";;
-    std::string uri2 = "http://marmotta.apache.org/test/uri1";;
-
-    EncodeWellknownURI(&uri1);
-    EXPECT_EQ("owl:sameAs", uri1);
-
-    EncodeWellknownURI(&uri2);
-    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, uri2);
-}
-
-TEST(URITest, EncodeURIProto) {
-    rdf::URI uri1 = "http://www.w3.org/2002/07/owl#sameAs";;
-    rdf::URI uri2 = "http://marmotta.apache.org/test/uri1";;
-
-    rdf::proto::URI msg1 = uri1.getMessage();
-    rdf::proto::URI msg2 = uri2.getMessage();
-
-    EncodeWellknownURI(&msg1);
-    EXPECT_EQ("owl:sameAs", msg1.uri());
-
-    EncodeWellknownURI(&msg2);
-    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, msg2.uri());
-}
-
-
-TEST(URITest, DecodeURI) {
-    std::string uri1 = "owl:sameAs";
-    std::string uri2 = "http://marmotta.apache.org/test/uri1";;
-
-    DecodeWellknownURI(&uri1);
-    EXPECT_EQ("http://www.w3.org/2002/07/owl#sameAs";, uri1);
-
-    DecodeWellknownURI(&uri2);
-    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, uri2);
-}
-
-TEST(URITest, DecodeURIProto) {
-    rdf::URI uri1 = "owl:sameAs";
-    rdf::URI uri2 = "http://marmotta.apache.org/test/uri1";;
-
-    rdf::proto::URI msg1 = uri1.getMessage();
-    rdf::proto::URI msg2 = uri2.getMessage();
-
-    DecodeWellknownURI(&msg1);
-    EXPECT_EQ("http://www.w3.org/2002/07/owl#sameAs";, msg1.uri());
-
-    DecodeWellknownURI(&msg2);
-    EXPECT_EQ("http://marmotta.apache.org/test/uri1";, msg2.uri());
-}
-
 
 }  // namespace test
 }  // namespace persistence

Reply via email to