mirror of https://gitee.com/bigwinds/arangodb
Removed now obsolete function getAllDocumentsOnCoordinator from CLusterMethods
This commit is contained in:
parent
0a11583560
commit
be32214554
|
@ -1567,95 +1567,6 @@ int getFilteredDocumentsOnCoordinator(
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get all documents in a coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getAllDocumentsOnCoordinator(
|
||||
std::string const& dbname, std::string const& collname,
|
||||
std::string const& returnType,
|
||||
arangodb::GeneralResponse::ResponseCode& responseCode,
|
||||
std::string& contentType, std::string& resultBody) {
|
||||
// Set a few variables needed for our work:
|
||||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
ClusterComm* cc = ClusterComm::instance();
|
||||
|
||||
// First determine the collection ID from the name:
|
||||
std::shared_ptr<CollectionInfo> collinfo =
|
||||
ci->getCollection(dbname, collname);
|
||||
if (collinfo->empty()) {
|
||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||
}
|
||||
|
||||
auto shards = collinfo->shardIds();
|
||||
CoordTransactionID coordTransactionID = TRI_NewTickServer();
|
||||
for (auto const& p : *shards) {
|
||||
std::unique_ptr<std::map<std::string, std::string>> headers(
|
||||
new std::map<std::string, std::string>());
|
||||
cc->asyncRequest("", coordTransactionID, "shard:" + p.first,
|
||||
arangodb::GeneralRequest::RequestType::GET,
|
||||
"/_db/" + StringUtils::urlEncode(dbname) +
|
||||
"/_api/document?collection=" + p.first + "&type=" +
|
||||
StringUtils::urlEncode(returnType),
|
||||
std::shared_ptr<std::string const>(), headers, nullptr,
|
||||
3600.0);
|
||||
}
|
||||
// Now listen to the results:
|
||||
int count;
|
||||
responseCode = arangodb::GeneralResponse::ResponseCode::OK;
|
||||
contentType = "application/json; charset=utf-8";
|
||||
|
||||
arangodb::basics::Json result(arangodb::basics::Json::Object);
|
||||
arangodb::basics::Json documents(arangodb::basics::Json::Array);
|
||||
|
||||
for (count = (int)shards->size(); count > 0; count--) {
|
||||
auto res = cc->wait("", coordTransactionID, 0, "", 0.0);
|
||||
|
||||
LOG(TRACE) << "Response status " << res.status;
|
||||
int error = handleGeneralCommErrors(&res);
|
||||
if (error != TRI_ERROR_NO_ERROR) {
|
||||
cc->drop("", coordTransactionID, 0, "");
|
||||
return error;
|
||||
}
|
||||
|
||||
if (res.status == CL_COMM_ERROR || res.status == CL_COMM_DROPPED ||
|
||||
res.answer_code == arangodb::GeneralResponse::ResponseCode::NOT_FOUND) {
|
||||
cc->drop("", coordTransactionID, 0, "");
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
std::unique_ptr<TRI_json_t> shardResult(
|
||||
TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, res.answer->body().c_str()));
|
||||
|
||||
if (shardResult == nullptr || !TRI_IsObjectJson(shardResult.get())) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
auto docs = TRI_LookupObjectJson(shardResult.get(), "documents");
|
||||
|
||||
if (!TRI_IsArrayJson(docs)) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
size_t const n = TRI_LengthArrayJson(docs);
|
||||
documents.reserve(n);
|
||||
|
||||
for (size_t j = 0; j < n; ++j) {
|
||||
auto doc =
|
||||
static_cast<TRI_json_t*>(TRI_AtVector(&docs->_value._objects, j));
|
||||
|
||||
// this will transfer the ownership for the JSON into "documents"
|
||||
documents.transfer(doc);
|
||||
}
|
||||
}
|
||||
|
||||
result("documents", documents);
|
||||
|
||||
resultBody = arangodb::basics::JsonHelper::toString(result.json());
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get all edges on coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -141,16 +141,6 @@ int getFilteredDocumentsOnCoordinator(
|
|||
std::unordered_set<std::string>& documentIds,
|
||||
std::unordered_map<std::string, std::shared_ptr<arangodb::velocypack::Buffer<uint8_t>>>& result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get all documents in a coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getAllDocumentsOnCoordinator(
|
||||
std::string const& dbname, std::string const& collname,
|
||||
std::string const& returnType,
|
||||
arangodb::GeneralResponse::ResponseCode& responseCode,
|
||||
std::string& contentType, std::string& resultBody);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get all edges in a coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue