1
0
Fork 0

Merge branch 'aql2' of https://github.com/triAGENS/ArangoDB into aql2

This commit is contained in:
Jan Steemann 2014-07-30 12:30:20 +02:00
commit 376ae9b8dc
8 changed files with 413 additions and 24 deletions

View File

@ -148,6 +148,31 @@ Json EnumerateCollectionPlan::toJson (TRI_memory_zone_t* zone) const {
return json;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of EnumerateListPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for EnumerateListPlan
////////////////////////////////////////////////////////////////////////////////
Json EnumerateListPlan::toJson (TRI_memory_zone_t* zone) const {
Json json(ExecutionPlan::toJson(zone)); // call base class method
if (json.isEmpty()) {
return json;
}
try {
json("varNumber", Json(static_cast<double>(_varNumber)))
("varName", Json(_varName));
}
catch (std::exception& e) {
return Json();
}
// And return it:
return json;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of LimitPlan
// -----------------------------------------------------------------------------
@ -200,6 +225,38 @@ Json CalculationPlan::toJson (TRI_memory_zone_t* zone) const {
return json;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of ProjectionPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for ProjectionPlan
////////////////////////////////////////////////////////////////////////////////
Json ProjectionPlan::toJson (TRI_memory_zone_t* zone) const {
Json json(ExecutionPlan::toJson(zone)); // call base class method
if (json.isEmpty()) {
return json;
}
try {
Json vec(Json::List,_keepAttributes.size());
for (auto it = _keepAttributes.begin(); it != _keepAttributes.end(); ++it) {
vec(Json(*it));
}
json("inVarNumber", Json(static_cast<double>(_inVar)))
("inVarName", Json(_inVarName))
("outVarNumber", Json(static_cast<double>(_outVar)))
("outVarName", Json(_outVarName))
("keepAttributes", vec);
}
catch (std::exception& e) {
return Json();
}
// And return it:
return json;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of FilterPlan
// -----------------------------------------------------------------------------
@ -215,8 +272,38 @@ Json FilterPlan::toJson (TRI_memory_zone_t* zone) const {
}
// Now put info about offset and limit in
try {
json("attribute", Json(_attribute))
("value", Json(_value.copy()));
json("varName", Json(_varName))
("varNumber", Json(static_cast<double>(_varNumber)));
}
catch (std::exception& e) {
return Json();
}
// And return it:
return json;
}
// -----------------------------------------------------------------------------
// --SECTION-- methods of SortPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief toJson, for SortPlan
////////////////////////////////////////////////////////////////////////////////
Json SortPlan::toJson (TRI_memory_zone_t* zone) const {
Json json(ExecutionPlan::toJson(zone)); // call base class method
if (json.isEmpty()) {
return json;
}
try {
Json vec(Json::List,_sortAttributes.size());
for (auto it = _sortAttributes.begin(); it != _sortAttributes.end(); ++it) {
vec(Json(*it));
}
json("varNumber", Json(static_cast<double>(_varNumber)))
("varName", Json(_varName))
("sortAttributes", vec);
}
catch (std::exception& e) {
return Json();

View File

@ -35,6 +35,7 @@
#include <VocBase/voc-types.h>
#include <VocBase/vocbase.h>
#include "Aql/Variable.h"
#include "Aql/Types.h"
namespace triagens {
@ -59,15 +60,15 @@ namespace triagens {
SINGLETON, // done
ENUMERATE_COLLECTION, // done
INDEX_RANGE,
STATIC_LIST, // 4.
ENUMERATE_LIST, // done
FILTER, // done
LIMIT, // done
INTERSECTION,
PROJECTION, // 1.
PROJECTION, // done
CALCULATION, // done
SORT, // 3.
SORT, // done
AGGREGATE_ON_SORTED,
AGGREGATE_ON_UNSORTED, // 2.
AGGREGATE_ON_UNSORTED, // todo
LOOKUP_JOIN,
MERGE_JOIN,
LOOKUP_INDEX_UNIQUE,
@ -354,6 +355,80 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class EnumerateListPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class EnumerateListPlan, derived from ExecutionPlan
////////////////////////////////////////////////////////////////////////////////
class EnumerateListPlan : public ExecutionPlan {
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
public:
EnumerateListPlan (VariableId varNumber, std::string varName)
: ExecutionPlan(), _varNumber(varNumber), _varName(varName) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node
////////////////////////////////////////////////////////////////////////////////
virtual NodeType getType () const {
return ENUMERATE_LIST;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node as a string
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("EnumerateListPlan");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual triagens::basics::Json toJson (
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new EnumerateListPlan(_varNumber, _varName);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief private data
////////////////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief _varNumber, input variable
////////////////////////////////////////////////////////////////////////////////
VariableId _varNumber;
////////////////////////////////////////////////////////////////////////////////
/// @brief _varName, name of variable to read from
////////////////////////////////////////////////////////////////////////////////
std::string _varName;
};
// -----------------------------------------------------------------------------
// --SECTION-- class LimitPlan
// -----------------------------------------------------------------------------
@ -422,6 +497,104 @@ namespace triagens {
};
// -----------------------------------------------------------------------------
// --SECTION-- class ProjectionPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class ProjectionPlan, derived from ExecutionPlan
////////////////////////////////////////////////////////////////////////////////
class ProjectionPlan : public ExecutionPlan {
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
public:
ProjectionPlan (VariableId inVar,
std::string inVarName,
VariableId outVar,
std::string outVarName,
std::vector<std::string> keepAttributes)
: ExecutionPlan(), _inVar(inVar), _inVarName(inVarName),
_outVar(outVar), _outVarName(outVarName),
_keepAttributes(keepAttributes) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node
////////////////////////////////////////////////////////////////////////////////
virtual NodeType getType () const {
return PROJECTION;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node as a string
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("ProjectionPlan");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual triagens::basics::Json toJson (
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new ProjectionPlan(_inVar, _inVarName, _outVar, _outVarName,
_keepAttributes);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief private data
////////////////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief input variable
////////////////////////////////////////////////////////////////////////////////
VariableId _inVar;
////////////////////////////////////////////////////////////////////////////////
/// @brief _inVarName, name of variable to read from
////////////////////////////////////////////////////////////////////////////////
std::string _inVarName;
////////////////////////////////////////////////////////////////////////////////
/// @brief output variable
////////////////////////////////////////////////////////////////////////////////
VariableId _outVar;
////////////////////////////////////////////////////////////////////////////////
/// @brief _outVarName, name of variable to write to
////////////////////////////////////////////////////////////////////////////////
std::string _outVarName;
////////////////////////////////////////////////////////////////////////////////
/// @brief vector of attributes to leave in the object
////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> _keepAttributes;
};
// -----------------------------------------------------------------------------
// --SECTION-- class CalculationPlan
// -----------------------------------------------------------------------------
@ -438,7 +611,7 @@ namespace triagens {
public:
CalculationPlan (AqlExpression* expr, uint32_t varNumber,
CalculationPlan (AqlExpression* expr, VariableId varNumber,
std::string varName)
: ExecutionPlan(), _expression(expr), _varNumber(varNumber),
_varName(varName) {
@ -493,7 +666,7 @@ namespace triagens {
/// @brief _varNumber, global number of variable to write to
////////////////////////////////////////////////////////////////////////////////
uint32_t _varNumber;
VariableId _varNumber;
////////////////////////////////////////////////////////////////////////////////
/// @brief _varName, name of variable to write to
@ -519,8 +692,8 @@ namespace triagens {
public:
FilterPlan (std::string attribute, triagens::basics::Json value)
: ExecutionPlan(), _attribute(attribute), _value(value) {
FilterPlan (VariableId varNumber, std::string varName)
: ExecutionPlan(), _varNumber(varNumber), _varName(varName) {
}
////////////////////////////////////////////////////////////////////////////////
@ -551,7 +724,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new FilterPlan(_attribute, _value.copy());
auto c = new FilterPlan(_varNumber, _varName);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
}
@ -562,8 +735,99 @@ namespace triagens {
private:
std::string _attribute;
triagens::basics::Json _value;
////////////////////////////////////////////////////////////////////////////////
/// @brief _varNumber, input variable
////////////////////////////////////////////////////////////////////////////////
VariableId _varNumber;
////////////////////////////////////////////////////////////////////////////////
/// @brief _varName, name of variable to read from
////////////////////////////////////////////////////////////////////////////////
std::string _varName;
};
// -----------------------------------------------------------------------------
// --SECTION-- class SortPlan
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief class SortPlan, derived from ExecutionPlan
////////////////////////////////////////////////////////////////////////////////
class SortPlan : public ExecutionPlan {
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
public:
SortPlan (VariableId varNumber,
std::string varName,
std::vector<std::string> sortAttributes)
: ExecutionPlan(), _varNumber(varNumber), _varName(varName),
_sortAttributes(sortAttributes) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node
////////////////////////////////////////////////////////////////////////////////
virtual NodeType getType () const {
return SORT;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the type of the node as a string
////////////////////////////////////////////////////////////////////////////////
virtual std::string getTypeString () const {
return std::string("SortPlan");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief export to JSON
////////////////////////////////////////////////////////////////////////////////
virtual triagens::basics::Json toJson (
TRI_memory_zone_t* zone = TRI_UNKNOWN_MEM_ZONE) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief clone execution plan recursively
////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const {
auto c = new SortPlan(_varNumber, _varName, _sortAttributes);
cloneDependencies(c);
return static_cast<ExecutionPlan*>(c);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief private data
////////////////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief _varNumber, input variable
////////////////////////////////////////////////////////////////////////////////
VariableId _varNumber;
////////////////////////////////////////////////////////////////////////////////
/// @brief _varName, name of variable to read from
////////////////////////////////////////////////////////////////////////////////
std::string _varName;
////////////////////////////////////////////////////////////////////////////////
/// @brief vector of attributes to sort by
////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> _sortAttributes;
};

View File

@ -240,7 +240,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
triagens::basics::Json toJson (TRI_memory_zone_t* zone) const {
return triagens::basics::Json("hier wird ein Ausdruck stehen");
return triagens::basics::Json(zone, _ast->toJson(zone));
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -1891,7 +1891,10 @@ var bindVertexCollections = function(self, vertexCollections) {
wrap.remove = function(vertexId, options) {
//delete all edges using the vertex in all graphs
var graphs = getGraphCollection().toArray();
var vertexCollectionName = vertexId.split("/")[0];
var vertexCollectionName = key;
if (vertexId.indexOf("/") === -1) {
vertexId = key + "/" + vertexId;
}
self.__collectionsToLock.push(vertexCollectionName);
graphs.forEach(
function(graph) {

View File

@ -1890,7 +1890,10 @@ var bindVertexCollections = function(self, vertexCollections) {
wrap.remove = function(vertexId, options) {
//delete all edges using the vertex in all graphs
var graphs = getGraphCollection().toArray();
var vertexCollectionName = vertexId.split("/")[0];
var vertexCollectionName = key;
if (vertexId.indexOf("/") === -1) {
vertexId = key + "/" + vertexId;
}
self.__collectionsToLock.push(vertexCollectionName);
graphs.forEach(
function(graph) {

View File

@ -1979,8 +1979,8 @@ function EdgesAndVerticesSuite() {
var myED = "unitTestEdgeCollection4711";
var myVD1 = "unitTestVertexCollection4711";
var myVD2 = "unitTestVertexCollection4712";
try {graph._drop(myGraphName, true)} catch (ignore){}
try {db._drop(myED)} catch (ignore){}
try {graph._drop(myGraphName, true);} catch (ignore){}
try {db._drop(myED);} catch (ignore){}
try {
graph._create(
myGraphName,
@ -2045,9 +2045,24 @@ function EdgesAndVerticesSuite() {
},
test_vC_remove : function () {
var vertex = g[vc1].save({first_name: "Tim"});
var col = g[vc1];
var counter = col.count();
var vertex = col.save({first_name: "Tim"});
assertEqual(col.count(), counter + 1);
var vertexId = vertex._id;
var result = g[vc1].remove(vertexId);
var result = col.remove(vertexId);
assertEqual(col.count(), counter);
assertTrue(result);
},
test_vC_remove_by_key : function () {
var col = g[vc1];
var counter = col.count();
var vertex = col.save({first_name: "Tim"});
assertEqual(col.count(), counter + 1);
var vertexId = vertex._key;
var result = col.remove(vertexId);
assertEqual(col.count(), counter);
assertTrue(result);
},
@ -2143,6 +2158,19 @@ function EdgesAndVerticesSuite() {
assertTrue(edge);
},
test_eC_remove_by_key : function () {
var vertex1 = g[vc1].save({first_name: "Tom"});
var vertexId1 = vertex1._id;
var vertex2 = g[vc1].save({first_name: "Tim"});
var vertexId2 = vertex2._id;
var counter = g[ec1].count();
var edge = g[ec1].save(vertexId1, vertexId2, {});
assertEqual(g[ec1].count(), counter + 1);
var edgeId1 = edge._key;
edge = g[ec1].remove(edgeId1);
assertTrue(edge);
assertEqual(g[ec1].count(), counter);
},
test_eC_removeWithEdgesAsVertices : function () {

View File

@ -28,18 +28,18 @@
/// @author Copyright 2011-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "ShellImplFactory.h"
#ifdef _WIN32
#include "LinenoiseShell.h"
#elif TRI_HAVE_LINENOISE
#elif defined TRI_HAVE_LINENOISE
#include "LinenoiseShell.h"
#elif TRI_HAVE_READLINE
#elif defined TRI_HAVE_READLINE
#include "ReadlineShell.h"
#else
#include "DummyShell.h"
#endif
#include "ShellImplFactory.h"
using namespace triagens;
using namespace std;

View File

@ -34,6 +34,10 @@
#include "Basics/Common.h"
namespace triagens {
class ShellImplementation;
class Completer;
class ShellImplFactory {
public: