[Mulgara-svn] r1994 - trunk/src/jar/tuples/java/org/mulgara/store/tuples
pag at mulgara.org
pag at mulgara.org
Fri Jul 15 03:20:20 UTC 2011
Author: pag
Date: 2011-07-15 03:20:20 +0000 (Fri, 15 Jul 2011)
New Revision: 1994
Modified:
trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
Log:
Fixed OPTIONAL joins where the RHS is empty. It now returns the LHS projected to include the RHS columns (when possible)
Modified: trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
===================================================================
--- trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2011-07-15 03:14:44 UTC (rev 1993)
+++ trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2011-07-15 03:20:20 UTC (rev 1994)
@@ -454,6 +454,17 @@
// check for empty parameters
if (logger.isDebugEnabled() && standard.getRowCardinality() == Cursor.ZERO) logger.debug("Nothing to the left of an optional");
+ // Checks if there is nothing on the RHS of the optional join
+ if (optional.isEmpty() || optional.getRowCardinality() == 0) {
+ // need to return standard, projected out to the extra variables
+ if (optional.getNumberOfVariables() == 0) {
+ // This may be empty due to having zero rows (since the columns are truncated in this case)
+ return (Tuples)standard.clone();
+ } else {
+ return project(standard, optional.getVariables());
+ }
+ }
+
// If the Optional clause does not have matching variables with the LHS
// then this is the equivalent to a normal join as a cartesian product
if (matchingVars.isEmpty()) {
@@ -470,16 +481,6 @@
return append(filteredProduct, invertedStd);
}
- if (optional.isEmpty()) {
- // need to return standard, projected out to the extra variables
- if (optional.getNumberOfVariables() == 0) {
- // This may be empty due to having zero rows (since the columns are truncated in this case)
- return (Tuples)standard.clone();
- } else {
- return project(standard, optional.getVariables());
- }
- }
-
// check if there are variables which should not be considered when sorting
if (!checkForExtraVariables(optional, matchingVars)) {
// there were no extra variables in the optional
More information about the Mulgara-svn
mailing list