diff rdf/SimpleSPARQLQuery.h @ 492:23945cdd7161

* Update RDF query stuff again so as to set up a temporary datastore each time we want to query over an rdf file, instead of using rasqal against the file. Seems the only way to avoid threading and storage management issues when trying to load from a single-source file and perform queries against our main datastore at the same time. Maybe.
author Chris Cannam
date Mon, 24 Nov 2008 16:26:11 +0000
parents 82ab61fa9223
children a03aafaacb5a
line wrap: on
line diff
--- a/rdf/SimpleSPARQLQuery.h	Mon Nov 24 12:26:21 2008 +0000
+++ b/rdf/SimpleSPARQLQuery.h	Mon Nov 24 16:26:11 2008 +0000
@@ -37,16 +37,52 @@
     typedef std::map<QString, Value> KeyValueMap;
     typedef std::vector<KeyValueMap> ResultList;
 
+    /**
+     * QueryType specifies the context in which the query will be
+     * evaluated.  SimpleSPARQLQuery maintains a general global data
+     * model, into which data can be loaded using addSourceToModel(),
+     * as well as permitting one-time queries directly on data sources
+     * identified by URL.
+     *
+     * The query type QueryFromModel indicates a query to be evaluated
+     * over the general global model; the query type
+     * QueryFromSingleSource indicates that the query should be
+     * evaluated in the context of a model generated solely by parsing
+     * the FROM url found in the query.
+     *
+     * Even in QueryFromSingleSource mode, the parsed data remains in
+     * memory and will be reused in subsequent queries with the same
+     * mode and FROM url.  To release data loaded in this way once all
+     * queries across it are complete, pass the said FROM url to
+     * closeSingleSource().
+     */
     enum QueryType {
         QueryFromModel,
         QueryFromSingleSource
     };
 
+    /**
+     * Construct a query of the given type (indicating the data model
+     * context for the query) using the given SPARQL query content.
+     */
     SimpleSPARQLQuery(QueryType type, QString query);
     ~SimpleSPARQLQuery();
 
+    /**
+     * Add the given URI to the general global model used for
+     * QueryFromModel queries.
+     */
     static bool addSourceToModel(QString sourceUri);
 
+    /**
+     * Release any data that has been loaded from the given source as
+     * part of a QueryFromSingleSource query with this source in the
+     * FROM clause.  Note this will not prevent any subsequent queries
+     * on the source from working -- it will just make them slower as
+     * the data will need to be re-parsed.
+     */
+    static void closeSingleSource(QString sourceUri);
+
     void setProgressReporter(ProgressReporter *reporter);
     bool wasCancelled() const;
     
@@ -55,8 +91,10 @@
     bool isOK() const;
     QString getErrorString() const;
 
-    // Do a query and return the value for the given binding, from the
-    // first result that has a value for it
+    /**
+     * Construct and execute a query, and return the first result
+     * value for the given binding.
+     */
     static Value singleResultQuery(QueryType type,
                                    QString query,
                                    QString binding);