org.openanzo.glitter.query
Class SPARQLAlgebra

java.lang.Object
  extended by org.openanzo.glitter.query.SPARQLAlgebra

public class SPARQLAlgebra
extends java.lang.Object

A collection of static utility methods that implement the algebraic functions for composing sets of SPARQL solutions.

Author:
lee

Constructor Summary
SPARQLAlgebra()
           
 
Method Summary
static SolutionSet filterSolutions(SolutionSet answers, java.util.Set<Expression> filters)
          Applies the given set of filters to a full solution set.
static SolutionSet join(SolutionSet set1, SolutionSet set2)
          Conjoins two solution sets.
static boolean keepSolution(PatternSolution solution, java.util.Set<Expression> filters)
           
static boolean keepSolution(PatternSolution solution, java.util.Set<Expression> filters, boolean keepSolutionsWithUnboundVariables)
           
static SolutionSet leftJoin(SolutionSet set1, SolutionSet set2, java.util.Set<Expression> filters)
          Implements the SPARQL LeftJoin operator.
static boolean solutionBindsAllVariables(PatternSolution solution, java.util.Collection<Variable> variables)
          Returns whether or not the given solution contains values for all of the given variables.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPARQLAlgebra

public SPARQLAlgebra()
Method Detail

join

public static SolutionSet join(SolutionSet set1,
                               SolutionSet set2)
Conjoins two solution sets. (A null list of solutions functions equivalently to a solution set with a single bindings-less solution. This is shorthand and is COMPLETELY different from a solution set with zero solutions (which conjoins with any other solution set to the empty solution set).)

Parameters:
set1 -
set2 -
Returns:
The conjunction of the two solution sets.

solutionBindsAllVariables

public static boolean solutionBindsAllVariables(PatternSolution solution,
                                                java.util.Collection<Variable> variables)
Returns whether or not the given solution contains values for all of the given variables.

Parameters:
solution -
variables -
Returns:
whether or not the given solution contains values for all of the given variables

keepSolution

public static boolean keepSolution(PatternSolution solution,
                                   java.util.Set<Expression> filters)
                            throws ExpressionEvaluationException
Parameters:
solution -
filters -
Returns:
true if the given solution passes all of the supplied filters; false otherwise.
Throws:
ExpressionEvaluationException

keepSolution

public static boolean keepSolution(PatternSolution solution,
                                   java.util.Set<Expression> filters,
                                   boolean keepSolutionsWithUnboundVariables)
                            throws ExpressionEvaluationException
Parameters:
solution -
filters -
keepSolutionsWithUnboundVariables - If true, a filter expression that acts on unbound variables is ignored. If false, such a filter expression evaluates to an error, which rejects the solution.
Returns:
true if the given solution passes all of the supplied filters; false otherwise.
Throws:
ExpressionEvaluationException

filterSolutions

public static SolutionSet filterSolutions(SolutionSet answers,
                                          java.util.Set<Expression> filters)
                                   throws ExpressionEvaluationException
Applies the given set of filters to a full solution set.

Parameters:
answers -
filters -
Returns:
A solution set containing only those solutions from answers for which keepSolution(PatternSolution, Set) returns true.
Throws:
ExpressionEvaluationException

leftJoin

public static SolutionSet leftJoin(SolutionSet set1,
                                   SolutionSet set2,
                                   java.util.Set<Expression> filters)
Implements the SPARQL LeftJoin operator. (For the SPARQL OPTIONAL keyword.)

Parameters:
set1 - The left-hand-side of the outer join. See the SPARQL spec. for precise semantics.
set2 - The right-hand-side of the outer join.
filters - Filters that are scoped to this left join.
Returns:
The results of applying the LeftJoin operator.


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.