[Mulgara-svn] r1759 - in trunk/src/jar: content-mbox/java/org/mulgara/content/mbox content-mp3/java/org/mulgara/content/mp3 content-n3/java/org/mulgara/content/n3 content-rdfxml/java/org/mulgara/content/rdfxml query/java/org/mulgara/query resolver/java/org/mulgara/resolver resolver-distributed/java/org/mulgara/resolver/distributed resolver-filesystem/java/org/mulgara/resolver/filesystem resolver-gis/java/org/mulgara/resolver/gis resolver-lucene/java/org/mulgara/resolver/lucene resolver-nodetype/java/org/mulgara/resolver/nodetype resolver-null/java/org/mulgara/resolver/nullres resolver-spi/java/org/mulgara/resolver/spi resolver-store/java/org/mulgara/resolver/store resolver-store/java/org/mulgara/store/statement/xa resolver-url/java/org/mulgara/resolver/url resolver-xsd/java/org/mulgara/resolver/xsd server-rmi/java/org/mulgara/server/rmi store-stringpool-memory/java/org/mulgara/store/stringpool/memory store-stringpool-xa/java/org/mulgara/store/stringpool/xa store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11
pag at mulgara.org
pag at mulgara.org
Fri Jul 10 16:35:28 UTC 2009
Author: pag
Date: 2009-07-10 09:35:27 -0700 (Fri, 10 Jul 2009)
New Revision: 1759
Modified:
trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/MBoxStatements.java
trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/MP3Statements.java
trunk/src/jar/content-n3/java/org/mulgara/content/n3/N3Statements.java
trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/RDFXMLStatements.java
trunk/src/jar/query/java/org/mulgara/query/AnswerImpl.java
trunk/src/jar/query/java/org/mulgara/query/ArrayAnswer.java
trunk/src/jar/query/java/org/mulgara/query/BooleanAnswer.java
trunk/src/jar/query/java/org/mulgara/query/ConstraintBinaryOperation.java
trunk/src/jar/query/java/org/mulgara/query/Cursor.java
trunk/src/jar/query/java/org/mulgara/query/GraphAnswer.java
trunk/src/jar/query/java/org/mulgara/query/UnconstrainedAnswer.java
trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java
trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemStatements.java
trunk/src/jar/resolver-gis/java/org/mulgara/resolver/gis/GISDistanceStatements.java
trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java
trunk/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java
trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/LocalizedTuples.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SingletonStatements.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperResolution.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperTuples.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperResolution.java
trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java
trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreXAResource.java
trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLStatements.java
trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
trunk/src/jar/resolver/java/org/mulgara/resolver/CacheStatements.java
trunk/src/jar/resolver/java/org/mulgara/resolver/GlobalizedAnswer.java
trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswer.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswerSerialised.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/BlankNodeWrapperAnswer.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/JRDFSessionWrapperRemoteJRDFSession.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswer.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswerWrapperAnswer.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
Log:
Added the getRowExpectedCount method to supplant getRowUpperBound
Modified: trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/MBoxStatements.java
===================================================================
--- trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/MBoxStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/MBoxStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -393,6 +393,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowExpectedCount();
+ }
+
public boolean hasNoDuplicates() throws TuplesException {
return false;
}
Modified: trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/MP3Statements.java
===================================================================
--- trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/MP3Statements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/MP3Statements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -375,17 +375,18 @@
}
public long getRowCount() throws TuplesException {
-
return rowCount;
}
public long getRowUpperBound() throws TuplesException {
+ return getRowCount();
+ }
+ public long getRowExpectedCount() throws TuplesException {
return getRowCount();
}
public boolean hasNoDuplicates() throws TuplesException {
-
return false;
}
Modified: trunk/src/jar/content-n3/java/org/mulgara/content/n3/N3Statements.java
===================================================================
--- trunk/src/jar/content-n3/java/org/mulgara/content/n3/N3Statements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/content-n3/java/org/mulgara/content/n3/N3Statements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -331,6 +331,15 @@
parser.getStatementCount() : Long.MAX_VALUE;
}
+ /** Guess at a large number */
+ private static final Long LARGE_FILE_SIZE = 1000000L;
+
+ public long getRowExpectedCount() throws TuplesException {
+ // If the row count isn't yet available, return an absurdly huge value
+ return parser != null && parser.isStatementCountTotal() ?
+ parser.getStatementCount() : LARGE_FILE_SIZE;
+ }
+
public boolean hasNoDuplicates() throws TuplesException {
return false;
}
Modified: trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/RDFXMLStatements.java
===================================================================
--- trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/RDFXMLStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/RDFXMLStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -335,20 +335,26 @@
return rowCount;
}
- public long getRowUpperBound() throws TuplesException
- {
+ public long getRowUpperBound() throws TuplesException {
// If the row count isn't yet available, return an absurdly huge value
return parser != null && parser.isStatementCountTotal() ?
parser.getStatementCount() : Long.MAX_VALUE;
}
- public boolean hasNoDuplicates() throws TuplesException
- {
+ /** Guess at a large number */
+ private static final Long LARGE_FILE_SIZE = 1000000L;
+
+ public long getRowExpectedCount() throws TuplesException {
+ // If the row count isn't yet available, return an absurdly huge value
+ return parser != null && parser.isStatementCountTotal() ?
+ parser.getStatementCount() : LARGE_FILE_SIZE;
+ }
+
+ public boolean hasNoDuplicates() throws TuplesException {
return false;
}
- public boolean isColumnEverUnbound(int column) throws TuplesException
- {
+ public boolean isColumnEverUnbound(int column) throws TuplesException {
switch (column) {
case 0: case 1: case 2:
return false;
Modified: trunk/src/jar/query/java/org/mulgara/query/AnswerImpl.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/AnswerImpl.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/AnswerImpl.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -223,6 +223,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
public int getRowCardinality() throws TuplesException {
switch ((int)getRowCount()) {
case 0:
Modified: trunk/src/jar/query/java/org/mulgara/query/ArrayAnswer.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ArrayAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/ArrayAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -227,6 +227,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
public int getRowCardinality() throws TuplesException {
if (getRowCount() > 1) {
return Cursor.MANY;
Modified: trunk/src/jar/query/java/org/mulgara/query/BooleanAnswer.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/BooleanAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/BooleanAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -126,6 +126,13 @@
}
/**
+ * @see org.mulgara.query.Cursor#getRowExpectedCount()
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return 1;
+ }
+
+ /**
* @see org.mulgara.query.Cursor#getVariables()
*/
public Variable[] getVariables() {
Modified: trunk/src/jar/query/java/org/mulgara/query/ConstraintBinaryOperation.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ConstraintBinaryOperation.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/ConstraintBinaryOperation.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -51,7 +51,7 @@
* Get the LHS of this operation
* @return The LHS operand.
*/
- protected ConstraintExpression getLhs() {
+ public ConstraintExpression getLhs() {
return elements.get(0);
}
@@ -59,7 +59,7 @@
* Get the RHS of this operation
* @return The RHS operand.
*/
- protected ConstraintExpression getRhs() {
+ public ConstraintExpression getRhs() {
return elements.get(1);
}
Modified: trunk/src/jar/query/java/org/mulgara/query/Cursor.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/Cursor.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/Cursor.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -61,23 +61,23 @@
/**
* Reset to iterate through every single element.
*
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public void beforeFirst() throws TuplesException;
/**
* Free resources associated with this instance.
*
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public void close() throws TuplesException;
/**
* Find the index of a variable.
*
- * @param column PARAMETER TO DO
+ * @param column The variable to search for.
* @return The ColumnIndex value
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException If the variable is null or not in this tuples.
*/
public int getColumnIndex(Variable column) throws TuplesException;
@@ -106,7 +106,7 @@
* row.
*
* @return The Unconstrained value
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public boolean isUnconstrained() throws TuplesException;
@@ -114,7 +114,7 @@
* This method returns the exact number of rows which this instance contains.
*
* @return The exact number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public long getRowCount() throws TuplesException;
@@ -122,15 +122,25 @@
* This method returns an upper bound on the number of rows which this instance contains.
*
* @return The upper bound of the number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public long getRowUpperBound() throws TuplesException;
+
/**
+ * This method returns the expected number of rows which this instance contains.
+ * This number should be updated statistically over time, when possible.
+ *
+ * @return An expected value for the rows.
+ * @throws TuplesException Due to an error accessing the underlying data.
+ */
+ public long getRowExpectedCount() throws TuplesException;
+
+ /**
* This method returns cardinality of the number of rows which this instance contains.
*
* @return The cardinality of this tuples. {0,1,N} rows.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public int getRowCardinality() throws TuplesException;
@@ -144,7 +154,7 @@
*
* @return whether a subsequent row exists
* @throws IllegalStateException if the current row is unspecified.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Due to an error accessing the underlying data.
*/
public boolean next() throws TuplesException;
}
Modified: trunk/src/jar/query/java/org/mulgara/query/GraphAnswer.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/GraphAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/GraphAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -165,6 +165,13 @@
}
/**
+ * @see org.mulgara.query.Cursor#getRowExpectedCount()
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return rawAnswer.getRowExpectedCount() * rowsPerCol;
+ }
+
+ /**
* @see org.mulgara.query.Cursor#getVariables()
*/
public Variable[] getVariables() {
Modified: trunk/src/jar/query/java/org/mulgara/query/UnconstrainedAnswer.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/UnconstrainedAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/query/java/org/mulgara/query/UnconstrainedAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -193,6 +193,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() {
+ return getRowCount();
+ }
+
public int getRowCardinality() {
return Cursor.ONE;
}
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -111,11 +111,10 @@
* @throws TuplesException if there's trouble reading <var>tuples</var>
*/
AppendAggregateTuples(ResolverSession session,
- LocalQueryResolver context, Tuples tuples,
- List variableList) throws TuplesException {
+ LocalQueryResolver context, Tuples tuples,
+ List<? extends SelectElement> variableList) throws TuplesException {
if (logger.isDebugEnabled()) {
- logger.debug("Generating variable list for " + tuples + " and " +
- variableList);
+ logger.debug("Generating variable list for " + tuples + " and " + variableList);
logger.debug("AppendAggregateTuples instantiated " + hashCode());
}
if (session == null) {
@@ -138,7 +137,7 @@
// while the size of the tuples may be larger due to aggregates
int uniqueTupleVarLen = Math.min(variableList.size(), tupleVars.length);
- Set newVariableList = new LinkedHashSet();
+ Set<Variable> newVariableList = new LinkedHashSet<Variable>();
for (int i = 0; i < uniqueTupleVarLen; i++) {
assert variableList.contains(tupleVars[i]);
@@ -177,7 +176,7 @@
logger.info("Generated variable list " + newVariableList);
}
- setVariables(new ArrayList(newVariableList));
+ setVariables(new ArrayList<Variable>(newVariableList));
if (logger.isDebugEnabled()) {
logger.debug("Set variable list " + Arrays.asList(getVariables()));
@@ -322,6 +321,10 @@
return tuples.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return tuples.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException {
return tuples.getRowCardinality();
}
@@ -346,7 +349,7 @@
return tuples.hasNoDuplicates();
}
- public List getOperands() {
+ public List<Tuples> getOperands() {
return Collections.singletonList(tuples);
}
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/CacheStatements.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/CacheStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/CacheStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -114,6 +114,11 @@
return statements.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException
+ {
+ return statements.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException
{
return statements.getRowCardinality();
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/GlobalizedAnswer.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/GlobalizedAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/GlobalizedAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -153,6 +153,10 @@
return tuples.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return tuples.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException {
return tuples.getRowCardinality();
}
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -198,6 +198,15 @@
}).getLong();
}
+ public long getRowExpectedCount() throws TuplesException {
+ notClosed();
+ return transaction.execute(new AnswerOperation() {
+ public void execute() throws TuplesException {
+ returnLong(answer.getRowExpectedCount());
+ }
+ }).getLong();
+ }
+
public int getRowCardinality() throws TuplesException {
notClosed();
return transaction.execute(new AnswerOperation() {
Modified: trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java
===================================================================
--- trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/MultiXAResource.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -32,8 +32,8 @@
import org.mulgara.resolver.spi.AbstractXAResource;
import org.mulgara.resolver.spi.AbstractXAResource.RMInfo;
+import org.mulgara.resolver.spi.ResolverFactory;
import org.mulgara.resolver.spi.AbstractXAResource.TxInfo;
-import org.mulgara.resolver.spi.ResolverFactory;
/**
* This is an implementation of {@link XAResource} that presents a collection of xa-resources as
@@ -64,6 +64,7 @@
* @copyright ©2008 <a href="http://www.topazproject.org/">Topaz Project</a>
* @licence Apache License v2.0
*/
+ at SuppressWarnings("unused")
public class MultiXAResource
extends AbstractXAResource<RMInfo<MultiXAResource.MultiTxInfo>,MultiXAResource.MultiTxInfo> {
Modified: trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemStatements.java
===================================================================
--- trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/FileSystemStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -31,33 +31,22 @@
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.MalformedURLException;
import java.util.*;
import java.text.SimpleDateFormat;
-import org.xml.sax.*;
// Third party packages
import org.jrdf.graph.*;
-import org.jrdf.graph.mem.*;
import org.jrdf.vocabulary.RDF;
import org.apache.log4j.Logger; // Apache Log4J
-import org.jrdf.util.ClosableIterator; // JRDF
-import org.jrdf.graph.*; // JRDF
// Locally written packages
-import org.mulgara.content.Content;
-import org.mulgara.query.Constraint;
-import org.mulgara.query.QueryException;
import org.mulgara.query.TuplesException;
import org.mulgara.query.Variable;
-import org.mulgara.query.rdf.*;
import org.mulgara.resolver.filesystem.exception.*;
import org.mulgara.resolver.spi.GlobalizeException;
import org.mulgara.resolver.spi.LocalizeException;
import org.mulgara.resolver.spi.ResolverSession;
import org.mulgara.resolver.spi.Statements;
-import org.mulgara.store.StoreException;
import org.mulgara.store.tuples.AbstractTuples;
import org.mulgara.store.tuples.Tuples;
@@ -97,23 +86,17 @@
/** The session used to globalize the RDF nodes from the stream */
private ResolverSession resolverSession;
- /** The queue of triples generated by the file system data tuples */
- private ArrayList triples;
-
/** The number of statements in the results */
private long rowCount;
/** The current row. If the cursor is not on a row, this will be null */
private Triple tripleStatement;
- /** An interator into triples positioned at the next triple. */
- private ClosableIterator nextTriple;
-
/** The model which will store the content of the resulting file system data */
private Graph model;
/** The list of excluded filesystems */
- private ArrayList exclusionList;
+ private ArrayList<File> exclusionList;
/** The meta data file manager we will be using for our conversions */
private MetaFileManager manager;
@@ -138,7 +121,6 @@
// Initialize fields
this.resolverSession = resolverSession;
- this.triples = new ArrayList();
// Fix the magical column names for RDF statements
setVariables(new Variable[] {new Variable("subject"),
@@ -162,7 +144,7 @@
private void createExclusionList(Tuples excludeTuples) throws TuplesException {
// Initialise the exclusion list
- exclusionList = new ArrayList();
+ exclusionList = new ArrayList<File>();
if (excludeTuples != null) {
@@ -421,9 +403,6 @@
cloned.rowCount = rowCount;
cloned.tripleStatement = tripleStatement;
- // Copy mutable fields by value
- cloned.triples = (ArrayList) triples.clone();
-
return cloned;
}
@@ -434,7 +413,6 @@
resolverSession = null;
tripleStatement = null;
- triples = null;
}
/**
@@ -480,13 +458,11 @@
}
}
- public List getOperands() {
-
- return Collections.EMPTY_LIST;
+ public List<Tuples> getOperands() {
+ return Collections.emptyList();
}
public long getRowCount() throws TuplesException {
-
// We have no way of telling how many files there will be due to the 'pull
// parser' structure we have set up so we just give a large estimate to
// account for large file systems
@@ -494,28 +470,24 @@
}
public long getRowUpperBound() throws TuplesException {
+ return getRowCount();
+ }
+ public long getRowExpectedCount() throws TuplesException {
return getRowCount();
}
public boolean hasNoDuplicates() throws TuplesException {
-
return false;
}
public boolean isColumnEverUnbound(int column) throws TuplesException {
-
switch (column) {
-
case 0:
-
case 1:
-
case 2:
-
return false;
default:
-
throw new TuplesException("No such column " + column);
}
}
@@ -561,6 +533,7 @@
*
* @throws TuplesException
*/
+ @SuppressWarnings("unused")
private void getFileSystemInformation(URI fileURI) throws TuplesException {
// Container for the actual file on the filesystem
@@ -996,19 +969,13 @@
*
* @throws TuplesException
*/
- private PredicateNode createPredicate(String key,
- GraphElementFactory elementFactory) throws
- TuplesException {
-
+ @SuppressWarnings("unused")
+ private PredicateNode createPredicate(String key, GraphElementFactory elementFactory) throws TuplesException {
try {
-
// Create the type node
- return (PredicateNode) elementFactory.createResource(
- RDF.TYPE);
+ return (PredicateNode) elementFactory.createResource(RDF.TYPE);
} catch (GraphElementFactoryException graphElementFactoryException) {
-
- throw new TuplesException("Failed to create predicate node for key: " +
- key,
+ throw new TuplesException("Failed to create predicate node for key: " + key,
graphElementFactoryException);
}
}
Modified: trunk/src/jar/resolver-gis/java/org/mulgara/resolver/gis/GISDistanceStatements.java
===================================================================
--- trunk/src/jar/resolver-gis/java/org/mulgara/resolver/gis/GISDistanceStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-gis/java/org/mulgara/resolver/gis/GISDistanceStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -348,6 +348,16 @@
}
/**
+ * getRowExpectedCount
+ *
+ * @return The expected wize of this result
+ * @throws TuplesException when accessing data
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return points.getRowExpectedCount() * STATEMENTS_PER_ROW;
+ }
+
+ /**
* getRowCardinality
*
* @return int
Modified: trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java
===================================================================
--- trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexTuples.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -261,6 +261,10 @@
return (results != null) ? results.getRowUpperBound() : getRowUpperBoundEstimate();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return (results != null) ? results.getRowExpectedCount() : getRowUpperBoundEstimate();
+ }
+
private long getRowUpperBoundEstimate() throws TuplesException {
if (rowUpperBound == -1) {
try {
@@ -443,6 +447,10 @@
return hits.length();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return hits.length();
+ }
+
public int getRowCardinality() throws TuplesException {
switch (hits.length()) {
case 0: return Tuples.ZERO;
Modified: trunk/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java
===================================================================
--- trunk/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-nodetype/java/org/mulgara/resolver/nodetype/TuplesWrapperResolution.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -332,13 +332,23 @@
* This method returns an upper bound on the number of rows which this instance contains.
*
* @return The upper bound of the number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public long getRowUpperBound() throws TuplesException {
return tuples.getRowUpperBound();
}
/**
+ * This method returns an expected size for the number of rows which this instance contains.
+ *
+ * @return The upper bound of the number of rows that this instance contains.
+ * @throws TuplesException Error accessing the underlying data.
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return tuples.getRowExpectedCount();
+ }
+
+ /**
* Returns the number of variables (columns).
*
* @return the number of variables (columns)
Modified: trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java
===================================================================
--- trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-null/java/org/mulgara/resolver/nullres/NullResolution.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -199,6 +199,11 @@
return 0;
}
+ /** @see org.mulgara.query.Cursor#getRowExpectedCount() */
+ public long getRowExpectedCount() throws TuplesException {
+ return 0;
+ }
+
/**
* All implementations must support cloning.
* @return the cloned instance
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/LocalizedTuples.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/LocalizedTuples.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/LocalizedTuples.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -41,6 +41,7 @@
import org.mulgara.query.rdf.BlankNodeImpl;
import org.mulgara.store.nodepool.NodePoolException;
import org.mulgara.store.tuples.AbstractTuples;
+import org.mulgara.store.tuples.Tuples;
import org.mulgara.util.IntFile;
import org.mulgara.util.StringToLongMap;
import org.mulgara.util.TempDir;
@@ -71,8 +72,8 @@
/**
* Logger.
*/
- private static Logger logger =
- Logger.getLogger(LocalizedTuples.class.getName());
+ @SuppressWarnings("unused")
+ private static Logger logger = Logger.getLogger(LocalizedTuples.class.getName());
/** The session to localize into. */
protected final ResolverSession session;
@@ -188,12 +189,15 @@
return answer.getRowCount();
}
- public long getRowUpperBound() throws TuplesException
- {
+ public long getRowUpperBound() throws TuplesException {
return answer.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return answer.getRowExpectedCount();
+ }
+
/**
* We can't possibly know whether an {@link Answer} column might be
* <code>null</code> without materializing it, so we have to assume it could
@@ -212,8 +216,8 @@
}
- public List getOperands() {
- return new ArrayList(0);
+ public List<Tuples> getOperands() {
+ return new ArrayList<Tuples>(0);
}
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SingletonStatements.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SingletonStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/SingletonStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -46,8 +46,7 @@
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class SingletonStatements implements Cloneable, Statements
-{
+public class SingletonStatements implements Cloneable, Statements {
/**
* The columns of the single statement:
* <code>$subject $predicate $object</code>.
@@ -77,8 +76,7 @@
/**
* Construct a single localized RDF statement.
*/
- public SingletonStatements(long subject, long predicate, long object)
- {
+ public SingletonStatements(long subject, long predicate, long object) {
// Validate "subject" parameter
if (subject == NONE) {
throw new IllegalArgumentException("NONE is not a valid subject");
@@ -104,18 +102,15 @@
// Methods implementing Cursor (superinterface of Statements)
//
- public void beforeFirst()
- {
+ public void beforeFirst() {
row = -1;
}
- public void close()
- {
+ public void close() {
// null implementation
}
- public int getColumnIndex(Variable variable) throws TuplesException
- {
+ public int getColumnIndex(Variable variable) throws TuplesException {
// Validate "variable" parameter
if (variable == null) {
throw new IllegalArgumentException("Null \"variable\" parameter");
@@ -142,38 +137,35 @@
}
}
- public int getNumberOfVariables()
- {
+ public int getNumberOfVariables() {
return 3;
}
- public long getRowCount()
- {
+ public long getRowCount() {
return 1;
}
- public long getRowUpperBound()
- {
+ public long getRowExpectedCount() {
+ return 1;
+ }
+
+ public long getRowUpperBound() {
return getRowCount();
}
- public int getRowCardinality()
- {
+ public int getRowCardinality() {
return Cursor.ONE;
}
- public Variable[] getVariables()
- {
+ public Variable[] getVariables() {
return variables;
}
- public boolean isUnconstrained()
- {
+ public boolean isUnconstrained() {
return false;
}
- public boolean next() throws TuplesException
- {
+ public boolean next() throws TuplesException {
switch (row) {
case -1:
row++;
@@ -195,26 +187,22 @@
// Methods implementing Statements
//
- public long getSubject() throws TuplesException
- {
+ public long getSubject() throws TuplesException {
return subject;
}
- public long getPredicate() throws TuplesException
- {
+ public long getPredicate() throws TuplesException {
return predicate;
}
- public long getObject() throws TuplesException
- {
+ public long getObject() throws TuplesException {
return object;
}
/**
* Cloning is always supported.
*/
- public Object clone()
- {
+ public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
@@ -222,8 +210,7 @@
}
}
- public String toString()
- {
+ public String toString() {
return "Singleton[" + subject + " " + predicate + " " + object + "]";
}
}
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperResolution.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperResolution.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperResolution.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -114,11 +114,11 @@
// Calculate columnIndex and set the variable list
int length = 0;
int[] temp = new int[3];
- List variableList = new ArrayList(3);
+ List<Variable> variableList = new ArrayList<Variable>(3);
for (int i = 0; i < 3; i++) {
if (constraint.getElement(i) instanceof Variable) {
temp[length++] = i;
- variableList.add(constraint.getElement(i));
+ variableList.add((Variable)constraint.getElement(i));
}
}
columnIndex = new int[length];
@@ -212,8 +212,8 @@
}
}
- public List getOperands() {
- return Collections.singletonList(statements);
+ public List<Tuples> getOperands() {
+ return Collections.singletonList((Tuples)statements);
}
public long getRowCount() throws TuplesException {
@@ -224,6 +224,10 @@
return statements.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return statements.getRowExpectedCount();
+ }
+
public boolean hasNoDuplicates() throws TuplesException {
return false;
}
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperTuples.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperTuples.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/StatementsWrapperTuples.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -187,8 +187,8 @@
* Returns the wrapped statements object as a singleton list.
* @return List
*/
- public List getOperands() {
- return Collections.singletonList(statements);
+ public List<Tuples> getOperands() {
+ return Collections.singletonList((Tuples)statements);
}
/**
@@ -210,6 +210,15 @@
}
/**
+ * Delegated to the wrapped statements.
+ * @throws TuplesException
+ * @return long
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return statements.getRowExpectedCount();
+ }
+
+ /**
* Can't guarantee the statements are all unique.
* @return boolean
*/
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -55,8 +55,7 @@
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class TripleSetWrapperStatements implements Statements
-{
+public class TripleSetWrapperStatements implements Statements {
// /** Logger. */
// private final Logger logger = Logger.getLogger(TripleSetWrapperStatements.class.getName());
@@ -69,7 +68,7 @@
ResolverSession resolverSession;
- TObjectLongHashMap nodeMap;
+ TObjectLongHashMap<Node> nodeMap;
Set<? extends Triple> triples;
Iterator<? extends Triple> iter;
@@ -84,7 +83,7 @@
throws TuplesException {
this.triples = triples;
this.resolverSession = resolverSession;
- this.nodeMap = new TObjectLongHashMap();
+ this.nodeMap = new TObjectLongHashMap<Node>();
this.persistent = (persistent == PERSIST);
}
@@ -130,6 +129,10 @@
return triples.size();
}
+ public long getRowExpectedCount() {
+ return triples.size();
+ }
+
public int getRowCardinality() {
switch (triples.size()) {
case 0: return ZERO;
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperResolution.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperResolution.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TuplesWrapperResolution.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -54,13 +54,9 @@
*/
public class TuplesWrapperResolution implements Resolution {
- /**
- * Logger.
- *
- * This is named after the class.
- */
- private static final Logger logger =
- Logger.getLogger(TuplesWrapperResolution.class.getName());
+ /** Logger. */
+ @SuppressWarnings("unused")
+ private static final Logger logger = Logger.getLogger(TuplesWrapperResolution.class.getName());
/** The constraint. */
private final Constraint constraint;
@@ -270,7 +266,7 @@
* Be aware that the tuples returned from this method are not cloned, and should
* be considered immutable.
*/
- public List getOperands() {
+ public List<Tuples> getOperands() {
return tuples.getOperands();
}
@@ -336,13 +332,23 @@
* This method returns an upper bound on the number of rows which this instance contains.
*
* @return The upper bound of the number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public long getRowUpperBound() throws TuplesException {
return tuples.getRowUpperBound();
}
/**
+ * This method returns an expected count on the number of rows which this instance contains.
+ *
+ * @return The expected value of the number of rows that this instance contains.
+ * @throws TuplesException Error accessing the underlying data.
+ */
+ public long getRowExpectedCount() throws TuplesException {
+ return tuples.getRowExpectedCount();
+ }
+
+ /**
* Returns the number of variables (columns).
*
* @return the number of variables (columns)
@@ -372,7 +378,7 @@
/**
* Copied from AbstractTuples
*/
- public Annotation getAnnotation(Class annotationClass) throws TuplesException {
+ public Annotation getAnnotation(Class<? extends Annotation> annotationClass) throws TuplesException {
return null;
}
}
Modified: trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolution.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -462,6 +462,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
public int getRowCardinality() throws TuplesException {
if (isEmpty) return Cursor.ZERO;
Modified: trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreXAResource.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreXAResource.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreXAResource.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -37,11 +37,11 @@
import org.mulgara.resolver.spi.AbstractXAResource;
import org.mulgara.resolver.spi.AbstractXAResource.RMInfo;
-import org.mulgara.resolver.spi.AbstractXAResource.TxInfo;
import org.mulgara.resolver.spi.ResolverFactory;
import org.mulgara.store.xa.SimpleXAResource;
import org.mulgara.store.xa.SimpleXAResourceException;
import org.mulgara.store.xa.XAResolverSession;
+import org.mulgara.resolver.spi.AbstractXAResource.TxInfo;
/**
* Implements the XAResource for the {@link StatementStoreResolver}.
@@ -56,6 +56,7 @@
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
+ at SuppressWarnings("unused")
public class StatementStoreXAResource
extends AbstractXAResource<RMInfo<StatementStoreXAResource.StatementStoreTxInfo>, StatementStoreXAResource.StatementStoreTxInfo> {
/** Logger. */
Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -1871,6 +1871,11 @@
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
+
public int getRowCardinality() throws TuplesException {
if (rowCardinality != -1) return rowCardinality;
Tuples temp = (Tuples)this.clone();
Modified: trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLStatements.java
===================================================================
--- trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLStatements.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-url/java/org/mulgara/resolver/url/URLStatements.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -72,8 +72,7 @@
* Software Pty Ltd</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class URLStatements extends AbstractTuples implements Statements
-{
+public class URLStatements extends AbstractTuples implements Statements {
/**
* Logger.
*/
@@ -321,8 +320,7 @@
Cursor.MANY;
}
- public long getRowCount() throws TuplesException
- {
+ public long getRowCount() throws TuplesException {
if (!rowCountIsValid) {
if (parser != null && parser.isStatementCountTotal()) {
// Get the statement count from the parser.
@@ -342,20 +340,27 @@
return rowCount;
}
- public long getRowUpperBound() throws TuplesException
- {
+ public long getRowUpperBound() throws TuplesException {
// If the row count isn't yet available, return an absurdly huge value
return parser != null && parser.isStatementCountTotal() ?
parser.getStatementCount() : Long.MAX_VALUE;
}
- public boolean hasNoDuplicates() throws TuplesException
- {
+ /** Guess at a large number */
+ private static final Long LARGE_FILE_SIZE = 1000000L;
+
+ public long getRowExpectedCount() throws TuplesException {
+ // If the row count isn't yet available, return an absurdly huge value
+ return parser != null && parser.isStatementCountTotal() ?
+ parser.getStatementCount() : LARGE_FILE_SIZE;
+ }
+
+
+ public boolean hasNoDuplicates() throws TuplesException {
return false;
}
- public boolean isColumnEverUnbound(int column) throws TuplesException
- {
+ public boolean isColumnEverUnbound(int column) throws TuplesException {
switch (column) {
case 0: case 1: case 2:
return false;
@@ -364,8 +369,7 @@
}
}
- public boolean next() throws TuplesException
- {
+ public boolean next() throws TuplesException {
if (parser == null) {
// no current row
return false;
@@ -391,8 +395,7 @@
/**
* Stops the thread if it is running, and clears the current row.
*/
- private void stopThread()
- {
+ private void stopThread() {
if (parser != null) {
parser.abort();
parser = null;
@@ -405,11 +408,8 @@
/**
* This {@link Runnable}
*/
-class Parser extends Thread implements ErrorHandler, StatementHandler
-{
- /**
- * Logger.
- */
+class Parser extends Thread implements ErrorHandler, StatementHandler {
+ /** Logger. */
private static final Logger logger =
Logger.getLogger(Parser.class.getName());
Modified: trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java
===================================================================
--- trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformation.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -50,11 +50,9 @@
// Local packages
import org.mulgara.query.*;
import org.mulgara.query.rdf.URIReferenceImpl;
-import org.mulgara.resolver.spi.MutableLocalQuery;
import org.mulgara.resolver.spi.AbstractSymbolicTransformer;
import org.mulgara.resolver.spi.SymbolicTransformationContext;
import org.mulgara.resolver.spi.SymbolicTransformationException;
-import org.mulgara.store.stringpool.StringPoolException;
/**
* A transformation rule that converts XSD ordering constraints into
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswer.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -165,7 +165,7 @@
// Standard answers are not serializable, so either instantiate it into a serializable object
// or wrap in a remote reference
Answer ans = (Answer) obj;
- if (ans.getRowUpperBound() <= MARSHALL_SIZE_LIMIT) {
+ if (ans.getRowExpectedCount() <= MARSHALL_SIZE_LIMIT) {
obj = new ArrayAnswer(ans); // return a serialised answer
ans.close();
}
@@ -279,6 +279,10 @@
return answer.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException, RemoteException {
+ return answer.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException {
return answer.getRowCardinality();
}
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswerSerialised.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswerSerialised.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/AnswerWrapperRemoteAnswerSerialised.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -29,7 +29,6 @@
// Java 2 standard packages
import java.rmi.*;
-import java.util.*;
import java.io.Serializable;
// Third party packages
@@ -282,8 +281,8 @@
* This method returns the number of rows which this instance contains.
*
* @return the number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
- * @throws RemoteException EXCEPTION TO DO
+ * @throws TuplesException Error in the underlying data.
+ * @throws RemoteException Due to network error.
*/
public long getRowCount() throws TuplesException, RemoteException {
return answer.getRowCount();
@@ -293,6 +292,10 @@
return answer.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException, RemoteException {
+ return answer.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException, RemoteException {
return answer.getRowCardinality();
}
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/BlankNodeWrapperAnswer.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/BlankNodeWrapperAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/BlankNodeWrapperAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -60,11 +60,9 @@
*/
public class BlankNodeWrapperAnswer implements Answer {
- /**
- * Logger
- */
- private static Logger logger =
- Logger.getLogger(BlankNodeWrapperAnswer.class.getName());
+ /** Logger */
+ @SuppressWarnings("unused")
+ private static Logger logger = Logger.getLogger(BlankNodeWrapperAnswer.class.getName());
/**
* The wrapped instance.
@@ -74,7 +72,7 @@
/**
* The blank node map.
*/
- protected Map blankNodeMap = null;
+ protected Map<BlankNode,BlankNode> blankNodeMap = null;
/**
* Creates a new wrapper for converting answers with blank nodes.
@@ -84,7 +82,7 @@
* in memory blank nodes.
* @throws IllegalArgumentException if <var>answer</var> is <code>null</code>
*/
- public BlankNodeWrapperAnswer(Answer answer, Map newBlankNodeMap)
+ public BlankNodeWrapperAnswer(Answer answer, Map<BlankNode,BlankNode> newBlankNodeMap)
throws RemoteException {
this.answer = answer;
blankNodeMap = newBlankNodeMap;
@@ -136,11 +134,11 @@
* memory blank node.
* @return the JRDF memory blank node or null if not found.
*/
- private Object getKey(Object serverBlankNode) {
- Set entrySet = blankNodeMap.entrySet();
- Iterator iter = entrySet.iterator();
+ private BlankNode getKey(Object serverBlankNode) {
+ Set<Map.Entry<BlankNode,BlankNode>> entrySet = blankNodeMap.entrySet();
+ Iterator<Map.Entry<BlankNode,BlankNode>> iter = entrySet.iterator();
while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
+ Map.Entry<BlankNode,BlankNode> entry = (Map.Entry<BlankNode,BlankNode>) iter.next();
if (entry.getValue().equals(serverBlankNode)) {
return entry.getKey();
}
@@ -180,6 +178,10 @@
return answer.getRowUpperBound();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return answer.getRowExpectedCount();
+ }
+
public int getRowCardinality() throws TuplesException {
return answer.getRowCardinality();
}
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/JRDFSessionWrapperRemoteJRDFSession.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/JRDFSessionWrapperRemoteJRDFSession.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/JRDFSessionWrapperRemoteJRDFSession.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -71,7 +71,8 @@
* Contains a reference of in memory blank nodes to internal node ids. Reset
* every transaction.
*/
- private HashMap<org.jrdf.graph.mem.BlankNodeImpl,BlankNode> bNodeMap = new HashMap<org.jrdf.graph.mem.BlankNodeImpl,BlankNode>();
+ private HashMap<BlankNode,BlankNode> bNodeMap = new HashMap<BlankNode,BlankNode>();
+// private HashMap<org.jrdf.graph.mem.BlankNodeImpl,BlankNode> bNodeMap = new HashMap<org.jrdf.graph.mem.BlankNodeImpl,BlankNode>();
//
// Constructor
@@ -131,7 +132,7 @@
subjectNode, predicateNode, objectNode), bNodeMap);
try {
- if (ans.getRowUpperBound() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
+ if (ans.getRowExpectedCount() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
RemoteAnswer serialAnswer = new AnswerWrapperRemoteAnswerSerialised(new
ArrayAnswer(ans));
ans.close();
@@ -362,7 +363,7 @@
private RemoteAnswer convertToRemoteAnswer(Answer ans) throws QueryException, RemoteException {
try {
- if (ans.getRowUpperBound() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
+ if (ans.getRowExpectedCount() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
RemoteAnswer serialAnswer = new AnswerWrapperRemoteAnswerSerialised(new ArrayAnswer(ans));
ans.close();
return serialAnswer;
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswer.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -29,12 +29,10 @@
// Java 2 standard packages
import java.rmi.*;
-import java.util.*;
// Third party packages
import org.mulgara.query.TuplesException;
import org.mulgara.query.Variable;
-import org.mulgara.util.MulgaraResultSet;
/**
* Remote ITQL answer. An answer is a set of solutions, where a solution is a
@@ -109,7 +107,7 @@
* was obtained from.
*
* @return the {@link Variable}s bound within this answer.
- * @throws RemoteException EXCEPTION TO DO
+ * @throws RemoteException Due to network error.
*/
public Variable[] getVariables() throws RemoteException;
@@ -120,8 +118,8 @@
* row.
*
* @return The Unconstrained value
- * @throws TuplesException EXCEPTION TO DO
- * @throws RemoteException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
+ * @throws RemoteException Due to network error.
*/
public boolean isUnconstrained() throws TuplesException, RemoteException;
@@ -129,25 +127,20 @@
* Advance to the next term in the solution.
*
* @return <code>false<code> if there was no further term to advance to.
- *
- *
- *
- * @throws TuplesException EXCEPTION TO DO
- * @throws RemoteException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
+ * @throws RemoteException Due to network error.
*/
public boolean next() throws TuplesException, RemoteException;
/**
- * Accessor for the binding of a given variable within the current product
- * term (row).
+ * Accessor for the binding of a given variable within the current product term (row).
*
* @param column PARAMETER TO DO
* @return the bound value, or {@link org.mulgara.store.tuples.Tuples#UNBOUND}
* if there is no binding within the current product term (row)
* @throws TuplesException if there is no current row (before first or after
- * last) or if <var>variable</var> isn't an element of {@link
- * #getVariables}
- * @throws RemoteException EXCEPTION TO DO
+ * last) or if <var>variable</var> isn't an element of {@link #getVariables}
+ * @throws RemoteException Due to network error.
*/
public int getColumnIndex(Variable column)
throws TuplesException, RemoteException;
@@ -156,7 +149,7 @@
* This method returns the exact number of rows which this instance contains.
*
* @return The exact number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public long getRowCount() throws TuplesException, RemoteException;
@@ -164,10 +157,19 @@
* This method returns an upper bound on the number of rows which this instance contains.
*
* @return The upper bound of the number of rows that this instance contains.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public long getRowUpperBound() throws TuplesException, RemoteException;
+ /**
+ * This method returns an expected value of the number of rows which this instance contains.
+ *
+ * @return The expected value of the number of rows that this instance contains.
+ * @throws TuplesException Error accessing the underlying data.
+ */
+ public long getRowExpectedCount() throws TuplesException, RemoteException;
+
+
public static final int ZERO = 0;
public static final int ONE = 1;
public static final int MANY = 2;
@@ -176,14 +178,14 @@
* This method returns cardinality of the number of rows which this instance contains.
*
* @return The cardinality of this tuples. {0,1,N} rows.
- * @throws TuplesException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public int getRowCardinality() throws TuplesException, RemoteException;
/**
* Free resources associated with this instance.
*
- * @throws RemoteException EXCEPTION TO DO
+ * @throws TuplesException Error accessing the underlying data.
*/
public void close() throws TuplesException, RemoteException;
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswerWrapperAnswer.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswerWrapperAnswer.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteAnswerWrapperAnswer.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -52,8 +52,7 @@
* Software Pty Ltd</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-class RemoteAnswerWrapperAnswer
- implements Answer, Cloneable {
+class RemoteAnswerWrapperAnswer implements Answer, Cloneable {
/** logger */
private static Logger logger =
Logger.getLogger(AnswerWrapperRemoteAnswer.class.getName());
@@ -374,6 +373,18 @@
}
}
+ public long getRowExpectedCount() throws TuplesException {
+ try {
+ waitForPrefetchThread();
+ assert prefetchThread == null || prefetchThread.hasFinished();
+ return remoteAnswer.getRowExpectedCount();
+ } catch (RMITimeoutException rmie) {
+ throw new RuntimeException("Timeout waiting on server", rmie);
+ } catch (RemoteException e) {
+ throw new TuplesException("Can't get remote expected row count", e);
+ }
+ }
+
public int getRowCardinality() throws TuplesException {
try {
waitForPrefetchThread();
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -444,7 +444,7 @@
Object servedAnswer = null;
Answer ans = i.next();
try {
- if (ans.getRowUpperBound() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
+ if (ans.getRowExpectedCount() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
// don't need to wrap this in an
// AnswerWrapperRemoteAnswerSerialised as the other end can handle
// any kind of object as it comes out of the list
@@ -635,7 +635,7 @@
private RemoteAnswer convertToRemoteAnswer(Answer ans) throws QueryException, RemoteException {
try {
try {
- if (ans.getRowUpperBound() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
+ if (ans.getRowExpectedCount() <= RemoteAnswer.MARSHALL_SIZE_LIMIT) {
RemoteAnswer serialAnswer = new AnswerWrapperRemoteAnswerSerialised(new ArrayAnswer(ans));
ans.close();
return serialAnswer;
Modified: trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -520,6 +520,13 @@
/**
* {@inheritDoc}
*/
+ public long getRowExpectedCount() throws TuplesException {
+ return set.size();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public int getRowCardinality() throws TuplesException {
int size = set.size();
return size == 0 ? ZERO :
Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -2406,6 +2406,10 @@
return getRowCount();
}
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
/**
* Return the cardinality of the tuples.
*
Modified: trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java 2009-07-10 16:31:20 UTC (rev 1758)
+++ trunk/src/jar/store-stringpool-xa11/java/org/mulgara/store/stringpool/xa11/XA11StringPoolImpl.java 2009-07-10 16:35:27 UTC (rev 1759)
@@ -1824,6 +1824,11 @@
return getRowCount();
}
+ /** Delegates this work to {@link #getRowCount()} */
+ public long getRowExpectedCount() throws TuplesException {
+ return getRowCount();
+ }
+
/**
* Return the cardinality of the tuples.
*
More information about the Mulgara-svn
mailing list