From a5006b7617dc685a087d073933e8910602d25ae0 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 13 Nov 2014 08:37:52 +0000 Subject: [PATCH] hash indexes working. --- arangod/Aql/ExecutionBlock.cpp | 20 +++++++++++--------- arangod/Aql/ExecutionBlock.h | 6 +++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index 6d95066096..5b1ef3d14f 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -850,9 +850,10 @@ IndexRangeBlock::IndexRangeBlock (ExecutionEngine* engine, _collection(en->collection()), _posInDocs(0), _allBoundsConstant(true), - _skiplistIterator(nullptr){ + _skiplistIterator(nullptr), + _condition(&en->_ranges) { - std::vector> const& orRanges = en->_ranges; + std::vector> const& orRanges = en->_ranges;//TODO replace this with _condition TRI_ASSERT(en->_index != nullptr); TRI_ASSERT(orRanges.size() == 1); // OR expressions not yet implemented @@ -944,7 +945,7 @@ int IndexRangeBlock::initialize () { bool IndexRangeBlock::initIndex () { auto en = static_cast(getPlanNode()); - IndexOrCondition const* condition = &en->_ranges; + //IndexOrCondition const* _condition = &en->_ranges; TRI_ASSERT(en->_index != nullptr); @@ -1040,7 +1041,7 @@ bool IndexRangeBlock::initIndex () { newCondition.get()->at(0).push_back(actualRange); } - condition = newCondition.get(); + _condition = newCondition.get(); } /*if (en->_index->type == TRI_IDX_TYPE_PRIMARY_INDEX) { @@ -1051,7 +1052,7 @@ bool IndexRangeBlock::initIndex () { return true; //no initialization here! } if (en->_index->type == TRI_IDX_TYPE_SKIPLIST_INDEX) { - initSkiplistIndex(*condition); + initSkiplistIndex(*_condition); return (_skiplistIterator != nullptr); }/* else if (en->_index->type == TRI_IDX_TYPE_EDGE_INDEX) { @@ -1083,14 +1084,13 @@ bool IndexRangeBlock::readIndex (size_t atMost) { } auto en = static_cast(getPlanNode()); - IndexOrCondition const* condition = &en->_ranges; //TODO remove this line if (en->_index->type == TRI_IDX_TYPE_PRIMARY_INDEX) { // atMost not passed since only equality is supported //readPrimaryIndex(*condition); //TODO correct } else if (en->_index->type == TRI_IDX_TYPE_HASH_INDEX) { - readHashIndex(*condition, atMost); + readHashIndex(*_condition, atMost); } else if (en->_index->type == TRI_IDX_TYPE_SKIPLIST_INDEX) { readSkiplistIndex(atMost); @@ -1210,7 +1210,10 @@ AqlItemBlock* IndexRangeBlock::getSome (size_t atLeast, _pos = 0; } if (! _buffer.empty()) { - initIndex(); + if(! initIndex()) {//FIXME is this right? + _done = true; + return nullptr; + } readIndex(atMost); } // If _buffer is empty, then we will fetch a new block in the next call @@ -1414,7 +1417,6 @@ void IndexRangeBlock::readHashIndex (IndexOrCondition const& ranges, size_t atMo setupSearchValue(); TRI_index_result_t list = TRI_LookupHashIndex(idx, &searchValue); destroySearchValue(); - size_t const n = list._length; _posInHashIndex += n; diff --git a/arangod/Aql/ExecutionBlock.h b/arangod/Aql/ExecutionBlock.h index ade4595194..f644384dbc 100644 --- a/arangod/Aql/ExecutionBlock.h +++ b/arangod/Aql/ExecutionBlock.h @@ -637,7 +637,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// /// @brief _inVars, a vector containing for each expression above /// a vector of Variable*, used to execute the expression -//////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// std::vector> _inVars; @@ -649,8 +649,12 @@ namespace triagens { std::vector> _inRegs; TRI_skiplist_iterator_t* _skiplistIterator; + size_t _posInHashIndex; + // condition for current incoming block + IndexOrCondition const* _condition; + }; // -----------------------------------------------------------------------------