You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/11/06 16:40:24 UTC
[3/3] git commit: SPARQL: - fix results with invalid types - avoid
unnecessary joins with nodes table
SPARQL:
- fix results with invalid types
- avoid unnecessary joins with nodes table
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/d11b8e00
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/d11b8e00
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/d11b8e00
Branch: refs/heads/develop
Commit: d11b8e00908307e60ee6137fcfc62bdf8ea04a3e
Parents: 4d54fd9
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Nov 6 16:40:56 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Nov 6 16:40:56 2014 +0100
----------------------------------------------------------------------
.../kiwi/sparql/builder/ConditionFinder.java | 4 ++
.../persistence/KiWiSparqlConnection.java | 53 +++++++++++---------
2 files changed, 33 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d11b8e00/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/ConditionFinder.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/ConditionFinder.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/ConditionFinder.java
index f06baf7..7b0c8f6 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/ConditionFinder.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/ConditionFinder.java
@@ -60,6 +60,10 @@ public class ConditionFinder extends QueryModelVisitorBase<RuntimeException> {
}
}
+ @Override
+ public void meet(StatementPattern node) throws RuntimeException {
+ // stop, no condition
+ }
@Override
http://git-wip-us.apache.org/repos/asf/marmotta/blob/d11b8e00/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
index c352e0f..0c3322a 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
@@ -169,38 +169,43 @@ public class KiWiSparqlConnection {
if(svalue != null) {
- if (svalue.length() > 0) {
- // retrieve optional type and language information, because string functions
- // need to preserve this in certain cases, even when constructing new literals
- String lang = null;
- URI type = null;
- try {
- lang = row.getString(sv.getName() + "_LANG");
- } catch (SQLException ex) {
- }
+ // retrieve optional type and language information, because string functions
+ // need to preserve this in certain cases, even when constructing new literals
+ String lang = null;
+ URI type = null;
+ try {
+ lang = row.getString(sv.getName() + "_LANG");
+ } catch (SQLException ex) {
+ }
- try {
- long typeId = row.getLong(sv.getName() + "_TYPE");
- if (typeId > 0)
- type = (URI) parent.loadNodeById(typeId);
- } catch (SQLException ex) {
- }
+ try {
+ long typeId = row.getLong(sv.getName() + "_TYPE");
+ if (typeId > 0)
+ type = (URI) parent.loadNodeById(typeId);
+ } catch (SQLException ex) {
+ }
- if (lang != null) {
+ if (lang != null) {
+ if (svalue.length() > 0) {
resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(svalue, lang));
- } else if (type != null) {
- if(type.stringValue().equals(XSD.String.stringValue())) {
- // string functions on other datatypes than string should yield no binding
+ } else {
+ // string functions that return empty literal should yield no type or language
+ resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(""));
+ }
+ } else if (type != null) {
+ if(type.stringValue().equals(XSD.String.stringValue())) {
+ // string functions on other datatypes than string should yield no binding
+ if (svalue.length() > 0) {
resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(svalue, type));
+ } else {
+ // string functions that return empty literal should yield no type or language
+ resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(""));
}
- } else {
- resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(svalue));
}
-
} else {
- // string functions that return empty literal should yield no type or language
- resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(""));
+ resultRow.addBinding(sv.getSparqlName(), new LiteralImpl(svalue));
}
+
}
break;
}