1
0
Fork 0

stringify conditions

This commit is contained in:
Jan Steemann 2015-09-30 14:35:18 +02:00
parent 6405c82a32
commit 47e1b3ceb8
3 changed files with 34 additions and 3 deletions

View File

@ -311,7 +311,7 @@ namespace triagens {
bool) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief adds a JSON representation of the node to the JSON list specified
/// @brief adds a JSON representation of the node to the JSON array specified
/// in the first argument
////////////////////////////////////////////////////////////////////////////////

View File

@ -34,6 +34,7 @@
#include "Aql/AstNode.h"
#include "Aql/SortCondition.h"
#include "Basics/AttributeNameParser.h"
#include "Basics/JsonHelper.h"
namespace triagens {
namespace aql {
@ -146,6 +147,26 @@ namespace triagens {
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief return the condition root
////////////////////////////////////////////////////////////////////////////////
inline AstNode const* root () const {
return _root;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the condition as a Json object
////////////////////////////////////////////////////////////////////////////////
triagens::basics::Json toJson (TRI_memory_zone_t* zone) const {
if (_root == nullptr) {
return triagens::basics::Json(triagens::basics::Json::Object);
}
return triagens::basics::Json(zone, _root->toJson(zone, false));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief add a sub-condition to the condition
/// the sub-condition will be AND-combined with the existing condition(s)

View File

@ -1504,8 +1504,8 @@ void IndexNode::toJsonHelper (triagens::basics::Json& nodes,
}
// Now put info about vocbase and cid in there
json("database", triagens::basics::Json(_vocbase->_name))
("collection", triagens::basics::Json(_collection->getName()))
json("database", triagens::basics::Json(_vocbase->_name))
("collection", triagens::basics::Json(_collection->getName()))
("outVariable", _outVariable->toJson());
triagens::basics::Json indexes(triagens::basics::Json::Array, _indexes.size());
@ -1515,6 +1515,13 @@ void IndexNode::toJsonHelper (triagens::basics::Json& nodes,
json("indexes", indexes);
if (_condition != nullptr) {
json("condition", _condition->toJson(TRI_UNKNOWN_MEM_ZONE));
}
else {
json("condition", triagens::basics::Json(triagens::basics::Json::Object));
}
// And add it:
nodes(json);
}
@ -1554,12 +1561,15 @@ IndexNode::IndexNode (ExecutionPlan* plan,
TRI_ASSERT(TRI_IsArrayJson(indexes));
size_t length = TRI_LengthArrayJson(indexes);
_indexes.reserve(length);
for (size_t i = 0; i < length; ++i) {
auto iid = JsonHelper::checkAndGetStringValue(TRI_LookupArrayJson(indexes, i), "id");
auto index = _collection->getIndex(iid);
if (index == nullptr) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "index not found");
}
_indexes.emplace_back(index);
}
}