[Mulgara-svn] r183 - trunk/src/jar/tuples/java/org/mulgara/store/tuples
pag at mulgara.org
pag at mulgara.org
Sat Feb 24 19:26:42 UTC 2007
Author: pag
Date: 2007-02-24 13:26:41 -0600 (Sat, 24 Feb 2007)
New Revision: 183
Modified:
trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
Log:
Extra test in subtraction to prevent the operation from proceeding on an empty minuend or subtrahend.
Modified: trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
===================================================================
--- trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2007-02-24 19:25:01 UTC (rev 182)
+++ trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java 2007-02-24 19:26:41 UTC (rev 183)
@@ -292,7 +292,13 @@
/**
- * This is approximately a subtraction.
+ * This is approximately a subtraction. The subtrahend is matched against the minuend in the same
+ * way as a conjunction, and the matching lines removed from the minuend. The remaining lines in
+ * the minuend are the result.
+ * @param minuend The tuples to subtract from.
+ * @param subtrahend The tuples to match against the minuend for removal.
+ * @return The contents from the minuend, excluding those rows which match against the subtrahend.
+ * @throws TuplesException If there are no matching variables between the minuend and subtrahend.
*/
public static Tuples subtract(Tuples minuend, Tuples subtrahend) throws TuplesException {
try {
@@ -309,6 +315,11 @@
}
throw new TuplesException("Unable to subtract: no common variables.");
}
+ // double check that the variables are not equal
+ if (subtrahend.getRowCardinality() == Cursor.ZERO || minuend.getRowCardinality() == Cursor.ZERO) {
+ logger.warn("Found an empty Tuples with bound variables");
+ return (Tuples)minuend.clone();
+ }
// reorder the subtrahend as necessary
Tuples sortedSubtrahend;
// check if there are variables which should not be considered when sorting
More information about the Mulgara-svn
mailing list