[Mulgara-svn] r253 - branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples

andrae at mulgara.org andrae at mulgara.org
Wed Apr 25 04:33:21 UTC 2007


Author: andrae
Date: 2007-04-24 23:33:21 -0500 (Tue, 24 Apr 2007)
New Revision: 253

Modified:
   branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
   branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/UnboundJoin.java
Log:
Some cleanup, a few comments, and an update to the copyright notice.



Modified: branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
===================================================================
--- branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java	2007-04-24 21:00:17 UTC (rev 252)
+++ branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java	2007-04-25 04:33:21 UTC (rev 253)
@@ -546,8 +546,11 @@
       }
 
       // Add all variables that don't contain UNBOUND to boundVars set.
-      // Note that the inefficiency this introduces for distributed results
+      // Note: the inefficiency this introduces for distributed results
       // can only be eliminated by propagating isColumnEverUnbound through Answer.
+      // Note: this is required to ensure that a subsequent operand will not
+      // rely on this variable when selecting an index as if it is UNBOUND in a
+      // left-operand it becomes unprefixed.
       Variable[] vars = bestTuples.getVariables();
       for (int i = 0; i < vars.length; i++) {
         if (!bestTuples.isColumnEverUnbound(i)) {

Modified: branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/UnboundJoin.java
===================================================================
--- branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/UnboundJoin.java	2007-04-24 21:00:17 UTC (rev 252)
+++ branches/nuc-disj/src/jar/tuples/java/org/mulgara/store/tuples/UnboundJoin.java	2007-04-25 04:33:21 UTC (rev 253)
@@ -16,7 +16,9 @@
  * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
  * Plugged In Software Pty Ltd. All Rights Reserved.
  *
- * Contributor(s): N/A.
+ * Contributor(s):
+ *  Various bug fixes copyright Netymon Pty Ltd <info at netymon.com> under
+ *  contract to The Topaz Foundation <info at topazproject.org>
  *
  * [NOTE: The text of this Exhibit A may differ slightly from the text
  * of the notices in the Source Code files of the Original Code. You
@@ -59,8 +61,6 @@
  *
  * @modified $Date: 2005/03/07 19:42:40 $
  *
- * @maintenanceAuthor $Author: newmana $
- *
  * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
  *
  * @copyright &copy; 2003 <A href="http://www.PIsoftware.com/">Plugged In
@@ -182,19 +182,16 @@
     operandBindingPrefix = new long[operands.length][];
     this.operandsContainDuplicates = false;
     for (int i = 0; i < operands.length; i++) {
-
-        // Debug
-        if (logger.isDebugEnabled()) {
-            logger.debug("Operands " + i + " : " + operands[i]);
-            logger.debug("Operands variables " + i + " : " +
-                    Arrays.asList(operands[i].getVariables()));
-            logger.debug("Ooperands types " + i + " : " +
-                    operands[i].getClass());
-        }
-        operandBinding[i] = new long[operands[i].getVariables().length];
-        if (!operands[i].hasNoDuplicates()) {
-            this.operandsContainDuplicates = true;
-        }
+      // Debug
+      if (logger.isDebugEnabled()) {
+        logger.debug("Operands " + i + " : " + operands[i]);
+        logger.debug("Operands variables " + i + " : " + Arrays.asList(operands[i].getVariables()));
+        logger.debug("Ooperands types " + i + " : " + operands[i].getClass());
+      }
+      operandBinding[i] = new long[operands[i].getVariables().length];
+      if (!operands[i].hasNoDuplicates()) {
+        this.operandsContainDuplicates = true;
+      }
     }
 
     fooOperand = new int[operands.length][];
@@ -210,39 +207,39 @@
     List fooColumnList = new ArrayList();
 
     for (int i = 0; i < operands.length; i++) {
-        fooOperandList.clear();
-        fooColumnList.clear();
+      fooOperandList.clear();
+      fooColumnList.clear();
 
-        Variable[] operandVariables = operands[i].getVariables();
+      Variable[] operandVariables = operands[i].getVariables();
 
-        operandOutputMap[i] = new int[operandVariables.length];
+      operandOutputMap[i] = new int[operandVariables.length];
 
-        for (int j = 0; j < operandVariables.length; j++) {
-            int k = variableList.indexOf(operandVariables[j]);
+      for (int j = 0; j < operandVariables.length; j++) {
+        int k = variableList.indexOf(operandVariables[j]);
 
-            if (k == -1) {
-                mapOperandList.add(new Integer(i));
-                mapColumnList.add(new Integer(j));
-                fooOperandList.add(new Integer(PREFIX));
-                fooColumnList.add(new Integer(variableList.size()));
-                variableList.add(operandVariables[j]);
-                operandOutputMap[i][j] = j;
-            } else {
-                fooOperandList.add(mapOperandList.get(k));
-                fooColumnList.add(mapColumnList.get(k));
-                operandOutputMap[i][j] = k;
-            }
+        if (k == -1) {
+          mapOperandList.add(new Integer(i));
+          mapColumnList.add(new Integer(j));
+          fooOperandList.add(new Integer(PREFIX));
+          fooColumnList.add(new Integer(variableList.size()));
+          variableList.add(operandVariables[j]);
+          operandOutputMap[i][j] = j;
+        } else {
+          fooOperandList.add(mapOperandList.get(k));
+          fooColumnList.add(mapColumnList.get(k));
+          operandOutputMap[i][j] = k;
         }
+      }
 
-        // Convert per-operand lists into arrays
-        assert fooOperandList.size() == fooColumnList.size();
-        fooOperand[i] = new int[fooOperandList.size()];
-        fooColumn[i] = new int[fooColumnList.size()];
+      // Convert per-operand lists into arrays
+      assert fooOperandList.size() == fooColumnList.size();
+      fooOperand[i] = new int[fooOperandList.size()];
+      fooColumn[i] = new int[fooColumnList.size()];
 
-        for (int j = 0; j < fooOperand[i].length; j++) {
-            fooOperand[i][j] = ((Integer) fooOperandList.get(j)).intValue();
-            fooColumn[i][j] = ((Integer) fooColumnList.get(j)).intValue();
-        }
+      for (int j = 0; j < fooOperand[i].length; j++) {
+        fooOperand[i][j] = ((Integer) fooOperandList.get(j)).intValue();
+        fooColumn[i][j] = ((Integer) fooColumnList.get(j)).intValue();
+      }
     }
 
     // Convert column mappings from lists to arrays
@@ -252,8 +249,8 @@
     mapColumn = new int[mapColumnList.size()];
 
     for (int i = 0; i < mapOperand.length; i++) {
-        mapOperand[i] = ((Integer) mapOperandList.get(i)).intValue();
-        mapColumn[i] = ((Integer) mapColumnList.get(i)).intValue();
+      mapOperand[i] = ((Integer) mapOperandList.get(i)).intValue();
+      mapColumn[i] = ((Integer) mapColumnList.get(i)).intValue();
     }
 
     // Determine which columns are ever unbound
@@ -262,15 +259,15 @@
     Arrays.fill(columnEverUnbound, true);
 
     for (int i = 0; i < operands.length; i++) {
-        Arrays.fill(columnOperandEverUnbound[i], false);
-        Variable[] variables = operands[i].getVariables();
-        for (int j = 0; j < variables.length; j++) {
-            if (!operands[i].isColumnEverUnbound(j)) {
-                columnEverUnbound[getColumnIndex(variables[j])] = false;
-            } else {
-                columnOperandEverUnbound[i][getColumnIndex(variables[j])] = true;
-            }
+      Arrays.fill(columnOperandEverUnbound[i], false);
+      Variable[] variables = operands[i].getVariables();
+      for (int j = 0; j < variables.length; j++) {
+        if (!operands[i].isColumnEverUnbound(j)) {
+          columnEverUnbound[getColumnIndex(variables[j])] = false;
+        } else {
+          columnOperandEverUnbound[i][getColumnIndex(variables[j])] = true;
         }
+      }
     }
   }
 
@@ -280,34 +277,34 @@
    * @throws TuplesException {@inheritDoc}
    */
   public boolean isUnconstrained() throws TuplesException {
-      for (int i = 0; i < operands.length; i++) {
-          if (!operands[i].isUnconstrained()) {
-              return false;
-          }
+    for (int i = 0; i < operands.length; i++) {
+      if (!operands[i].isUnconstrained()) {
+        return false;
       }
+    }
 
-      return true;
+    return true;
   }
 
   public List getOperands() {
-      return Arrays.asList(operands);
+    return Arrays.asList(operands);
   }
 
   public void beforeFirst(long[] prefix, int suffixTruncation) throws TuplesException {
-      if (prefix == null) {
-          throw new IllegalArgumentException("Null \"prefix\" parameter");
-      }
+    if (prefix == null) {
+      throw new IllegalArgumentException("Null \"prefix\" parameter");
+    }
 
-      if (suffixTruncation != 0) {
-          throw new TuplesException("Suffix truncation not implemented");
-      }
+    if (suffixTruncation != 0) {
+      throw new TuplesException("Suffix truncation not implemented");
+    }
 
-      assert operands != null;
-      assert operandBinding != null;
+    assert operands != null;
+    assert operandBinding != null;
 
-      isBeforeFirst = true;
-      isAfterLast = false;
-      this.prefix = prefix;
+    isBeforeFirst = true;
+    isAfterLast = false;
+    this.prefix = prefix;
   }
 
   //
@@ -363,9 +360,7 @@
     BigInteger rowCount = BigInteger.valueOf(operands[0].getRowUpperBound());
 
     for (int i = 1; i < operands.length; i++) {
-      rowCount = rowCount.multiply(BigInteger.valueOf(
-          operands[i].getRowUpperBound()
-          ));
+      rowCount = rowCount.multiply(BigInteger.valueOf(operands[i].getRowUpperBound()));
       if (rowCount.bitLength() > 63)
         return Long.MAX_VALUE;
     }
@@ -373,16 +368,10 @@
     return rowCount.longValue();
   }
 
-  /**
-   * This method is not yet implemented, and always returns <code>true</code>.
-   *
-   * @return <code>true</code>
-   */
   public boolean isColumnEverUnbound(int column) throws TuplesException {
     try {
       return columnEverUnbound[column];
-    }
-    catch (ArrayIndexOutOfBoundsException e) {
+    } catch (ArrayIndexOutOfBoundsException e) {
       throw new TuplesException("No such column " + column, e);
     }
   }
@@ -418,8 +407,7 @@
       }
 
       return true;
-    }
-    else {
+    } else {
       // We know at this point that we're on a row satisfying the current
       // prefix.  Advance the rightmost operand and let rollover do any
       // right-to-left advancement required
@@ -486,13 +474,10 @@
     for (int j = 0; j < operandBinding[i].length; j++) {
       if (fooOperand[i][j] == PREFIX) {
         // Variable first bound to a next method parameter prefix column passed to beforeFirst.
-        operandBinding[i][j] = (j < prefix.length) ? prefix[fooColumn[i][j]] :
-            Tuples.UNBOUND;
-      }
-      else {
+        operandBinding[i][j] = (j < prefix.length) ? prefix[fooColumn[i][j]] : Tuples.UNBOUND;
+      } else {
         // Variable first bound to a leftward operand column
-        operandBinding[i][j] = operands[fooOperand[i][j]].getColumnValue(
-            fooColumn[i][j]);
+        operandBinding[i][j] = operands[fooOperand[i][j]].getColumnValue(fooColumn[i][j]);
       }
     }
 
@@ -506,19 +491,15 @@
 
     assert prefixLength >= 0;
     assert prefixLength <= operandBinding[i].length;
-//    assert (prefixLength == operandBinding[i].length) ||
-//           (operandBinding[i][prefixLength] == Tuples.UNBOUND);
 
     // Generate the advancement prefix
     assert operandBindingPrefix != null;
 
-    if ((operandBindingPrefix[i] == null) ||
-        (operandBindingPrefix[i].length != prefixLength)) {
+    if ((operandBindingPrefix[i] == null) || (operandBindingPrefix[i].length != prefixLength)) {
       operandBindingPrefix[i] = new long[prefixLength];
     }
 
-    System.arraycopy(operandBinding[i], 0, operandBindingPrefix[i], 0,
-        prefixLength);
+    System.arraycopy(operandBinding[i], 0, operandBindingPrefix[i], 0, prefixLength);
   }
 
   /**
@@ -540,8 +521,7 @@
           isAfterLast = true;
           prefix = null;
           return false;
-        }
-        else {
+        } else {
           // roll the leftward row
           if (!advance(i - 1)) {
             return false;
@@ -556,8 +536,7 @@
       }
 
       // Check that any suffix conditions are satisfied
-      for (int j = operandBindingPrefix[i].length;
-          j < operandBinding[i].length; j++) {
+      for (int j = operandBindingPrefix[i].length; j < operandBinding[i].length; j++) {
         if ((operandBinding[i][j] != Tuples.UNBOUND) &&
             (operandBinding[i][j] != operands[i].getColumnValue(j)) &&
             (operands[i].getColumnValue(j) != Tuples.UNBOUND)) {




More information about the Mulgara-svn mailing list