Skip to content

Commit

Permalink
Merge pull request #595 from eclipse/issues/#164-extended-strategy
Browse files Browse the repository at this point in the history
Issue #164: extended query eval strategy
  • Loading branch information
abrokenjester authored Oct 16, 2016
2 parents a1d880e + ff70ff9 commit 5bd362d
Show file tree
Hide file tree
Showing 28 changed files with 2,452 additions and 2,077 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sparql="http://www.w3.org/2005/sparql-results#" xmlns="http://www.w3.org/1999/xhtml">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sparql="http://www.w3.org/2005/sparql-results#"
xmlns="http://www.w3.org/1999/xhtml">

<xsl:include href="../locale/messages.xsl" />

Expand Down Expand Up @@ -54,11 +54,10 @@
<xsl:value-of select="$repository-persist.label" />
</th>
<td>
<input type="radio" name="Persist" size="48"
value="true" checked="true" />
<input type="radio" name="Persist" size="48" value="true"
checked="true" />
<xsl:value-of select="$true.label" />
<input type="radio" name="Persist" size="48"
value="false" />
<input type="radio" name="Persist" size="48" value="false" />
<xsl:value-of select="$false.label" />
</td>
<td></td>
Expand All @@ -79,8 +78,13 @@
</th>
<td>
<select id="evalStratFactory" name="EvaluationStrategyFactory">
<option value="org.eclipse.rdf4j.query.algebra.evaluation.impl.SimpleEvaluationStrategyFactory">
Strict
<option selected="selected"
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory">
Strict
</option>
<option
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.ExtendedEvaluationStrategyFactory">
Extended
</option>
</select>
</td>
Expand All @@ -91,7 +95,7 @@
<td>
<input type="button" value="{$cancel.label}" style="float:right"
data-href="repositories"
onclick="document.location.href=this.getAttribute('data-href')" />
onclick="document.location.href=this.getAttribute('data-href')" />
<input id="create" type="button" value="{$create.label}"
onclick="checkOverwrite()" />
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@
</th>
<td>
<select id="evalStratFactory" name="EvaluationStrategyFactory">
<option value="org.eclipse.rdf4j.query.algebra.evaluation.impl.SimpleEvaluationStrategyFactory">
Strict
<option selected="selected"
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory">
Strict
</option>
<option
value="org.eclipse.rdf4j.query.algebra.evaluation.impl.ExtendedEvaluationStrategyFactory">
Extended
</option>
</select>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.query.Dataset;
import org.eclipse.rdf4j.query.algebra.TupleExpr;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.SimpleEvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy;

/**
* Interface used by {@link SimpleEvaluationStrategy} prior to evalutating the query.
* Interface used by {@link StrictEvaluationStrategy} prior to evalutating the query.
*
* @author James Leigh
* @author Arjohn Kampman
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;

/**
* @deprecated since 4.0. Use {@link SimpleEvaluationStrategy} instead.
* @deprecated since 4.0. Use {@link StrictEvaluationStrategy} instead.
* @author Jeen Broekstra
*/
@Deprecated
public class EvaluationStrategyImpl extends SimpleEvaluationStrategy {
public class EvaluationStrategyImpl extends StrictEvaluationStrategy {

public EvaluationStrategyImpl(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2016 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.rdf4j.query.algebra.evaluation.impl;

import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.impl.BooleanLiteral;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.query.Dataset;
import org.eclipse.rdf4j.query.QueryEvaluationException;
import org.eclipse.rdf4j.query.algebra.Compare;
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource;
import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.util.QueryEvaluationUtil;

/**
* SPARQL 1.1 extended query evaluation strategy. This strategy adds the use of virtual properties, as well as
* extended comparison operators to the minimally-conforming {@link StrictEvaluationStrategy}.
*
* @author Jeen Broekstra
*/
public class ExtendedEvaluationStrategy extends TupleFunctionEvaluationStrategy {

public ExtendedEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
FederatedServiceResolver serviceResolver)
{
super(tripleSource, dataset, serviceResolver);
}

@Override
public Value evaluate(Compare node, BindingSet bindings)
throws ValueExprEvaluationException, QueryEvaluationException
{
Value leftVal = evaluate(node.getLeftArg(), bindings);
Value rightVal = evaluate(node.getRightArg(), bindings);

// return result of non-strict comparison.
return BooleanLiteral.valueOf(
QueryEvaluationUtil.compare(leftVal, rightVal, node.getOperator(), false));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2016 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*******************************************************************************/
package org.eclipse.rdf4j.query.algebra.evaluation.impl;

import org.eclipse.rdf4j.query.Dataset;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategyFactory;
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolver;
import org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient;

public class ExtendedEvaluationStrategyFactory
implements EvaluationStrategyFactory, FederatedServiceResolverClient
{

private FederatedServiceResolver serviceResolver;

public ExtendedEvaluationStrategyFactory() {
}

public ExtendedEvaluationStrategyFactory(FederatedServiceResolver resolver) {
this.serviceResolver = resolver;
}

@Override
public void setFederatedServiceResolver(FederatedServiceResolver resolver) {
this.serviceResolver = resolver;
}

public FederatedServiceResolver getFederatedServiceResolver() {
return serviceResolver;
}

@Override
public EvaluationStrategy createEvaluationStrategy(Dataset dataset, TripleSource tripleSource) {
return new ExtendedEvaluationStrategy(tripleSource, dataset, serviceResolver);
}
}
Loading

0 comments on commit 5bd362d

Please sign in to comment.