8000 fix count · aa10000/arangodb@cf04966 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf04966

Browse files
committed
fix count
1 parent 5da6b9b commit cf04966

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

arangod/Utils/Transaction.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,22 +2821,7 @@ OperationResult Transaction::countCoordinator(std::string const& collectionName,
28212821
return OperationResult(res);
28222822
}
28232823

2824-
VPackBuilder resultBuilder;
2825-
if (aggregate) {
2826-
uint64_t result = 0;
2827-
for (auto const& it : count) {
2828-
result += it.second;
2829-
}
2830-
resultBuilder.add(VPackValue(result));
2831-
} else {
2832-
resultBuilder.openObject();
2833-
for (auto const& it : count) {
2834-
resultBuilder.add(it.first, VPackValue(it.second));
2835-
}
2836-
resultBuilder.close();
2837-
}
2838-
2839-
return OperationResult(resultBuilder.steal(), nullptr, "", TRI_ERROR_NO_ERROR, false);
2824+
return buildCountResult(count, aggregate);
28402825
}
28412826
#endif
28422827

@@ -3611,6 +3596,25 @@ int Transaction::resolveId(char const* handle, size_t length,
36113596

36123597
return TRI_ERROR_NO_ERROR;
36133598
}
3599+
3600+
OperationResult Transaction::buildCountResult(std::vector<std::pair<std::string, uint64_t>> const& count, bool aggregate) {
3601+
VPackBuilder resultBuilder;
3602+
3603+
if (aggregate) {
3604+
uint64_t result = 0;
3605+
for (auto const& it : count) {
3606+
result += it.second;
3607+
}
3608+
resultBuilder.add(VPackValue(result));
3609+
} else {
3610+
resultBuilder.openObject();
3611+
for (auto const& it : count) {
3612+
resultBuilder.add(it.first, VPackValue(it.second));
3613+
}
3614+
resultBuilder.close();
3615+
}
3616+
return OperationResult(resultBuilder.steal(), nullptr, "", TRI_ERROR_NO_ERROR, false);
3617+
}
36143618

36153619
//////////////////////////////////////////////////////////////////////////////
36163620
/// @brief constructor, leases a StringBuffer

arangod/Utils/Transaction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ class Transaction {
754754

755755
protected:
756756

757+
static OperationResult buildCountResult(std::vector<std::pair<std::string, uint64_t>> const& count, bool aggregate);
758+
757759
//////////////////////////////////////////////////////////////////////////////
758760
/// @brief return the transaction collection for a document collection
759761
//////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
0