[Mulgara-svn] r1564 - in branches/mgr-183-project/src/jar: resolver-spi/java/org/mulgara/resolver/spi resolver-spi/java/org/mulgara/store/statement resolver-store/java/org/mulgara/resolver/store resolver-store/java/org/mulgara/store/statement/xa
andrae at mulgara.org
andrae at mulgara.org
Sat Feb 28 02:17:14 UTC 2009
Author: andrae
Date: 2009-02-27 18:17:13 -0800 (Fri, 27 Feb 2009)
New Revision: 1564
Removed:
branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java
Modified:
branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java
branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java
branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
Log:
refs #183
Passes all regression tests, untested is the actual preference based index
selection, one difficulty will be matching up the nodes with the index columns
based on index order.
Next step is to eliminate the switch statement by lifting it to a lookup table,
and writing some unit-tests for the new functionality.
Deleted: branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java
===================================================================
--- branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java 2009-02-27 07:06:28 UTC (rev 1563)
+++ branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ReresolvableResolution.java 2009-02-28 02:17:13 UTC (rev 1564)
@@ -1,65 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [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
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.resolver.spi;
-
-import java.util.Map;
-
-import org.mulgara.query.ConstraintElement;
-import org.mulgara.query.TuplesException;
-
-/**
- * A Resolution that can be reresolved cheaper than the cost of joining
- * against an equivalent set of assignments.
- *
- * @created 2004-04-22
- * @author <a href="http://staff.tucanatech.com/raboczi">Simon Raboczi</a>
- * @version $Revision: 1.8 $
- * @modified $Date: 2005/01/05 04:58:50 $
- * @maintenanceAuthor $Author: newmana $
- * @company <a href="mailto:info at tucanatech.com">Plugged In Software</a>
- * @copyright ©2004 <a href="http://www.PIsoftware.com/">Plugged In
- * Software Pty Ltd</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-
-public interface ReresolvableResolution extends Resolution
-{
- /**
- * Reresolve resolution given additional knowledge derived from other constraints in the query.
- *
- * Note: assign/x and Resolution <=> assign/x and Resolution.reresolve(x).
- *
- * Reresolve is analogous to beta-reduction in the lambda calculus, it is defined as
- * project({this.vars - bindings.vars}, restrict(bindings, this))
- *
- * @param bindings map of Variable to Long that defines the variable bindings known so far.
- * @return null if resolution was not able to be simplified using bindings otherwise a new
- * ReresolvableResolution with any variables bound in the reresolution removed.
- */
- public ReresolvableResolution reresolve(Map<? extends ConstraintElement,Long> bindings) throws TuplesException;
-}
Modified: branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java
===================================================================
--- branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java 2009-02-27 07:06:28 UTC (rev 1563)
+++ branches/mgr-183-project/src/jar/resolver-spi/java/org/mulgara/store/statement/StatementStore.java 2009-02-28 02:17:13 UTC (rev 1564)
@@ -122,10 +122,10 @@
* @return the {@link StoreTuples}
* @throws StatementStoreException if something exceptional happens
*/
- public StoreTuples findTuples(
- int mask,
- long node0, long node1, long node2, long node3
- ) throws StatementStoreException;
+// public StoreTuples findTuples(
+// int mask,
+// long node0, long node1, long node2, long node3
+// ) throws StatementStoreException;
/**
* Returns a StoreTuples which contains all triples in the store. The
Modified: branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java
===================================================================
--- branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java 2009-02-27 07:06:28 UTC (rev 1563)
+++ branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java 2009-02-28 02:17:13 UTC (rev 1564)
@@ -39,7 +39,6 @@
// Locally written packages
import org.mulgara.query.*;
-//import org.mulgara.resolver.spi.ReresolvableResolution;
import org.mulgara.resolver.spi.Resolution;
import org.mulgara.store.nodepool.NodePool;
import org.mulgara.store.statement.StatementStore;
@@ -69,7 +68,6 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-//class StatementStoreResolution extends AbstractTuples implements ReresolvableResolution {
class StatementStoreResolution extends AbstractTuples implements Resolution {
private final static long ROWCOUNT_UNCALCULATED = -1;
private final static int ROWCARD_UNCALCULATED = -1;
Modified: branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
===================================================================
--- branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java 2009-02-27 07:06:28 UTC (rev 1563)
+++ branches/mgr-183-project/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java 2009-02-28 02:17:13 UTC (rev 1564)
@@ -425,22 +425,22 @@
/* 3210 */ TI_3120
},
/* 3210 */ {
- /* XXXX */ TI_3012, // I picked this index because it corresponds to <s> $p $o in <g>
- /* XXX0 */ TI_3012, // Sharing exists() with this constraint may improve caching behaviour. (AWM)
- /* XX1X */ TI_3012,
- /* XX10 */ TI_3012,
- /* X2XX */ TI_3012,
- /* X2X0 */ TI_3012,
- /* X21X */ TI_3012,
- /* X210 */ TI_3012,
- /* 3XXX */ TI_3012,
- /* 3XX0 */ TI_3012,
- /* 3X1X */ TI_3012,
- /* 3X10 */ TI_3012,
- /* 32XX */ TI_3012,
- /* 32X0 */ TI_3012,
- /* 321X */ TI_3012,
- /* 3210 */ TI_3012
+ /* XXXX */ TI_0123, // I picked this index because it corresponds to <s> $p $o in <g>
+ /* XXX0 */ TI_0123, // Sharing exists() with this constraint may improve caching behaviour. (AWM)
+ /* XX1X */ TI_0123, // - changed to TI_0123 temporarally
+ /* XX10 */ TI_0123,
+ /* X2XX */ TI_0123,
+ /* X2X0 */ TI_0123,
+ /* X21X */ TI_0123,
+ /* X210 */ TI_0123,
+ /* 3XXX */ TI_0123,
+ /* 3XX0 */ TI_0123,
+ /* 3X1X */ TI_0123,
+ /* 3X10 */ TI_0123,
+ /* 32XX */ TI_0123,
+ /* 32X0 */ TI_0123,
+ /* 321X */ TI_0123,
+ /* 3210 */ TI_0123
},
};
@@ -817,9 +817,8 @@
* @return A set of all the triples which match the search.
* @throws StatementStoreException EXCEPTION TO DO
*/
- public synchronized StoreTuples findTuples(
- long node0, long node1, long node2, long node3
- ) throws StatementStoreException {
+ public synchronized StoreTuples findTuples(long node0, long node1, long node2, long node3)
+ throws StatementStoreException {
checkInitialized();
dirty = false;
return currentPhase.findTuples(node0, node1, node2, node3);
@@ -838,13 +837,12 @@
* @return A set of all the triples which match the search.
* @throws StatementStoreException EXCEPTION TO DO
*/
- public synchronized StoreTuples findTuples(
- int mask, long node0, long node1, long node2, long node3
- ) throws StatementStoreException {
+
+ public synchronized StoreTuples findTuples(int preference, long node0, long node1, long node2, long node3)
+ throws StatementStoreException {
checkInitialized();
dirty = false;
- if (!checkMask(mask, node0, node1, node2, node3)) throw new StatementStoreException("Bad explicit index selection for given node pattern.");
- return currentPhase.findTuples(mask, node0, node1, node2, node3);
+ return currentPhase.findTuples(preference, node0, node1, node2, node3);
}
/**
@@ -877,8 +875,10 @@
* @return the {@link StoreTuples}
* @throws StatementStoreException if something exceptional happens
*/
- public synchronized StoreTuples findTuples(boolean node0Bound, boolean node1Bound, boolean node2Bound, boolean node3Bound)
- throws StatementStoreException {
+ public synchronized StoreTuples findTuples(
+ boolean node0Bound, boolean node1Bound, boolean node2Bound,
+ boolean node3Bound
+ ) throws StatementStoreException {
checkInitialized();
dirty = false;
return currentPhase.findTuples(node0Bound, node1Bound, node2Bound, node3Bound);
@@ -1610,10 +1610,9 @@
* @throws StatementStoreException EXCEPTION TO DO
*/
public synchronized StoreTuples findTuples(
- int mask, long node0, long node1, long node2, long node3
+ int preference, long node0, long node1, long node2, long node3
) throws StatementStoreException {
- if (!checkMask(mask, node0, node1, node2, node3)) throw new StatementStoreException("Bad explicit index selection for given node pattern.");
- return phase.findTuples(mask, node0, node1, node2, node3);
+ return phase.findTuples(preference, node0, node1, node2, node3);
}
@@ -1630,8 +1629,10 @@
* @return the {@link StoreTuples}
* @throws StatementStoreException if something exceptional happens
*/
- public synchronized StoreTuples findTuples(boolean node0Bound, boolean node1Bound, boolean node2Bound, boolean node3Bound)
- throws StatementStoreException {
+ public synchronized StoreTuples findTuples(
+ boolean node0Bound, boolean node1Bound, boolean node2Bound,
+ boolean node3Bound
+ ) throws StatementStoreException {
return phase.findTuples(node0Bound, node1Bound, node2Bound, node3Bound);
}
@@ -2014,6 +2015,22 @@
/**
* Finds triples matching the given specification.
*
+ * @param node0 The 0 node of the triple to find.
+ * @param node1 The 1 node of the triple to find.
+ * @param node2 The 2 node of the triple to find.
+ * @param node3 The 3 node of the triple to find.
+ * @return A StoreTuples containing all the triples which match the search.
+ * @throws StatementStoreException EXCEPTION TO DO
+ */
+ StoreTuples findTuples(long node0, long node1, long node2, long node3) throws StatementStoreException {
+ StoreTuples result = findTuples(0, node0, node1, node2, node3);
+ assert result != null;
+ return result;
+ }
+
+ /**
+ * Finds triples matching the given specification.
+ *
* @param variableMask the mask used to indicate the desired index.
* @param node0 The 0 node of the triple to find.
* @param node1 The 1 node of the triple to find.
@@ -2026,13 +2043,6 @@
if (preference < 0 || preference > 15) {
throw new StatementStoreException("Invalid variable preference: " + preference);
}
- if (node0 < NodePool.NONE ||
- node1 < NodePool.NONE ||
- node2 < NodePool.NONE ||
- node3 < NodePool.NONE) {
- // There is at least one query node. Return an empty StoreTuples.
- return TuplesOperations.empty();
- }
int boundMask = 0;
boundMask += node0 != NodePool.NONE ? 1 : 0;
@@ -2041,16 +2051,23 @@
boundMask += node3 != NodePool.NONE ? 8 : 0;
if (selectIndexSet[boundMask][preference] < 0) {
- return findTuplesFromPhase(tripleAVLFilePhases[selectIndexSet[boundMask][preference]],
- node0, node1, node2, node3);
- } else {
return null;
}
+
+ return findTuplesFromPhase(tripleAVLFilePhases[selectIndexSet[boundMask][preference]], node0, node1, node2, node3);
}
StoreTuples findTuplesFromPhase(TripleAVLFile.Phase phase, long node0, long node1, long node2, long node3)
throws StatementStoreException {
+ if (node0 < NodePool.NONE ||
+ node1 < NodePool.NONE ||
+ node2 < NodePool.NONE ||
+ node3 < NodePool.NONE) {
+ // There is at least one query node. Return an empty StoreTuples.
+ return TuplesOperations.empty();
+ }
+
int variableMask =
(node0 != NONE ? MASK0 : 0) |
(node1 != NONE ? MASK1 : 0) |
@@ -2102,25 +2119,11 @@
}
}
- /**
- * Finds triples matching the given specification.
- *
- * @param node0 The 0 node of the triple to find.
- * @param node1 The 1 node of the triple to find.
- * @param node2 The 2 node of the triple to find.
- * @param node3 The 3 node of the triple to find.
- * @return A StoreTuples containing all the triples which match the search.
- * @throws StatementStoreException EXCEPTION TO DO
- */
- StoreTuples findTuples(long node0, long node1, long node2, long node3) throws StatementStoreException {
- StoreTuples result = findTuples(0, node0, node1, node2, node3);
- assert result != null;
- return result;
- }
-
- StoreTuples findTuples(boolean node0Bound, boolean node1Bound, boolean node2Bound, boolean node3Bound)
- throws StatementStoreException {
+ StoreTuples findTuples(
+ boolean node0Bound, boolean node1Bound,
+ boolean node2Bound, boolean node3Bound
+ ) throws StatementStoreException {
int variableMask =
(node0Bound ? MASK0 : 0) |
(node1Bound ? MASK1 : 0) |
More information about the Mulgara-svn
mailing list