Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
491:6f8ee19984ad | 492:23945cdd7161 |
---|---|
35 }; | 35 }; |
36 | 36 |
37 typedef std::map<QString, Value> KeyValueMap; | 37 typedef std::map<QString, Value> KeyValueMap; |
38 typedef std::vector<KeyValueMap> ResultList; | 38 typedef std::vector<KeyValueMap> ResultList; |
39 | 39 |
40 /** | |
41 * QueryType specifies the context in which the query will be | |
42 * evaluated. SimpleSPARQLQuery maintains a general global data | |
43 * model, into which data can be loaded using addSourceToModel(), | |
44 * as well as permitting one-time queries directly on data sources | |
45 * identified by URL. | |
46 * | |
47 * The query type QueryFromModel indicates a query to be evaluated | |
48 * over the general global model; the query type | |
49 * QueryFromSingleSource indicates that the query should be | |
50 * evaluated in the context of a model generated solely by parsing | |
51 * the FROM url found in the query. | |
52 * | |
53 * Even in QueryFromSingleSource mode, the parsed data remains in | |
54 * memory and will be reused in subsequent queries with the same | |
55 * mode and FROM url. To release data loaded in this way once all | |
56 * queries across it are complete, pass the said FROM url to | |
57 * closeSingleSource(). | |
58 */ | |
40 enum QueryType { | 59 enum QueryType { |
41 QueryFromModel, | 60 QueryFromModel, |
42 QueryFromSingleSource | 61 QueryFromSingleSource |
43 }; | 62 }; |
44 | 63 |
64 /** | |
65 * Construct a query of the given type (indicating the data model | |
66 * context for the query) using the given SPARQL query content. | |
67 */ | |
45 SimpleSPARQLQuery(QueryType type, QString query); | 68 SimpleSPARQLQuery(QueryType type, QString query); |
46 ~SimpleSPARQLQuery(); | 69 ~SimpleSPARQLQuery(); |
47 | 70 |
71 /** | |
72 * Add the given URI to the general global model used for | |
73 * QueryFromModel queries. | |
74 */ | |
48 static bool addSourceToModel(QString sourceUri); | 75 static bool addSourceToModel(QString sourceUri); |
76 | |
77 /** | |
78 * Release any data that has been loaded from the given source as | |
79 * part of a QueryFromSingleSource query with this source in the | |
80 * FROM clause. Note this will not prevent any subsequent queries | |
81 * on the source from working -- it will just make them slower as | |
82 * the data will need to be re-parsed. | |
83 */ | |
84 static void closeSingleSource(QString sourceUri); | |
49 | 85 |
50 void setProgressReporter(ProgressReporter *reporter); | 86 void setProgressReporter(ProgressReporter *reporter); |
51 bool wasCancelled() const; | 87 bool wasCancelled() const; |
52 | 88 |
53 ResultList execute(); | 89 ResultList execute(); |
54 | 90 |
55 bool isOK() const; | 91 bool isOK() const; |
56 QString getErrorString() const; | 92 QString getErrorString() const; |
57 | 93 |
58 // Do a query and return the value for the given binding, from the | 94 /** |
59 // first result that has a value for it | 95 * Construct and execute a query, and return the first result |
96 * value for the given binding. | |
97 */ | |
60 static Value singleResultQuery(QueryType type, | 98 static Value singleResultQuery(QueryType type, |
61 QString query, | 99 QString query, |
62 QString binding); | 100 QString binding); |
63 | 101 |
64 protected: | 102 protected: |