Class SparqlEngine

Description

This engine executes SPARQL queries against an RDF Datatset.

  • author: Tobias Gauß <tobias.gauss@web.de>
  • version: $Id: SparqlEngine.html 443 2007-06-01 16:25:38Z cax $

Located in /sparql/SparqlEngine.php (line 19)

Object
   |
   --SparqlEngine
Variable Summary
Method Summary
SparqlEngine __construct ()
Array buildVarmap (String $order, Array $vartable)
boolean checkIntBindings (Triple $trip, Array $intBindings)
Array distinct (Array $vartable)
void factory ([Model $model = null])
String fillConstraintString (Array $vars, Array $res, Constraint $constraint, Array $function)
Array filterPatterns (Array $patternlist, boolean $outer)
Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
void getDataset ()
void getQuery ()
Array joinOptionalTuples (Array &$finalRes, Array &$res)
Array joinResults (Array $patternlist)
Array joinTuples (Array &$finalRes, Array &$res)
void matchPattern ( &$patternlist, array $graphlist,  &$graphPattern, Array $patternlist, GraphPattern $graphPattern)
Array matchPatterns (Array $graphlist)
Array preselectGraphs ()
Array/String queryModel (Dataset $dataset, Query $query, [String $resultform = false])
Array selectVars (Array $table, Array $vars)
Array sortVars (Array $vartable)
void writeQueryResultAsHtmlTable (array $queryResult)
Array _buildIntBindings (Array $var)
Array _buildResultSet (GraphPattern $pattern, Array $resmodel)
Array _checkGraphs ( &$pattern, Array $graphlist, GraphPattern $pattern)
Variables
Dataset $dataset (line 32)

The RDF Dataset.

  • access: protected
Query $query (line 26)

The query object.

  • access: protected
Methods
Constructor __construct (line 40)

Use SparqlEngine::factory() instead of this constructor.

  • access: protected
SparqlEngine __construct ()
buildVarmap (line 998)

Sorts the result table.

  • return: A map that contains the new order of the result vars
  • access: protected
Array buildVarmap (String $order, Array $vartable)
  • String $order: (ASC/DESC)
  • Array $vartable: the vartable
checkIntBindings (line 304)

Checks it there are internal bindings between variables.

  • access: protected
boolean checkIntBindings (Triple $trip, Array $intBindings)
  • Triple $trip
  • Array $intBindings
distinct (line 1070)

Eliminates duplicate results.

  • return: the result table without duplicate results
  • access: protected
Array distinct (Array $vartable)
  • Array $vartable: a table that contains the result vars and their bindings
factory (line 53)

Creates a new instance of the SparqlEngine, depending on the given model. For example, if you pass a DbModel, you will get a SparqlEngine specialized on databases.

  • access: public
void factory ([Model $model = null])
  • Model $model: RDF model that uses the engine
fillConstraintString (line 760)

Builds an evaluation string to determine wether the result passes the filter or not. This string is evaluatet by the php buildin eval() function

  • access: protected
String fillConstraintString (Array $vars, Array $res, Constraint $constraint, Array $function)
  • Array $vars: a list which contains the used variables
  • Array $res: the result part which have to be evaluated
  • Constraint $constraint: the Constrain object
  • Array $function: an Array which contains the used functions
filterPatterns (line 665)

Filters the pattern results.

  • return: the filtered patternlist
  • access: protected
Array filterPatterns (Array $patternlist, boolean $outer)
  • Array $patternlist: list containing the results of the GraphPatterns
  • boolean $outer: TRUE if its an outer filter FALSE if not
findTuplesMatchingOnePattern (line 216)

Finds Tuples matching one TriplePattern.

  • access: protected
Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
  • TriplePattern $pattern
  • Array $graphlist
getDataset (line 1161)
  • access: public
void getDataset ()
getQuery (line 1154)
  • access: public
void getQuery ()
joinOptionalTuples (line 406)

Joins OPTIONAL pattern results.

  • return: the joined Array
  • access: protected
Array joinOptionalTuples (Array &$finalRes, Array &$res)
  • Array &$finalRes
  • Array &$res
joinResults (line 618)

Joins the results of the different Graphpatterns.

  • access: protected
Array joinResults (Array $patternlist)
  • Array $patternlist
joinTuples (line 343)

Perform an SQL-like inner join on two resultSets.

  • access: protected
Array joinTuples (Array &$finalRes, Array &$res)
  • Array &$finalRes
  • Array &$res
matchPattern (line 152)

Finds tuples that match one graph pattern.

  • access: protected
void matchPattern ( &$patternlist, array $graphlist,  &$graphPattern, Array $patternlist, GraphPattern $graphPattern)
  • Array $patternlist: list that contains the graphPatterns
  • array $graphlist: the graphlist
  • GraphPattern $graphPattern: the pattern which has to be matched
  • &$patternlist
  • &$graphPattern
matchPatterns (line 130)

Matches all graph Patterns against the dataset and generates an array which contains the result sets for every given GraphPattern.

  • access: protected
Array matchPatterns (Array $graphlist)
  • Array $graphlist: the graphlist which contains the names of the named graphs which has to be queried.
preselectGraphs (line 480)

Looks in from and from named part of the query and adds the graphs to the graphlist.

  • access: protected
Array preselectGraphs ()
queryModel (line 74)

The query engine's main method.

  • return: Type of the result depends on $resultform.
  • access: public
Array/String queryModel (Dataset $dataset, Query $query, [String $resultform = false])
  • Dataset $dataset: the RDF Dataset
  • mixed $query: the parsed SPARQL query
  • String $resultform: the result form. If set to 'xml' the result will be SPARQL Query Results XML Format as described in http://www.w3.org/TR/rdf-sparql-XMLres/ .
selectVars (line 594)

Selects the result variables and builds a result table.

  • access: protected
Array selectVars (Array $table, Array $vars)
  • Array $table: the result table
  • Array $vars: the result variables
sortVars (line 966)

Sorts the results.

  • return: List containing the sorted result vars
  • access: protected
Array sortVars (Array $vartable)
  • Array $vartable: List containing the unsorted result vars
writeQueryResultAsHtmlTable (line 1094)

Prints a query result as HTML table.

You can change the colors in the configuration file.

  • access: public
void writeQueryResultAsHtmlTable (array $queryResult)
  • array $queryResult: [][?VARNAME] = object Node
_buildIntBindings (line 524)

Marks triples with internal bindings.

int bindings -1 :none 0:sub=pred 1:sub=obj 2:pred=obj 3:sub=pred=obj.

  • access: protected
Array _buildIntBindings (Array $var)
  • Array $var
_buildResultSet (line 557)

Builds the resultset.

  • access: protected
Array _buildResultSet (GraphPattern $pattern, Array $resmodel)
_checkGraphs (line 497)

Evaluates the GRPAH clause if there is one. Checks if the GRAPH clause contains an IRI, variable or nothing.

Returns an array which contains the graphs that has to be matched.

  • access: protected
Array _checkGraphs ( &$pattern, Array $graphlist, GraphPattern $pattern)

Inherited Methods

Inherited From Object

Object::toString()

Documentation generated on Fri, 1 Jun 2007 16:52:05 +0200 by phpDocumentor 1.3.2