From: <tho...@us...> - 2010-10-20 14:09:25
|
Revision: 3825 http://bigdata.svn.sourceforge.net/bigdata/?rev=3825&view=rev Author: thompsonbry Date: 2010-10-20 14:09:18 +0000 (Wed, 20 Oct 2010) Log Message: ----------- reverting to the old behavior for a query which contains a single statement pattern. this will get the wrong answer for default graph queries against quads, but it does better overall. we are continuing to look into this issue. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 20:46:00 UTC (rev 3824) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-20 14:09:18 UTC (rev 3825) @@ -1829,6 +1829,46 @@ } } + /** + * Override evaluation of StatementPatterns to recognize magic search + * predicate. + */ + @Override + public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( + final StatementPattern sp, final BindingSet bindings) + throws QueryEvaluationException { + + if (log.isDebugEnabled()) { + log.debug("evaluating statement pattern:\n" + sp); + } + + // check for magic search + final Var predVar = sp.getPredicateVar(); + final Value predValue = getVarValue(predVar, bindings); + if (BD.SEARCH.equals(predValue)) { + final Var ovar = sp.getObjectVar(); + final Value oval = getVarValue(ovar, bindings); + if (oval == null) { + throw new QueryEvaluationException(BD.SEARCH + + " : object must be bound."); + } + if (!(oval instanceof Literal)) { + throw new QueryEvaluationException(BD.SEARCH + + " : object must be literal."); + } + final Literal lit = (Literal) oval; + if (lit.getDatatype() != null) { + throw new QueryEvaluationException(BD.SEARCH + + " : object is datatype literal."); + } + return search(sp.getSubjectVar(), lit.getLanguage(), + lit.getLabel(), bindings, sp.getScope()); + } + + return super.evaluate(sp, bindings); + + } + // /** // * Override evaluation of StatementPatterns to recognize magic search // * predicate. @@ -1838,72 +1878,32 @@ // final StatementPattern sp, final BindingSet bindings) // throws QueryEvaluationException { // +// // no check against the nativeJoins property here because we are simply +// // using the native execution model to take care of magic searches. +// // if (log.isDebugEnabled()) { // log.debug("evaluating statement pattern:\n" + sp); // } // -// // check for magic search -// final Var predVar = sp.getPredicateVar(); -// final Value predValue = getVarValue(predVar, bindings); -// if (BD.SEARCH.equals(predValue)) { -// final Var ovar = sp.getObjectVar(); -// final Value oval = getVarValue(ovar, bindings); -// if (oval == null) { -// throw new QueryEvaluationException(BD.SEARCH -// + " : object must be bound."); -// } -// if (!(oval instanceof Literal)) { -// throw new QueryEvaluationException(BD.SEARCH -// + " : object must be literal."); -// } -// final Literal lit = (Literal) oval; -// if (lit.getDatatype() != null) { -// throw new QueryEvaluationException(BD.SEARCH -// + " : object is datatype literal."); -// } -// return search(sp.getSubjectVar(), lit.getLanguage(), -// lit.getLabel(), bindings, sp.getScope()); +// final IStep query = createNativeQuery(sp); +// +// if (query == null) { +// return new EmptyIteration<BindingSet, QueryEvaluationException>(); // } +// +// try { // -// return super.evaluate(sp, bindings); +// return execute(query, bindings); +// +// } catch (Exception ex) { +// +// throw new QueryEvaluationException(ex); +// +// } // // } - /** - * Override evaluation of StatementPatterns to recognize magic search - * predicate. - */ - @Override - public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( - final StatementPattern sp, final BindingSet bindings) - throws QueryEvaluationException { - - // no check against the nativeJoins property here because we are simply - // using the native execution model to take care of magic searches. - - if (log.isDebugEnabled()) { - log.debug("evaluating statement pattern:\n" + sp); - } - - final IStep query = createNativeQuery(sp); - - if (query == null) { - return new EmptyIteration<BindingSet, QueryEvaluationException>(); - } - try { - - return execute(query, bindings); - - } catch (Exception ex) { - - throw new QueryEvaluationException(ex); - - } - - } - - /** * Evaluates the {@link BD#SEARCH} magic predicate as a full-text search * against the index literal in the database, binding <i>svar</i> to each This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |