SVN commit 1168868 by trueg:
New Virtuoso backend parameter "QueryTimeout" which is exactly what it sounds like:
a maximum time that a query may take. After that time the query is canceled and the
results already gathered are returned.
TODO: signal if this happens to the client knows that there might be more results.
M +1 -1 CMakeLists.txt
M +1 -0 ChangeLog
M +2 -0 backends/virtuoso/Virtuoso.dox
M +14 -1 backends/virtuoso/odbcconnectionpool.cpp
M +6 -2 backends/virtuoso/odbcconnectionpool.h
M +3 -1 backends/virtuoso/odbcconnectionpool_p.h
M +6 -1 backends/virtuoso/virtuosobackend.cpp
--- trunk/kdesupport/soprano/CMakeLists.txt #1168867:1168868
@@ -7,7 +7,7 @@
################## Soprano version ################################
set(CMAKE_SOPRANO_VERSION_MAJOR 2)
set(CMAKE_SOPRANO_VERSION_MINOR 5)
-set(CMAKE_SOPRANO_VERSION_RELEASE 61)
+set(CMAKE_SOPRANO_VERSION_RELEASE 62)
set(CMAKE_SOPRANO_VERSION_STRING "${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}")
--- trunk/kdesupport/soprano/ChangeLog #1168867:1168868
@@ -1,5 +1,6 @@
2.6.0
* Fixed handling of xsd:boolean in SPARQL queries in the Virtuoso backend
+ * Added new parameter for the Virtuoso backend: QueryTimeout allows to set a maximum query exeution time.
2.5.0
* New public qHash method for Statement
--- trunk/kdesupport/soprano/backends/virtuoso/Virtuoso.dox #1168867:1168868
@@ -33,6 +33,8 @@
* - \c forcedstart - A boolean property which when set will result in the backend killing any Virtuoso instance accessing the
* data in the storage dir before starting its own instance. This option is ignored when connecting to an already
* running Virtuoso server.
+ * - \c QueryTimeout - The maximum time any query may take in milliseconds. See
+ * Virtuoso Anytime Queries for details.
*
* The settings above are user settings and have to be provided using Soprano::BackendOptionUser:
*
--- trunk/kdesupport/soprano/backends/virtuoso/odbcconnectionpool.cpp #1168867:1168868
@@ -81,17 +81,30 @@
conn->d->m_env = env;
conn->d->m_hdbc = hdbc;
conn->d->m_pool = this;
+
+ // run the setup commands
+ Q_FOREACH( const QString& command, m_connectionSetupCommands ) {
+ if ( conn->executeCommand( command ) != Error::ErrorNone ) {
+ setError( conn->lastError() );
+ delete conn;
+ return 0;
+ }
+ }
+
return conn;
}
-Soprano::ODBC::ConnectionPool::ConnectionPool( const QString& odbcConnectString, QObject* parent )
+Soprano::ODBC::ConnectionPool::ConnectionPool( const QString& odbcConnectString,
+ const QStringList& connectionSetupCommands,
+ QObject* parent )
: QObject( parent ),
d( new ConnectionPoolPrivate() )
{
qDebug() << Q_FUNC_INFO << odbcConnectString;
d->m_odbcConnectString = odbcConnectString;
+ d->m_connectionSetupCommands = connectionSetupCommands;
}
--- trunk/kdesupport/soprano/backends/virtuoso/odbcconnectionpool.h #1168867:1168868
@@ -1,7 +1,7 @@
/*
* This file is part of Soprano Project
*
- * Copyright (C) 2009 Sebastian Trueg
+ * Copyright (C) 2009-2010 Sebastian Trueg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,6 +26,8 @@
#include "error.h"
+class QStringList;
+
namespace Soprano {
namespace ODBC {
@@ -37,7 +39,9 @@
Q_OBJECT
public:
- ConnectionPool( const QString& odbcConnectString, QObject* parent = 0 );
+ ConnectionPool( const QString& odbcConnectString,
+ const QStringList& connectionSetupCommands,
+ QObject* parent = 0 );
~ConnectionPool();
/**
--- trunk/kdesupport/soprano/backends/virtuoso/odbcconnectionpool_p.h #1168867:1168868
@@ -1,7 +1,7 @@
/*
* This file is part of Soprano Project
*
- * Copyright (C) 2009 Sebastian Trueg
+ * Copyright (C) 2009-2010 Sebastian Trueg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,6 +26,7 @@
#include
#include
+#include
class QThread;
@@ -39,6 +40,7 @@
{
public:
QString m_odbcConnectString;
+ QStringList m_connectionSetupCommands;
QHash m_openConnections;
--- trunk/kdesupport/soprano/backends/virtuoso/virtuosobackend.cpp #1168867:1168868
@@ -55,6 +55,7 @@
QString pwd = valueInSettings( settings, BackendOptionPassword ).toString();
QString path = valueInSettings( settings, BackendOptionStorageDir ).toString();
bool debugMode = valueInSettings( settings, BackendOptionUser, QLatin1String( "debugmode" ) ).toBool();
+ int queryTimeout = valueInSettings( settings, QLatin1String( "QueryTimeout" ), 0 ).toInt();
VirtuosoController* controller = 0;
if ( host.isEmpty() &&
@@ -92,8 +93,12 @@
const QString connectString = QString( "host=%1:%2;uid=%3;pwd=%4;driver=%5" )
.arg( host, QString::number( port ), uid, pwd, odbcDriver );
+ QStringList connectionSetupCommands;
+ if ( queryTimeout > 1000 ) {
+ connectionSetupCommands << QString::fromLatin1( "set result_timeout=%1" ).arg( queryTimeout );
+ }
- ODBC::ConnectionPool* connectionPool = new ODBC::ConnectionPool( connectString );
+ ODBC::ConnectionPool* connectionPool = new ODBC::ConnectionPool( connectString, connectionSetupCommands );
// FIXME: should configuration only be allowed on spawned servers?
if ( ODBC::Connection* conn = connectionPool->connection() ) {