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; 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 // --SECTION-- methods of LimitPlan
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -200,6 +225,38 @@ Json CalculationPlan::toJson (TRI_memory_zone_t* zone) const {
return json; 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 // --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 // Now put info about offset and limit in
try { try {
json("attribute", Json(_attribute)) json("varName", Json(_varName))
("value", Json(_value.copy())); ("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) { catch (std::exception& e) {
return Json(); return Json();

View File

@ -35,6 +35,7 @@
#include <VocBase/voc-types.h> #include <VocBase/voc-types.h>
#include <VocBase/vocbase.h> #include <VocBase/vocbase.h>
#include "Aql/Variable.h"
#include "Aql/Types.h" #include "Aql/Types.h"
namespace triagens { namespace triagens {
@ -59,15 +60,15 @@ namespace triagens {
SINGLETON, // done SINGLETON, // done
ENUMERATE_COLLECTION, // done ENUMERATE_COLLECTION, // done
INDEX_RANGE, INDEX_RANGE,
STATIC_LIST, // 4. ENUMERATE_LIST, // done
FILTER, // done FILTER, // done
LIMIT, // done LIMIT, // done
INTERSECTION, INTERSECTION,
PROJECTION, // 1. PROJECTION, // done
CALCULATION, // done CALCULATION, // done
SORT, // 3. SORT, // done
AGGREGATE_ON_SORTED, AGGREGATE_ON_SORTED,
AGGREGATE_ON_UNSORTED, // 2. AGGREGATE_ON_UNSORTED, // todo
LOOKUP_JOIN, LOOKUP_JOIN,
MERGE_JOIN, MERGE_JOIN,
LOOKUP_INDEX_UNIQUE, 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 // --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 // --SECTION-- class CalculationPlan
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -438,7 +611,7 @@ namespace triagens {
public: public:
CalculationPlan (AqlExpression* expr, uint32_t varNumber, CalculationPlan (AqlExpression* expr, VariableId varNumber,
std::string varName) std::string varName)
: ExecutionPlan(), _expression(expr), _varNumber(varNumber), : ExecutionPlan(), _expression(expr), _varNumber(varNumber),
_varName(varName) { _varName(varName) {
@ -493,7 +666,7 @@ namespace triagens {
/// @brief _varNumber, global number of variable to write to /// @brief _varNumber, global number of variable to write to
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
uint32_t _varNumber; VariableId _varNumber;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief _varName, name of variable to write to /// @brief _varName, name of variable to write to
@ -519,8 +692,8 @@ namespace triagens {
public: public:
FilterPlan (std::string attribute, triagens::basics::Json value) FilterPlan (VariableId varNumber, std::string varName)
: ExecutionPlan(), _attribute(attribute), _value(value) { : ExecutionPlan(), _varNumber(varNumber), _varName(varName) {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -551,7 +724,7 @@ namespace triagens {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
virtual ExecutionPlan* clone () const { virtual ExecutionPlan* clone () const {
auto c = new FilterPlan(_attribute, _value.copy()); auto c = new FilterPlan(_varNumber, _varName);
cloneDependencies(c); cloneDependencies(c);
return static_cast<ExecutionPlan*>(c); return static_cast<ExecutionPlan*>(c);
} }
@ -562,8 +735,99 @@ namespace triagens {
private: 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 { 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) { wrap.remove = function(vertexId, options) {
//delete all edges using the vertex in all graphs //delete all edges using the vertex in all graphs
var graphs = getGraphCollection().toArray(); var graphs = getGraphCollection().toArray();
var vertexCollectionName = vertexId.split("/")[0]; var vertexCollectionName = key;
if (vertexId.indexOf("/") === -1) {
vertexId = key + "/" + vertexId;
}
self.__collectionsToLock.push(vertexCollectionName); self.__collectionsToLock.push(vertexCollectionName);
graphs.forEach( graphs.forEach(
function(graph) { function(graph) {

View File

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

View File

@ -1979,8 +1979,8 @@ function EdgesAndVerticesSuite() {
var myED = "unitTestEdgeCollection4711"; var myED = "unitTestEdgeCollection4711";
var myVD1 = "unitTestVertexCollection4711"; var myVD1 = "unitTestVertexCollection4711";
var myVD2 = "unitTestVertexCollection4712"; var myVD2 = "unitTestVertexCollection4712";
try {graph._drop(myGraphName, true)} catch (ignore){} try {graph._drop(myGraphName, true);} catch (ignore){}
try {db._drop(myED)} catch (ignore){} try {db._drop(myED);} catch (ignore){}
try { try {
graph._create( graph._create(
myGraphName, myGraphName,
@ -2045,9 +2045,24 @@ function EdgesAndVerticesSuite() {
}, },
test_vC_remove : function () { 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 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); assertTrue(result);
}, },
@ -2143,6 +2158,19 @@ function EdgesAndVerticesSuite() {
assertTrue(edge); 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 () { test_eC_removeWithEdgesAsVertices : function () {

View File

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

View File

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