mirror of https://gitee.com/bigwinds/arangodb
Implement passing of query statistics through cluster.
This commit is contained in:
parent
20383dd4e2
commit
9558f5aa0a
|
@ -4527,6 +4527,9 @@ AqlItemBlock* RemoteBlock::getSome (size_t atLeast,
|
|||
}
|
||||
|
||||
auto items = new triagens::aql::AqlItemBlock(responseBodyJson);
|
||||
|
||||
_engine->_stats.add(ExecutionStats(responseBodyJson.get("stats")));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Aql/ExecutionStats.h"
|
||||
|
||||
#include "Utils/Exception.h"
|
||||
using namespace triagens::aql;
|
||||
using Json = triagens::basics::Json;
|
||||
using JsonHelper = triagens::basics::JsonHelper;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
|
@ -50,6 +51,24 @@ Json ExecutionStats::toJson () const {
|
|||
return json;
|
||||
}
|
||||
|
||||
ExecutionStats::ExecutionStats()
|
||||
:writesExecuted(0),
|
||||
writesIgnored(0),
|
||||
scannedFull(0),
|
||||
scannedIndex(0) {
|
||||
}
|
||||
|
||||
ExecutionStats::ExecutionStats (triagens::basics::Json const& jsonStats) {
|
||||
if (!jsonStats.isArray()) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "stats is not an Array");
|
||||
}
|
||||
std::cout << jsonStats.toString() << "\n";
|
||||
writesExecuted = JsonHelper::checkAndGetNumericValue<int>(jsonStats.json(), "writesExecuted");
|
||||
writesIgnored = JsonHelper::checkAndGetNumericValue<int>(jsonStats.json(), "writesIgnored");
|
||||
scannedFull = JsonHelper::checkAndGetNumericValue<int>(jsonStats.json(), "scannedFull");
|
||||
scannedIndex = JsonHelper::checkAndGetNumericValue<int>(jsonStats.json(), "scannedIndex");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -38,35 +38,50 @@ namespace triagens {
|
|||
|
||||
struct ExecutionStats {
|
||||
|
||||
ExecutionStats ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief instanciate the statistics from JSON
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ExecutionStats (triagens::basics::Json const& jsonStats);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert the statistics to JSON
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::basics::Json toJson () const;
|
||||
|
||||
void add (ExecutionStats const& summand) {
|
||||
writesExecuted += summand.writesExecuted;
|
||||
writesIgnored += summand.writesIgnored;
|
||||
scannedFull += summand.scannedFull;
|
||||
scannedIndex += summand.scannedIndex;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief number of successfully executed write operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64_t writesExecuted = 0;
|
||||
int64_t writesExecuted;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief number of ignored write operations (ignored due to errors)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64_t writesIgnored = 0;
|
||||
int64_t writesIgnored;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief number of documents scanned (full-collection scan)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64_t scannedFull = 0;
|
||||
int64_t scannedFull;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief number of documents scanned (using indexes scan)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int64_t scannedIndex = 0;
|
||||
int64_t scannedIndex;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -840,6 +840,14 @@ void Query::exitContext () {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns statistics for current query.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::basics::Json Query::getStats() {
|
||||
return _engine->_stats.toJson();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief fetch a boolean value from the options
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -379,6 +379,12 @@ namespace triagens {
|
|||
|
||||
void exitContext ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns statistics for current query.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::basics::Json getStats();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -747,6 +747,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
|
|||
else {
|
||||
try {
|
||||
answerBody = items->toJson(query->trx());
|
||||
answerBody.set("stats", query->getStats());
|
||||
// std::cout << "ANSWERBODY: " << JsonHelper::toString(answerBody.json()) << "\n\n";
|
||||
}
|
||||
catch (...) {
|
||||
|
|
Loading…
Reference in New Issue