mirror of https://gitee.com/bigwinds/arangodb
The new IndexNode can now serve with a SkiplistIndex when only a sort and no filter is given
This commit is contained in:
parent
dcc34e5312
commit
1c81f89a18
|
@ -179,8 +179,9 @@ namespace triagens {
|
|||
arango::IndexIterator* getIterator (arango::IndexIteratorContext* context,
|
||||
triagens::aql::Ast* ast,
|
||||
triagens::aql::AstNode const* condition,
|
||||
triagens::aql::Variable const* reference) const {
|
||||
return getInternals()->iteratorForCondition(context, ast, condition, reference);
|
||||
triagens::aql::Variable const* reference,
|
||||
bool const reverse) const {
|
||||
return getInternals()->iteratorForCondition(context, ast, condition, reference, reverse);
|
||||
}
|
||||
|
||||
triagens::aql::AstNode* specializeCondition (triagens::aql::AstNode const* node,
|
||||
|
|
|
@ -150,6 +150,10 @@ int IndexBlock::initialize () {
|
|||
};
|
||||
|
||||
auto outVariable = static_cast<IndexNode const*>(getPlanNode())->outVariable();
|
||||
if (_condition == nullptr) {
|
||||
// This Node has no condition. Iterate over the complete index.
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _condition->numMembers(); ++i) {
|
||||
auto andCond = _condition->getMemberUnchecked(i);
|
||||
|
@ -255,14 +259,25 @@ bool IndexBlock::initIndexes () {
|
|||
}
|
||||
|
||||
_currentIndex = 0;
|
||||
auto outVariable = static_cast<IndexNode const*>(getPlanNode())->outVariable();
|
||||
auto ast = static_cast<IndexNode const*>(getPlanNode())->_plan->getAst();
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable);
|
||||
IndexNode const* node = static_cast<IndexNode const*>(getPlanNode());
|
||||
auto outVariable = node->outVariable();
|
||||
auto ast = node->_plan->getAst();
|
||||
if (_condition == nullptr) {
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, nullptr, outVariable, node->_reverse);
|
||||
}
|
||||
else {
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable, node->_reverse);
|
||||
}
|
||||
|
||||
while (_iterator == nullptr) {
|
||||
++_currentIndex;
|
||||
if (_currentIndex < _indexes.size()) {
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable);
|
||||
if (_condition == nullptr) {
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, nullptr, outVariable, node->_reverse);
|
||||
}
|
||||
else {
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable, node->_reverse);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We were not able to initialize any index with this condition
|
||||
|
@ -280,10 +295,11 @@ void IndexBlock::startNextIterator () {
|
|||
|
||||
++_currentIndex;
|
||||
if (_currentIndex < _indexes.size()) {
|
||||
auto outVariable = static_cast<IndexNode const*>(getPlanNode())->outVariable();
|
||||
auto ast = static_cast<IndexNode const*>(getPlanNode())->_plan->getAst();
|
||||
IndexNode const* node = static_cast<IndexNode const*>(getPlanNode());
|
||||
auto outVariable = node->outVariable();
|
||||
auto ast = node->_plan->getAst();
|
||||
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable);
|
||||
_iterator = _indexes[_currentIndex]->getIterator(_context, ast, _condition->getMember(_currentIndex), outVariable, node->_reverse);
|
||||
}
|
||||
/*
|
||||
else {
|
||||
|
|
|
@ -616,7 +616,8 @@ bool EdgeIndex::supportsFilterCondition (triagens::aql::AstNode const* node,
|
|||
IndexIterator* EdgeIndex::iteratorForCondition (IndexIteratorContext* context,
|
||||
triagens::aql::Ast* ast,
|
||||
triagens::aql::AstNode const* node,
|
||||
triagens::aql::Variable const* reference) const {
|
||||
triagens::aql::Variable const* reference,
|
||||
bool const reverse) const {
|
||||
TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND);
|
||||
|
||||
SimpleAttributeEqualityMatcher matcher({
|
||||
|
|
|
@ -181,7 +181,8 @@ namespace triagens {
|
|||
IndexIterator* iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const override;
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const override;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private methods
|
||||
|
|
|
@ -793,7 +793,8 @@ bool HashIndex::supportsFilterCondition (triagens::aql::AstNode const* node,
|
|||
IndexIterator* HashIndex::iteratorForCondition (IndexIteratorContext* context,
|
||||
triagens::aql::Ast* ast,
|
||||
triagens::aql::AstNode const* node,
|
||||
triagens::aql::Variable const* reference) const {
|
||||
triagens::aql::Variable const* reference,
|
||||
bool const reverse) const {
|
||||
TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND);
|
||||
|
||||
SimpleAttributeEqualityMatcher matcher(fields());
|
||||
|
|
|
@ -185,7 +185,8 @@ namespace triagens {
|
|||
IndexIterator* iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const override;
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const override;
|
||||
|
||||
triagens::aql::AstNode* specializeCondition (triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const override;
|
||||
|
|
|
@ -461,7 +461,8 @@ bool Index::supportsSortCondition (triagens::aql::SortCondition const*,
|
|||
IndexIterator* Index::iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const {
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const {
|
||||
// the super class index cannot create an iterator
|
||||
// the derived index classes have to manage this.
|
||||
return nullptr;
|
||||
|
|
|
@ -352,7 +352,8 @@ namespace triagens {
|
|||
virtual IndexIterator* iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const;
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const;
|
||||
|
||||
virtual triagens::aql::AstNode* specializeCondition (triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const;
|
||||
|
|
|
@ -323,7 +323,8 @@ bool PrimaryIndex::supportsFilterCondition (triagens::aql::AstNode const* node,
|
|||
IndexIterator* PrimaryIndex::iteratorForCondition (IndexIteratorContext* context,
|
||||
triagens::aql::Ast* ast,
|
||||
triagens::aql::AstNode const* node,
|
||||
triagens::aql::Variable const* reference) const {
|
||||
triagens::aql::Variable const* reference,
|
||||
bool const reverse) const {
|
||||
TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND);
|
||||
|
||||
SimpleAttributeEqualityMatcher matcher({
|
||||
|
|
|
@ -205,7 +205,8 @@ namespace triagens {
|
|||
IndexIterator* iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const override;
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const override;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private methods
|
||||
|
|
|
@ -31,12 +31,14 @@
|
|||
#include "Aql/AstNode.h"
|
||||
#include "Aql/SortCondition.h"
|
||||
#include "Basics/AttributeNameParser.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/VocShaper.h"
|
||||
|
||||
using namespace triagens::arango;
|
||||
using Json = triagens::basics::Json;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
|
@ -1176,9 +1178,20 @@ bool SkiplistIndex::supportsSortCondition (triagens::aql::SortCondition const* s
|
|||
|
||||
IndexIterator* SkiplistIndex::iteratorForCondition (IndexIteratorContext* context,
|
||||
triagens::aql::Ast* ast,
|
||||
triagens::aql::AstNode const*node,
|
||||
triagens::aql::Variable const* reference) const {
|
||||
triagens::aql::AstNode const* node,
|
||||
triagens::aql::Variable const* reference,
|
||||
bool const reverse) const {
|
||||
// Create the skiplistOperator for the IndexLookup
|
||||
if (node == nullptr) {
|
||||
// We have no condition, we just use sort
|
||||
Json nullArray(Json::Array);
|
||||
nullArray.add(Json(Json::Null));
|
||||
std::unique_ptr<TRI_index_operator_t> unboundOperator(TRI_CreateIndexOperator(TRI_GE_INDEX_OPERATOR, nullptr,
|
||||
nullptr, nullArray.steal(), _shaper, 1));
|
||||
std::vector<TRI_index_operator_t*> searchValues({unboundOperator.get()});
|
||||
unboundOperator.release();
|
||||
return new SkiplistIndexIterator(this, searchValues, reverse);
|
||||
}
|
||||
std::unordered_map<size_t, std::vector<triagens::aql::AstNode const*>> found;
|
||||
size_t unused = 0;
|
||||
matchAttributes(node, reference, found, unused);
|
||||
|
@ -1378,7 +1391,7 @@ IndexIterator* SkiplistIndex::iteratorForCondition (IndexIteratorContext* contex
|
|||
}
|
||||
}
|
||||
|
||||
return new SkiplistIndexIterator(this, searchValues);
|
||||
return new SkiplistIndexIterator(this, searchValues, reverse);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -178,10 +178,11 @@ namespace triagens {
|
|||
public:
|
||||
|
||||
SkiplistIndexIterator (SkiplistIndex const* index,
|
||||
std::vector<TRI_index_operator_t*> op)
|
||||
std::vector<TRI_index_operator_t*> op,
|
||||
bool reverse)
|
||||
: _index(index),
|
||||
_operators(op),
|
||||
_reverse(false),
|
||||
_reverse(reverse),
|
||||
_currentOperator(0),
|
||||
_iterator(nullptr) {
|
||||
}
|
||||
|
@ -310,7 +311,8 @@ namespace triagens {
|
|||
IndexIterator* iteratorForCondition (IndexIteratorContext*,
|
||||
triagens::aql::Ast*,
|
||||
triagens::aql::AstNode const*,
|
||||
triagens::aql::Variable const*) const override;
|
||||
triagens::aql::Variable const*,
|
||||
bool const) const override;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue