1
0
Fork 0

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

This commit is contained in:
Max Neunhoeffer 2014-08-21 15:49:11 +02:00
commit 5b0874a78a
3 changed files with 83 additions and 39 deletions

View File

@ -427,6 +427,14 @@ namespace triagens {
_varUsageValid = false;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief can the node throw?
////////////////////////////////////////////////////////////////////////////////
virtual bool canThrow () {
return false;
}
// -----------------------------------------------------------------------------
// --SECTION-- protected functions
// -----------------------------------------------------------------------------
@ -646,7 +654,7 @@ namespace triagens {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get indexes with fields <attrs> or nullptr if none exist
/// @brief get vector of indexes with fields <attrs>
////////////////////////////////////////////////////////////////////////////////
vector<TRI_index_t*> getIndexes (vector<std::string> attrs) const {
@ -918,7 +926,8 @@ namespace triagens {
// tighter than right, 0 that they are equal, 1 that right is tighter than
// left. For example, (x<1) is tighter than (x<=1) and (x>1) is tighter
// than (x>=1) . . .
static int CompareRangeInfoBound (RangeInfoBound const* left, RangeInfoBound const* right) {
static int CompareRangeInfoBound (RangeInfoBound const* left,
RangeInfoBound const* right) {
if (left == nullptr) {
return (right == nullptr ? 0 : 1);
}
@ -1074,7 +1083,6 @@ static int CompareRangeInfoBound (RangeInfoBound const* left, RangeInfoBound con
}
~IndexRangeNode () {
delete _ranges;
}
////////////////////////////////////////////////////////////////////////////////
@ -1362,6 +1370,14 @@ static int CompareRangeInfoBound (RangeInfoBound const* left, RangeInfoBound con
return v;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief can the node throw?
////////////////////////////////////////////////////////////////////////////////
bool canThrow () {
return _expression->canThrow();
}
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
@ -1485,6 +1501,15 @@ static int CompareRangeInfoBound (RangeInfoBound const* left, RangeInfoBound con
return v;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief can the node throw?
////////////////////////////////////////////////////////////////////////////////
bool canThrow () {
std::cout << "SubqueryNode method for canThrow is not implemented!\n";
return true;
}
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------

View File

@ -1052,6 +1052,7 @@ ExecutionPlan* ExecutionPlan::clone (){
auto plan = new ExecutionPlan();
try {
plan->_root = _root->clone();
plan->_nextId = _nextId;
CloneNodeAdder adder(plan);
plan->_root->walk(&adder);
plan->findVarUsage();

View File

@ -181,8 +181,6 @@ class CalculationNodeFinder : public WalkerWorker<ExecutionNode> {
if (map != nullptr) {
// check the first components of <map> against indexes of <node> . . .
// FIXME does this need to be done like this? Couldn't we keep track
// earlier?
std::vector<std::string> attrs;
std::vector<RangeInfo*> rangeInfo;
for (auto x : *map){
@ -191,9 +189,26 @@ class CalculationNodeFinder : public WalkerWorker<ExecutionNode> {
}
std::vector<TRI_index_t*> idxs = node->getIndexes(attrs);
//use make one new plan for every index in <idxs> that replaces the
// make one new plan for every index in <idxs> that replaces the
// enumerate collection node with a RangeIndexNode . . .
for (auto idx: idxs) {
bool stop = false;
if (idx->_type == TRI_IDX_TYPE_HASH_INDEX){
// only use a hash index if the corresponding rangeInfos are all
// equalities . . .
for(auto x : rangeInfo){
if (x->_low == nullptr || x->_high == nullptr ||
!TRI_CheckSameValueJson(x->_low->_bound.json(),
x->_high->_bound.json()) || !(x->_low->_include) ||
!(x->_high->_include) ) {
stop = true;
std::cout << "not using hash index . . .\n";
break;
}
}
}
if (!stop) {
std::cout << "FOUND INDEX!\n";
auto newPlan = _plan->clone();
ExecutionNode* newNode = nullptr;
@ -209,12 +224,15 @@ class CalculationNodeFinder : public WalkerWorker<ExecutionNode> {
delete newPlan;
throw;
}
newPlan->replaceNode(newPlan->getNodeById(node->id()), newNode);
std::cout << newPlan->root()->toJson(TRI_UNKNOWN_MEM_ZONE, true).toString() << "\n";
newPlan->replaceNode(newPlan->getNodeById(node->id()), newNode,
newPlan->getNodeById(_prev->id()));
std::cout << newPlan->root()->toJson(TRI_UNKNOWN_MEM_ZONE, false).toString()
<< "\n";
_out.push_back(newPlan);
}
}
}
}
_prev = en;
}