mirror of https://gitee.com/bigwinds/arangodb
fix `fullCount` value in some cases in cluster mode (#4722)
This commit is contained in:
parent
f3659947f4
commit
fa83a932ee
|
@ -1,3 +1,9 @@
|
||||||
|
v3.3.5 (XXXX-XX-XX)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
* fix AQL `fullCount` result value in some cluster cases when it was off a bit
|
||||||
|
|
||||||
|
|
||||||
v3.3.4 (2018-02-28)
|
v3.3.4 (2018-02-28)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
using namespace arangodb::aql;
|
using namespace arangodb::aql;
|
||||||
|
|
||||||
/// @brief convert the statistics to VelocyPack
|
/// @brief convert the statistics to VelocyPack
|
||||||
void ExecutionStats::toVelocyPack(VPackBuilder& builder) const {
|
void ExecutionStats::toVelocyPack(VPackBuilder& builder, bool reportFullCount) const {
|
||||||
builder.openObject();
|
builder.openObject();
|
||||||
builder.add("writesExecuted", VPackValue(writesExecuted));
|
builder.add("writesExecuted", VPackValue(writesExecuted));
|
||||||
builder.add("writesIgnored", VPackValue(writesIgnored));
|
builder.add("writesIgnored", VPackValue(writesIgnored));
|
||||||
|
@ -40,9 +40,8 @@ void ExecutionStats::toVelocyPack(VPackBuilder& builder) const {
|
||||||
builder.add("filtered", VPackValue(filtered));
|
builder.add("filtered", VPackValue(filtered));
|
||||||
builder.add("httpRequests", VPackValue(httpRequests));
|
builder.add("httpRequests", VPackValue(httpRequests));
|
||||||
|
|
||||||
if (fullCount > -1) {
|
if (reportFullCount) {
|
||||||
// fullCount is exceptional. it has a default value of -1 and is
|
// fullCount is exceptional, as it may be hidden
|
||||||
// not reported with this value
|
|
||||||
builder.add("fullCount", VPackValue(fullCount));
|
builder.add("fullCount", VPackValue(fullCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ void ExecutionStats::toVelocyPackStatic(VPackBuilder& builder) {
|
||||||
builder.add("scannedIndex", VPackValue(0));
|
builder.add("scannedIndex", VPackValue(0));
|
||||||
builder.add("filtered", VPackValue(0));
|
builder.add("filtered", VPackValue(0));
|
||||||
builder.add("httpRequests", VPackValue(0));
|
builder.add("httpRequests", VPackValue(0));
|
||||||
builder.add("fullCount", VPackValue(-1));
|
builder.add("fullCount", VPackValue(0));
|
||||||
builder.add("executionTime", VPackValue(0.0));
|
builder.add("executionTime", VPackValue(0.0));
|
||||||
builder.close();
|
builder.close();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,7 @@ ExecutionStats::ExecutionStats()
|
||||||
scannedIndex(0),
|
scannedIndex(0),
|
||||||
filtered(0),
|
filtered(0),
|
||||||
httpRequests(0),
|
httpRequests(0),
|
||||||
fullCount(-1),
|
fullCount(0),
|
||||||
executionTime(0.0) {}
|
executionTime(0.0) {}
|
||||||
|
|
||||||
ExecutionStats::ExecutionStats(VPackSlice const& slice)
|
ExecutionStats::ExecutionStats(VPackSlice const& slice)
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct ExecutionStats {
|
||||||
explicit ExecutionStats(arangodb::velocypack::Slice const& slice);
|
explicit ExecutionStats(arangodb::velocypack::Slice const& slice);
|
||||||
|
|
||||||
/// @brief convert the statistics to VelocyPack
|
/// @brief convert the statistics to VelocyPack
|
||||||
void toVelocyPack(arangodb::velocypack::Builder&) const;
|
void toVelocyPack(arangodb::velocypack::Builder&, bool reportFullCount) const;
|
||||||
|
|
||||||
/// @brief create empty statistics for VelocyPack
|
/// @brief create empty statistics for VelocyPack
|
||||||
static void toVelocyPackStatic(arangodb::velocypack::Builder&);
|
static void toVelocyPackStatic(arangodb::velocypack::Builder&);
|
||||||
|
@ -59,7 +59,6 @@ struct ExecutionStats {
|
||||||
filtered += summand.filtered;
|
filtered += summand.filtered;
|
||||||
httpRequests += summand.httpRequests;
|
httpRequests += summand.httpRequests;
|
||||||
if (summand.fullCount > 0) {
|
if (summand.fullCount > 0) {
|
||||||
// fullCount may be negative, don't add it then
|
|
||||||
fullCount += summand.fullCount;
|
fullCount += summand.fullCount;
|
||||||
}
|
}
|
||||||
// intentionally no modification of executionTime
|
// intentionally no modification of executionTime
|
||||||
|
@ -72,7 +71,7 @@ struct ExecutionStats {
|
||||||
scannedIndex = 0;
|
scannedIndex = 0;
|
||||||
filtered = 0;
|
filtered = 0;
|
||||||
httpRequests = 0;
|
httpRequests = 0;
|
||||||
fullCount = -1;
|
fullCount = 0;
|
||||||
executionTime = 0.0;
|
executionTime = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ void Query::exitContext() {
|
||||||
void Query::getStats(VPackBuilder& builder) {
|
void Query::getStats(VPackBuilder& builder) {
|
||||||
if (_engine != nullptr) {
|
if (_engine != nullptr) {
|
||||||
_engine->_stats.setExecutionTime(TRI_microtime() - _startTime);
|
_engine->_stats.setExecutionTime(TRI_microtime() - _startTime);
|
||||||
_engine->_stats.toVelocyPack(builder);
|
_engine->_stats.toVelocyPack(builder, _queryOptions.fullCount);
|
||||||
} else {
|
} else {
|
||||||
ExecutionStats::toVelocyPackStatic(builder);
|
ExecutionStats::toVelocyPackStatic(builder);
|
||||||
}
|
}
|
||||||
|
@ -1285,7 +1285,7 @@ void Query::cleanupPlanAndEngine(int errorCode, VPackBuilder* statsBuilder) {
|
||||||
try {
|
try {
|
||||||
_engine->shutdown(errorCode);
|
_engine->shutdown(errorCode);
|
||||||
if (statsBuilder != nullptr) {
|
if (statsBuilder != nullptr) {
|
||||||
_engine->_stats.toVelocyPack(*statsBuilder);
|
_engine->_stats.toVelocyPack(*statsBuilder, _queryOptions.fullCount);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// shutdown may fail but we must not throw here
|
// shutdown may fail but we must not throw here
|
||||||
|
|
|
@ -192,6 +192,20 @@ function optimizerFullcountTestSuite () {
|
||||||
|
|
||||||
assertEqual(2, result.stats.fullCount);
|
assertEqual(2, result.stats.fullCount);
|
||||||
assertEqual(0, result.json.length);
|
assertEqual(0, result.json.length);
|
||||||
|
},
|
||||||
|
|
||||||
|
testJoin1 : function () {
|
||||||
|
let result = AQL_EXECUTE("FOR doc1 IN UnitTestsCollection LIMIT 1 FOR doc2 IN UnitTestsCollection RETURN 1", null, { fullCount: true });
|
||||||
|
|
||||||
|
assertEqual(3, result.stats.fullCount);
|
||||||
|
assertEqual(3, result.json.length);
|
||||||
|
},
|
||||||
|
|
||||||
|
testJoin2 : function () {
|
||||||
|
let result = AQL_EXECUTE("FOR doc1 IN UnitTestsCollection LIMIT 1 FOR doc2 IN UnitTestsCollection FILTER doc1._id == doc2._id RETURN 1", null, { fullCount: true });
|
||||||
|
|
||||||
|
assertEqual(3, result.stats.fullCount);
|
||||||
|
assertEqual(1, result.json.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue