From: <tho...@us...> - 2011-06-03 11:35:24
|
Revision: 4613 http://bigdata.svn.sourceforge.net/bigdata/?rev=4613&view=rev Author: thompsonbry Date: 2011-06-03 11:35:18 +0000 (Fri, 03 Jun 2011) Log Message: ----------- Bug fix for [1]. This appears to be a bug in Constant#equals(Object o). The code was written to allow comparison with IConstantOrVariable. However, IVariable#get() always throws an UnsupportedOperationException? since it is not possible to obtain the asBound value of a variable without reference to a binding set. I have modified Constant#equals() to return false unless the passed Object is another IConstant. I also added a fast code path for tests against self. This is sufficient to have the unit test pass. I am now running through the test suites for the SAIL to verify that this change has not broken anything else. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTicket276.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java 2011-06-03 11:01:17 UTC (rev 4612) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java 2011-06-03 11:35:18 UTC (rev 4613) @@ -137,14 +137,25 @@ final public boolean equals(final Object o) { - if(!(o instanceof IVariableOrConstant<?>)) { - - // incomparable types. + if (this == o) + return true; + + if(!(o instanceof IConstant<?>)) { + + /* + * Incomparable types. + * + * Note: This used to permit IVariableOrConstant, but it is not + * possible to invoke get() on an IVariable without a bindingSet + * against which to resolve its asBound value. + * + * See https://sourceforge.net/apps/trac/bigdata/ticket/276 + */ return false; } - final Object otherValue = ((IVariableOrConstant<?>) o).get(); + final Object otherValue = ((IConstant<?>) o).get(); // handles reference equality, including when both are null. if (value == otherValue) Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTicket276.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTicket276.java 2011-06-03 11:01:17 UTC (rev 4612) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTicket276.java 2011-06-03 11:35:18 UTC (rev 4613) @@ -19,12 +19,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +*/ package com.bigdata.rdf.sail; import java.io.IOException; import java.util.Properties; +import java.util.Set; import org.openrdf.OpenRDFException; import org.openrdf.model.Statement; @@ -105,7 +106,7 @@ props.setProperty(BigdataSail.Options.ALLOW_SESAME_QUERY_EVALUATION, "false"); props.setProperty( - com.bigdata.rdf.store.AbstractTripleStore.Options.STATEMENT_IDENTIFIERS, + BigdataSail.Options.STATEMENT_IDENTIFIERS, "false"); return props; @@ -133,13 +134,13 @@ RDFHandlerException { try { repo.initialize(); - RepositoryConnection conn = repo.getConnection(); + final RepositoryConnection conn = repo.getConnection(); try { - ValueFactory vf = conn.getValueFactory(); + final ValueFactory vf = conn.getValueFactory(); addData(conn); - final String query = "SELECT ?x { ?x ?a ?t . ?x ?lookup ?l }"; - TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SPARQL, + final String query = "SELECT ?x { ?x ?a ?t . ?x ?lookup ?l }"; + final TupleQuery q = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); q.setBinding( "a", @@ -147,9 +148,13 @@ q.setBinding("t", vf.createURI("os:class/Location")); q.setBinding("lookup", vf.createURI("os:prop/lookupName")); q.setBinding("l", vf.createLiteral("amsterdam")); - TupleQueryResult tqr = q.evaluate(); - while (tqr.hasNext()) - System.out.println(tqr.next().getBindingNames()); + final TupleQueryResult tqr = q.evaluate(); + while (tqr.hasNext()) { + final Set<String> bindingNames = tqr.next() + .getBindingNames(); + if (log.isInfoEnabled()) + log.info("bindingNames=" + bindingNames); + } tqr.close(); } finally { conn.close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |