Class SparqlEngine

Description

This engine executes SPARQL queries against an RDF Datatset.



History:

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

Object
   |
   --SparqlEngine
Method Summary
Array buildVarmap (String $order, Array $vartable)
String buildXmlResult ($vartable $vartable)
boolean checkIntBindings (Triple $trip, Array $intBindings)
MemModel constructGraph (Array $vartable, GraphPattern $constructPattern)
MemModel describeGraph (Array $vartable)
Array distinct (Array $vartable)
String fillConstraintString (Array $vars, Array $res, Constraint $constraint, Array $function)
Array filterPatterns (Array $patternlist, boolean $outer)
Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
Array joinOptionalTuples (Array &$finalRes, Array &$res)
Array joinResults (Array $patternlist)
Array joinTuples (Array &$finalRes, Array &$res)
void matchPattern (Array &$patternlist, array $graphlist, GraphPattern &$graphPattern)
Array matchPatterns (Array $graphlist)
Array preselectGraphs ()
Array/String queryModel (Dataset $dataset, Query $query, [String $resultform = false])
Array/String returnResult (Array $vartable, [String/boolean $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 (GraphPattern &$pattern, Array $graphlist)
String _determineType (Node $var, MemModel $resultGraph)
void _getAttributes (Array $list, MemModel $resultGraph, mixed $varvalue)
String _getBindindString (String $varname, Node $varvalue)
Methods
buildVarmap (line 934)

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
buildXmlResult (line 1219)

Generates an xml string from a given result table.

  • return: The xml result string
  • access: protected
String buildXmlResult ($vartable $vartable)
  • $vartable $vartable: The result table
checkIntBindings (line 245)

Checks it there are internal bindings between variables.

  • access: protected
boolean checkIntBindings (Triple $trip, Array $intBindings)
  • Triple $trip
  • Array $intBindings
constructGraph (line 1005)

Constructs a result graph.

  • return: the result graph which matches the CONSTRUCT pattern
  • access: protected
MemModel constructGraph (Array $vartable, GraphPattern $constructPattern)
  • Array $vartable: a table containing the result vars and their bindings
  • GraphPattern $constructPattern: the CONSTRUCT pattern
describeGraph (line 1052)

Builds a describing named graph. To define an attribute list for a several rdf:type look at constants.php

  • access: protected
MemModel describeGraph (Array $vartable)
  • Array $vartable
distinct (line 1154)

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
fillConstraintString (line 697)

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 602)

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 159)

Finds Tuples matching one TriplePattern.

  • access: protected
Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
  • TriplePattern $pattern
  • Array $graphlist
joinOptionalTuples (line 347)

Joins OPTIONAL pattern results.

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

Joins the results of the different Graphpatterns.

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

Perform an SQL-like inner join on two resultSets.

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

Finds tuples that match one graph pattern.

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

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 417)

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

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

The query engines 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
  • Query $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/ .
returnResult (line 1176)

Generates the result object.

  • return: The result
  • access: protected
Array/String returnResult (Array $vartable, [String/boolean $resultform = false])
  • Array $vartable: The result table
  • String/boolean $resultform: 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 531)

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 903)

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 1302)

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 461)

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 494)

Builds the resultset.

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

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 (GraphPattern &$pattern, Array $graphlist)
_determineType (line 1092)

Tries to determine the rdf:type of the variable.

  • return: Uri of the rdf:type
  • access: protected
String _determineType (Node $var, MemModel $resultGraph)
  • Node $var: The variable
  • MemModel $resultGraph: The result graph which describes the Resource
_getAttributes (line 1127)

Search the attributes listed in $list in the dataset.

  • access: protected
void _getAttributes (Array $list, MemModel $resultGraph, mixed $varvalue)
  • Array $list: List containing the attributes
  • MemModel $resultGraph: The result graph which describes the Resource
_getBindindString (line 1273)

Helper Function for function buildXmlResult($vartable). Generates an xml string for a single variable an their corresponding value.

  • return: The xml string
  • access: protected
String _getBindindString (String $varname, Node $varvalue)
  • String $varname: The variables name
  • Node $varvalue: The value of the variable

Inherited Methods

Inherited From Object

Object::toString()

Documentation generated on Fri, 13 Jan 2006 07:49:40 +0100 by phpDocumentor 1.3.0RC4