Learn R Programming

redland (version 1.0.17-6)

Query-class: Query an RDF model

Description

The Query class is used to execuate a query on a Model object using the default query language SPARQL. For more information, please refer to http://librdf.org/rasqal/ for details on supported query languages.

Arguments

Methods

{: Initialize a Query object.} executeQuery{: Execute a query.} setQueryResultLimit{: Set limit on returned query results.} getQueryResultLimit{: Get the query result limit.} freeParser{: Free memory used by a librdf query.}

Details

A Query is executed using the executeQuery method, which returns a QueryResults object that can be interated over the query solution sequence.

References

www.example.com

See Also

redland{: redland package}

Examples

Run this code
world <- new("World")
storage <- new("Storage", world, "hashes", name="", options="hash-type='memory'")
model <- new("Model", world, storage, options="")
stmt <- new("Statement", world=world, 
  subject="https://cn.dataone.org/cn/v1/resolve/urn:uuid:274a0c5c-3082-4562-bbd3-2b1288768cac",
  predicate="http://www.w3.org/ns/prov#hadPlan",
  object="https://cn.dataone.org/cn/v1/resolve/urn:uuid:01305f45-f22b-40c8-8d27-00357d01e4a5")
status <- addStatement(model, stmt)
stmt <- new("Statement", world=world, 
           subject="https://orcid.org/0000-0002-2192-403X",
           predicate="http://www.w3.org/ns/prov#Agent",
           object="slaughter", 
           objectType="literal", 
           datatype_uri="http://www.w3.org/2001/XMLSchema#string")
status <- addStatement(model, stmt)
queryString <- 
    paste("PREFIX orcid: <https://orcid.org/>",
          "PREFIX dataone: <https://cn.dataone.org/cn/v1/resolve/>",
          "PREFIX prov: <http://www.w3.org/ns/prov#>",
          "SELECT ?a ?c WHERE { ?a prov:Agent ?c . }", sep="")
query <- new("Query", world, queryString, base_uri=NULL, query_language="sparql", query_uri=NULL)
queryResult <- executeQuery(query, model)
result <- getNextResult(queryResult)

Run the code above in your browser using DataLab