1
0
Fork 0

some cleanup

This commit is contained in:
Jan Steemann 2015-01-18 16:41:48 +01:00
parent 958ae69479
commit 1003e52cf7
5 changed files with 56 additions and 47 deletions

View File

@ -1245,10 +1245,23 @@ bool IndexRangeBlock::initRanges () {
return false;
}
// sort the conditions!
sortConditions();
_posInRanges = 0;
// TODO this should also be done for hash indexes when
// they are lazy too, but only if they should be used to produce a sorted result
getSkiplistIterator(_condition->at(_sortCoords[_posInRanges]));
return (_skiplistIterator != nullptr);
}
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unexpected index type");
LEAVE_BLOCK;
}
////////////////////////////////////////////////////////////////////////////////
// @brief: sorts the index range conditions and resets _posInRanges to 0
////////////////////////////////////////////////////////////////////////////////
void IndexRangeBlock::sortConditions () {
auto en = static_cast<IndexRangeNode const*>(getPlanNode());
size_t const n = _condition->size();
// first sort by the prefix of the index
@ -1282,14 +1295,8 @@ bool IndexRangeBlock::initRanges () {
// then sort by the values of the bounds
std::sort(_sortCoords.begin(), _sortCoords.end(), sortFunc);
_posInRanges = 0;
getSkiplistIterator(_condition->at(_sortCoords[_posInRanges]));
return (_skiplistIterator != nullptr);
}
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unexpected index type");
LEAVE_BLOCK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -569,12 +569,6 @@ namespace triagens {
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief free all dynamic bounds expressions
////////////////////////////////////////////////////////////////////////////////
void freeDynamicBoundsExpressions ();
////////////////////////////////////////////////////////////////////////////////
/// @brief free _condition if it belongs to us
////////////////////////////////////////////////////////////////////////////////
@ -642,6 +636,12 @@ namespace triagens {
void readSkiplistIndex (size_t atMost);
////////////////////////////////////////////////////////////////////////////////
// @brief: sorts the index range conditions and resets _posInRanges to 0
////////////////////////////////////////////////////////////////////////////////
void sortConditions ();
////////////////////////////////////////////////////////////////////////////////
/// @brief andCombineRangeInfoVecs: combine the arguments into a single vector,
/// by intersecting every pair of range infos and inserting them in the returned

View File

@ -1383,7 +1383,7 @@ IndexRangeNode::IndexRangeNode (ExecutionPlan* plan,
}
}
ExecutionNode::IndexMatch IndexRangeNode::MatchesIndex (IndexMatchVec const& pattern) const {
ExecutionNode::IndexMatch IndexRangeNode::matchesIndex (IndexMatchVec const& pattern) const {
return CompareIndex(_index, pattern);
}

View File

@ -1202,7 +1202,7 @@ namespace triagens {
/// @brief check whether the pattern matches this node's index
////////////////////////////////////////////////////////////////////////////////
IndexMatch MatchesIndex (IndexMatchVec const& pattern) const;
IndexMatch matchesIndex (IndexMatchVec const& pattern) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not a reverse index traversal is used

View File

@ -2072,7 +2072,9 @@ public:
return std::make_pair(v, rangeInfo); // for now, no mixed support.
}
}
// Collect the right data for the sorting:
v.reserve(_sortNodeData.size());
for (size_t j = 0; j < _sortNodeData.size(); j ++) {
v.push_back(std::make_pair(_sortNodeData[j]->attributevec,
_sortNodeData[j]->ASC));
@ -2105,7 +2107,6 @@ class SortToIndexNode : public WalkerWorker<ExecutionNode> {
Optimizer::RuleLevel _level;
bool _modified;
public:
SortToIndexNode (ExecutionPlan* plan,
@ -2168,7 +2169,8 @@ class SortToIndexNode : public WalkerWorker<ExecutionNode> {
auto variableName = node->getVariablesSetHere()[0]->name;
auto result = _sortNode->getAttrsForVariableName(variableName);
auto const& match = node->MatchesIndex(result.first);
auto const& match = node->matchesIndex(result.first);
if (match.doesMatch) {
if (match.reverse) {
node->reverse(true);