diff options
author | jasplin <qt-info@nokia.com> | 2010-03-19 14:44:46 +0100 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2010-03-19 14:44:46 +0100 |
commit | 22807b3aaf4f1bb07a088124c50f6d8900a2fb72 (patch) | |
tree | 00c978f4e34b6c0c8008bb3d92cd8a88d8a1c06b /src/bm | |
parent | 849c7453ea6e12a896d56d32f6226397100bb1f3 (diff) |
Moved timestamp from snapshot to result.
This patch moves the timestamp attribute from
the snapshot table to the result table. This
is done for two purposes:
1) Retrieving a pure result history (not including the
SHA-1 values) becomes quicker, since a join is avoided
(simply fetch all (timestamp, value) pairs matching a
given BM context).
2) It constitutes the first of two steps towards supporting
multiple result recordings per (SHA-1, BM context)
combination (the other step will be to remove the current
uniqueness constraint on that combination!).
The (future) use case is to improve statistical confidence
by e.g. taking the median value of the set of values for
a certain (SHA-1, BM context) combination as the representative
value for the combination.
Diffstat (limited to 'src/bm')
-rw-r--r-- | src/bm/bmrequest.cpp | 32 | ||||
-rw-r--r-- | src/bm/bmrequest.h | 6 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/bm/bmrequest.cpp b/src/bm/bmrequest.cpp index 063dd19..da685fd 100644 --- a/src/bm/bmrequest.cpp +++ b/src/bm/bmrequest.cpp @@ -340,15 +340,12 @@ bool BMRequest::getBranchId( } bool BMRequest::getSnapshotId( - QString *reply, int *snapshotId, const QString &sha1, const QString ×tamp, - bool autoInsert) const + QString *reply, int *snapshotId, const QString &sha1, bool autoInsert) const { const QStringList colNames = QStringList() << "sha1"; const QStringList colValues = QStringList() << sha1; return getId( - reply, snapshotId, "snapshot", - colNames, colValues, - colNames + QStringList("timestamp"), colValues + QStringList(timestamp), autoInsert); + reply, snapshotId, "snapshot", colNames, colValues, colNames, colValues, autoInsert); } bool BMRequest::getContextId( @@ -566,7 +563,8 @@ bool BMRequest::getOrInsertBMContextId( } bool BMRequest::insertOrReplaceResult( - QString *reply, const int bmcontextId, const int snapshotId, const qreal value) const + QString *reply, const int bmcontextId, const int snapshotId, const int timestamp, + const qreal value) const { QSqlQuery *query = createQuery(); @@ -593,9 +591,9 @@ bool BMRequest::insertOrReplaceResult( if (!query->exec( QString( "UPDATE result" - " SET value=%1" - " WHERE id=%2;") - .arg(value).arg(id))) { + " SET timestamp=%1, value=%2" + " WHERE id=%3;") + .arg(timestamp).arg(value).arg(id))) { *reply = errorReply(*query, name(), "failed to update result (exec() failed)"); deleteQuery(query, Rollback); return false; @@ -611,9 +609,9 @@ bool BMRequest::insertOrReplaceResult( if (!query->exec( QString( - "INSERT INTO result (bmcontextId, snapshotId, value) " - "VALUES (%1, %2, %3);") - .arg(bmcontextId).arg(snapshotId).arg(value))) { + "INSERT INTO result (bmcontextId, snapshotId, timestamp, value) " + "VALUES (%1, %2, %3, %4);") + .arg(bmcontextId).arg(snapshotId).arg(timestamp).arg(value))) { *reply = errorReply(*query, name(), "failed to insert result (exec() failed)"); deleteQuery(query, Rollback); return false; @@ -1214,7 +1212,9 @@ QByteArray BMRequest_PutResults::toReplyBuffer() host = contextElem.attributeNode("host").value(); gitRepo = contextElem.attributeNode("gitRepo").value(); gitBranch = contextElem.attributeNode("gitBranch").value(); - timestamp = contextElem.attributeNode("timestamp").value(); + bool ok; + const int timestamp_ = contextElem.attributeNode("timestamp").value().toInt(&ok); + Q_ASSERT(ok); sha1 = contextElem.attributeNode("sha1").value(); testCase = contextElem.attributeNode("testCase").value(); @@ -1233,7 +1233,7 @@ QByteArray BMRequest_PutResults::toReplyBuffer() return xmlConvert(reply); int snapshotId; - if (!getSnapshotId(&reply, &snapshotId, sha1, timestamp, true)) + if (!getSnapshotId(&reply, &snapshotId, sha1, true)) return xmlConvert(reply); QMap<QString, int> contextIds; // ### replace with QHash? @@ -1284,8 +1284,8 @@ QByteArray BMRequest_PutResults::toReplyBuffer() if (!getOrInsertBMContextId(&reply, &bmcontextId, contextId, benchmarkId)) return xmlConvert(reply); - // Insert value ... - if (!insertOrReplaceResult(&reply, bmcontextId, snapshotId, value)) + // Insert timestamp and value ... + if (!insertOrReplaceResult(&reply, bmcontextId, snapshotId, timestamp_, value)) return xmlConvert(reply); } } diff --git a/src/bm/bmrequest.h b/src/bm/bmrequest.h index aa5074a..4ce2605 100644 --- a/src/bm/bmrequest.h +++ b/src/bm/bmrequest.h @@ -85,8 +85,7 @@ protected: QString *reply, int *branchId, const QString &gitRepo, const QString &gitBranch, bool autoInsert = false) const; bool getSnapshotId( - QString *reply, int *snapshotId, const QString &sha1, const QString ×tamp, - bool autoInsert = false) const; + QString *reply, int *snapshotId, const QString &sha1, bool autoInsert = false) const; bool getContextId( QString *reply, int *id, const QString &metric, const QString &platform, const QString &host, const QString &gitRepo, const QString &gitBranch) const; @@ -101,7 +100,8 @@ protected: bool getOrInsertBMContextId( QString *reply, int *id, const int contextId, const int benchmarkId) const; bool insertOrReplaceResult( - QString *reply, const int bmcontextId, const int snapshotId, const qreal value) const; + QString *reply, const int bmcontextId, const int snapshotId, const int timestamp, + const qreal value) const; bool getBenchmark( QString *reply, int benchmarkId, QString *testCase, QString *testFunction, QString *dataTag) const; |