1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Jan Steemann 2014-10-23 16:57:18 +02:00
commit bb47eb93ad
6 changed files with 40 additions and 11 deletions

View File

@ -4602,17 +4602,18 @@ AqlItemBlock* RemoteBlock::getSome (size_t atLeast,
Json responseBodyJson(TRI_UNKNOWN_MEM_ZONE,
TRI_JsonString(TRI_UNKNOWN_MEM_ZONE,
responseBodyBuf.begin()));
if (JsonHelper::getBooleanValue(responseBodyJson.json(), "exhausted", true)) {
return nullptr;
}
auto items = new triagens::aql::AqlItemBlock(responseBodyJson);
ExecutionStats newStats(responseBodyJson.get("stats"));
_engine->_stats.addDelta(_deltaStats, newStats);
_deltaStats = newStats;
if (JsonHelper::getBooleanValue(responseBodyJson.json(), "exhausted", true)) {
return nullptr;
}
auto items = new triagens::aql::AqlItemBlock(responseBodyJson);
return items;
LEAVE_BLOCK
}

View File

@ -51,6 +51,17 @@ Json ExecutionStats::toJson () const {
return json;
}
Json ExecutionStats::toJsonStatic () {
Json json(Json::Array);
json.set("writesExecuted", Json(static_cast<double>(0)));
json.set("writesIgnored", Json(static_cast<double>(0)));
json.set("scannedFull", Json(static_cast<double>(0)));
json.set("scannedIndex", Json(static_cast<double>(0)));
json.set("static", Json(static_cast<double>(0)));
return json;
}
ExecutionStats::ExecutionStats()
:writesExecuted(0),
writesIgnored(0),

View File

@ -52,6 +52,12 @@ namespace triagens {
triagens::basics::Json toJson () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief create empty statistics for JSON
////////////////////////////////////////////////////////////////////////////////
static triagens::basics::Json toJsonStatic ();
////////////////////////////////////////////////////////////////////////////////
/// @brief sumarize two sets of ExecutionStats
////////////////////////////////////////////////////////////////////////////////

View File

@ -864,7 +864,12 @@ void Query::exitContext () {
////////////////////////////////////////////////////////////////////////////////
triagens::basics::Json Query::getStats() {
return _engine->_stats.toJson();
if (_engine) {
return _engine->_stats.toJson();
}
else {
return ExecutionStats::toJsonStatic();
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -717,7 +717,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
shardId = shardIdCharP;
}
Json answerBody(Json::Array, 2);
Json answerBody(Json::Array, 3);
if (operation == "getSome") {
auto atLeast = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
@ -738,7 +738,8 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
}
if (items.get() == nullptr) {
answerBody("exhausted", Json(true))
("error", Json(false));
("error", Json(false))
("stats", query->getStats());
}
else {
try {
@ -781,6 +782,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
}
answerBody("skipped", Json(static_cast<double>(skipped)))
("error", Json(false));
answerBody.set("stats", query->getStats());
}
else if (operation == "skip") {
auto number = JsonHelper::getNumericValue<uint64_t>(queryJson.json(),
@ -801,6 +803,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
answerBody("exhausted", Json(exhausted))
("error", Json(false));
answerBody.set("stats", query->getStats());
}
catch (...) {
LOG_ERROR("skip lead to an exception");
@ -831,6 +834,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
}
answerBody("error", Json(res != TRI_ERROR_NO_ERROR))
("code", Json(static_cast<double>(res)));
answerBody.set("stats", query->getStats());
}
else if (operation == "shutdown") {
int res = TRI_ERROR_INTERNAL;
@ -848,6 +852,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
}
answerBody("error", res == TRI_ERROR_NO_ERROR ? Json(false) : Json(true))
("code", Json(static_cast<double>(res)));
answerBody.set("stats", query->getStats());
}
else {
LOG_ERROR("Unknown operation!");

View File

@ -347,7 +347,6 @@ namespace triagens {
this->_sinceCompactification++;
}
const char * ptr = this->_readBuffer->c_str() + this->_readPosition;
const char * end = this->_readBuffer->end() - 3;
@ -567,8 +566,10 @@ namespace triagens {
}
}
else {
if (this->_readBuffer->c_str() < end) {
this->_readPosition = end - this->_readBuffer->c_str();
size_t l = (this->_readBuffer->end() - this->_readBuffer->c_str());
if (this->_startPosition + 4 <= l) {
this->_readPosition = l - 4;
}
}
}