mirror of https://gitee.com/bigwinds/arangodb
Sort out shardId for ScatterBlock and HTTP API.
This commit is contained in:
parent
a59d1e4448
commit
d021bcf720
|
@ -488,6 +488,13 @@ void RestAqlHandler::getInfoQuery (std::string const& operation,
|
|||
std::string const& idString) {
|
||||
// the GET verb
|
||||
|
||||
bool found;
|
||||
std::string shardId;
|
||||
char const* shardIdCharP = _request->header("shard-id", found);
|
||||
if (found && shardIdCharP != nullptr) {
|
||||
shardId = shardIdCharP;
|
||||
}
|
||||
|
||||
QueryId qId;
|
||||
Query* query = nullptr;
|
||||
if (findQuery(idString, qId, query)) {
|
||||
|
@ -498,33 +505,69 @@ void RestAqlHandler::getInfoQuery (std::string const& operation,
|
|||
|
||||
TRI_ASSERT(query->engine() != nullptr);
|
||||
|
||||
int64_t number;
|
||||
if (operation == "count") {
|
||||
number = query->engine()->count();
|
||||
if (number == -1) {
|
||||
answerBody("count", Json("unknown"));
|
||||
try {
|
||||
int64_t number;
|
||||
if (operation == "count") {
|
||||
number = query->engine()->count();
|
||||
if (number == -1) {
|
||||
answerBody("count", Json("unknown"));
|
||||
}
|
||||
else {
|
||||
answerBody("count", Json(static_cast<double>(number)));
|
||||
}
|
||||
}
|
||||
else if (operation == "remaining") {
|
||||
// FIXME:
|
||||
// Do the !shardId.empty() case once the ScatterBlock has remainingForShard
|
||||
number = query->engine()->remaining();
|
||||
if (number == -1) {
|
||||
answerBody("remaining", Json("unknown"));
|
||||
}
|
||||
else {
|
||||
answerBody("remaining", Json(static_cast<double>(number)));
|
||||
}
|
||||
}
|
||||
else if (operation == "hasMore") {
|
||||
bool hasMore;
|
||||
if (shardId.empty()) {
|
||||
hasMore = query->engine()->hasMore();
|
||||
}
|
||||
else {
|
||||
auto scatter = static_cast<ScatterBlock*>(query->engine()->root());
|
||||
if (scatter->getPlanNode()->getType() != ExecutionNode::SCATTER) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL);
|
||||
}
|
||||
hasMore = scatter->hasMoreForShard(shardId);
|
||||
}
|
||||
|
||||
answerBody("hasMore", Json(hasMore));
|
||||
}
|
||||
else {
|
||||
answerBody("count", Json(static_cast<double>(number)));
|
||||
_queryRegistry->close(_vocbase, qId);
|
||||
generateError(HttpResponse::NOT_FOUND, TRI_ERROR_HTTP_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (operation == "remaining") {
|
||||
number = query->engine()->remaining();
|
||||
if (number == -1) {
|
||||
answerBody("remaining", Json("unknown"));
|
||||
}
|
||||
else {
|
||||
answerBody("remaining", Json(static_cast<double>(number)));
|
||||
}
|
||||
}
|
||||
else if (operation == "hasMore") {
|
||||
bool hasMore = query->engine()->hasMore();
|
||||
answerBody("hasMore", Json(hasMore));
|
||||
}
|
||||
else {
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
_queryRegistry->close(_vocbase, qId);
|
||||
generateError(HttpResponse::NOT_FOUND, TRI_ERROR_HTTP_NOT_FOUND);
|
||||
return;
|
||||
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
ex.code(),
|
||||
ex.message());
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
_queryRegistry->close(_vocbase, qId);
|
||||
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
TRI_ERROR_HTTP_SERVER_ERROR,
|
||||
ex.what());
|
||||
}
|
||||
catch (...) {
|
||||
_queryRegistry->close(_vocbase, qId);
|
||||
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
TRI_ERROR_HTTP_SERVER_ERROR,
|
||||
"an unknown exception occurred");
|
||||
}
|
||||
|
||||
_queryRegistry->close(_vocbase, qId);
|
||||
|
@ -661,7 +704,7 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
|
|||
bool found;
|
||||
std::string shardId;
|
||||
char const* shardIdCharP = _request->header("shard-id", found);
|
||||
if (shardIdCharP != nullptr) {
|
||||
if (found && shardIdCharP != nullptr) {
|
||||
shardId = shardIdCharP;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue