comparison rdf/SimpleSPARQLQuery.cpp @ 493:3931711b5671

* RDF importer: add model titles where possible * RDF transform factory: report whether something appears to be RDF or not (so we can avoid trying to load it as something else if the RDF query fails)
author Chris Cannam
date Tue, 25 Nov 2008 13:43:56 +0000
parents 23945cdd7161
children 81963c51b488
comparison
equal deleted inserted replaced
492:23945cdd7161 493:3931711b5671
163 } 163 }
164 164
165 void 165 void
166 WredlandWorldWrapper::freeModel(QString forUri) 166 WredlandWorldWrapper::freeModel(QString forUri)
167 { 167 {
168 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
169 std::cerr << "SimpleSPARQLQuery::freeModel: Model uri = \"" << forUri.toStdString() << "\"" << std::endl;
170 #endif
171
168 QMutexLocker locker(&m_mutex); 172 QMutexLocker locker(&m_mutex);
169 if (forUri == "") { 173 if (forUri == "") {
170 std::cerr << "SimpleSPARQLQuery::freeModel: ERROR: Can't free default model" << std::endl; 174 std::cerr << "SimpleSPARQLQuery::freeModel: ERROR: Can't free default model" << std::endl;
171 return; 175 return;
172 } 176 }
173 if (m_ownModelUris.find(forUri) == m_ownModelUris.end()) { 177 if (m_ownModelUris.find(forUri) == m_ownModelUris.end()) {
174 std::cerr << "SimpleSPARQLQuery::freeModel: ERROR: Never heard of this model (uri = \"" << forUri.toStdString() << "\")" << std::endl; 178 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
179 std::cerr << "SimpleSPARQLQuery::freeModel: NOTE: Unknown or already-freed model (uri = \"" << forUri.toStdString() << "\")" << std::endl;
180 #endif
175 return; 181 return;
176 } 182 }
177 183
178 librdf_model *model = m_ownModelUris[forUri]; 184 librdf_model *model = m_ownModelUris[forUri];
179 if (model) librdf_free_model(model); 185 if (model) librdf_free_model(model);
406 SimpleSPARQLQuery::Impl::executeFor(QString modelUri) 412 SimpleSPARQLQuery::Impl::executeFor(QString modelUri)
407 { 413 {
408 ResultList list; 414 ResultList list;
409 librdf_query *query; 415 librdf_query *query;
410 416
417 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
411 static std::map<QString, int> counter; 418 static std::map<QString, int> counter;
412 if (counter.find(m_query) == counter.end()) counter[m_query] = 1; 419 if (counter.find(m_query) == counter.end()) counter[m_query] = 1;
413 else ++counter[m_query]; 420 else ++counter[m_query];
414 std::cerr << "Counter for this query: " << counter[m_query] << std::endl; 421 std::cerr << "Counter for this query: " << counter[m_query] << std::endl;
415 std::cerr << "Base URI is: \"" << modelUri.toStdString() << "\"" << std::endl; 422 std::cerr << "Base URI is: \"" << modelUri.toStdString() << "\"" << std::endl;
423 #endif
416 424
417 { 425 {
418 Profiler p("SimpleSPARQLQuery: Prepare LIBRDF query"); 426 Profiler p("SimpleSPARQLQuery: Prepare LIBRDF query");
419 query = librdf_new_query 427 query = librdf_new_query
420 (m_redland.getWorld(), "sparql", NULL, 428 (m_redland.getWorld(), "sparql", NULL,