mirror of https://gitee.com/bigwinds/arangodb
Cluster Communication: serialize a global set of the currently available variables.
This commit is contained in:
parent
d7d6ce65db
commit
dc6dba1ef4
|
@ -475,6 +475,7 @@ std::cout << "REGISTERING QUERY ON COORDINATOR WITH ID: " << id << "\n";
|
||||||
|
|
||||||
result.set("plan", jsonNodesList);
|
result.set("plan", jsonNodesList);
|
||||||
result.set("part", triagens::basics::Json("main")); // TODO: set correct query type
|
result.set("part", triagens::basics::Json("main")); // TODO: set correct query type
|
||||||
|
result.set("variables", query->ast()->variables()->toJson(TRI_UNKNOWN_MEM_ZONE));
|
||||||
|
|
||||||
std::unique_ptr<std::string> body(new std::string(triagens::basics::JsonHelper::toString(result.json())));
|
std::unique_ptr<std::string> body(new std::string(triagens::basics::JsonHelper::toString(result.json())));
|
||||||
|
|
||||||
|
|
|
@ -387,6 +387,7 @@ QueryResult Query::prepare (QueryRegistry* registry) {
|
||||||
enterState(PLAN_INSTANCIATION);
|
enterState(PLAN_INSTANCIATION);
|
||||||
ExecutionPlan::getCollectionsFromJson(parser->ast(), _queryJson);
|
ExecutionPlan::getCollectionsFromJson(parser->ast(), _queryJson);
|
||||||
|
|
||||||
|
parser->ast()->variables()->fromJson(_queryJson);
|
||||||
// creating the plan may have produced some collections
|
// creating the plan may have produced some collections
|
||||||
// we need to add them to the transaction now (otherwise the query will fail)
|
// we need to add them to the transaction now (otherwise the query will fail)
|
||||||
int res = _trx->addCollectionList(_collections.collections());
|
int res = _trx->addCollectionList(_collections.collections());
|
||||||
|
|
|
@ -27,9 +27,11 @@
|
||||||
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "Utils/Exception.h"
|
||||||
#include "Aql/VariableGenerator.h"
|
#include "Aql/VariableGenerator.h"
|
||||||
|
|
||||||
using namespace triagens::aql;
|
using namespace triagens::aql;
|
||||||
|
using Json = triagens::basics::Json;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- constructors / destructors
|
// --SECTION-- constructors / destructors
|
||||||
|
@ -202,6 +204,36 @@ std::string VariableGenerator::nextName () const {
|
||||||
return std::to_string(_id); // to_string: c++11
|
return std::to_string(_id); // to_string: c++11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief export to JSON, returns an AUTOFREE Json object
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
triagens::basics::Json VariableGenerator::toJson (TRI_memory_zone_t* zone) const {
|
||||||
|
Json jsonAllVariablesList(Json::List, _variables.size());
|
||||||
|
for (auto oneVariable: _variables) {
|
||||||
|
jsonAllVariablesList(oneVariable.second->toJson());
|
||||||
|
}
|
||||||
|
return jsonAllVariablesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief import from JSON
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void VariableGenerator::fromJson (Json const& query) {
|
||||||
|
|
||||||
|
Json jsonAllVariablesList = query.get("variables");
|
||||||
|
if (!jsonAllVariablesList.isList()) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "variables needs to be a list");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto len = jsonAllVariablesList.size();
|
||||||
|
_variables.reserve(len);
|
||||||
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
createVariable(jsonAllVariablesList.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -117,6 +117,18 @@ namespace triagens {
|
||||||
|
|
||||||
std::string nextName () const;
|
std::string nextName () const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief export to JSON, returns an AUTOFREE Json object
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
triagens::basics::Json toJson (TRI_memory_zone_t*) const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief import from JSON
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void fromJson (triagens::basics::Json const& jsonAllVariablesList);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- private functions
|
// --SECTION-- private functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue