1
0
Fork 0
This commit is contained in:
jsteemann 2015-10-15 01:32:25 +02:00
parent c38445aa64
commit f5f61ea173
5 changed files with 33 additions and 32 deletions

View File

@ -107,9 +107,6 @@ bool ConditionFinder::before (ExecutionNode* en) {
break;
}
auto const& varsValid = node->getVarsValid();
std::unordered_set<Variable const*> varsUsed;
std::unique_ptr<Condition> condition(new Condition(_plan->getAst()));
for (auto& it : _variableDefinitions) {
@ -122,6 +119,8 @@ bool ConditionFinder::before (ExecutionNode* en) {
// normalize the condition
condition->normalize(_plan);
auto const& varsValid = node->getVarsValid();
// remove all invalid variables from the condition
if (condition->removeInvalidVariables(varsValid)) {
// removing left a previously non-empty OR block empty...

View File

@ -43,6 +43,10 @@ using Json = triagens::basics::Json;
EnumerateListBlock::EnumerateListBlock (ExecutionEngine* engine,
EnumerateListNode const* en)
: ExecutionBlock(engine, en),
_index(0),
_thisBlock(0),
_seen(0),
_collection(nullptr),
_inVarRegId(ExecutionNode::MaxRegisterId) {
auto it = en->getRegisterPlan()->varInfo.find(en->_inVariable->id);
@ -75,9 +79,9 @@ int EnumerateListBlock::initializeCursor (AqlItemBlock* items, size_t pos) {
// handle local data (if any)
_index = 0; // index in _inVariable for next run
_thisblock = 0; // the current block in the _inVariable DOCVEC
_thisBlock = 0; // the current block in the _inVariable DOCVEC
_seen = 0; // the sum of the sizes of the blocks in the _inVariable
// DOCVEC that preceed _thisblock
// DOCVEC that preceed _thisBlock
return TRI_ERROR_NO_ERROR;
}
@ -130,14 +134,13 @@ AqlItemBlock* EnumerateListBlock::getSome (size_t, size_t atMost) {
case AqlValue::DOCVEC: {
if (_index == 0) { // this is a (maybe) new DOCVEC
_DOCVECsize = 0;
_docVecSize = 0;
// we require the total number of items
for (size_t i = 0; i < inVarReg._vector->size(); i++) {
_DOCVECsize += inVarReg._vector->at(i)->size();
_docVecSize += inVarReg._vector->at(i)->size();
}
}
sizeInVar = _DOCVECsize;
sizeInVar = _docVecSize;
if (sizeInVar > 0) {
_collection = inVarReg._vector->at(0)->getDocumentCollection(0);
}
@ -196,7 +199,7 @@ AqlItemBlock* EnumerateListBlock::getSome (size_t, size_t atMost) {
if (_index == sizeInVar) {
_index = 0;
_thisblock = 0;
_thisBlock = 0;
_seen = 0;
// advance read position in the current block . . .
if (++_pos == cur->size()) {
@ -214,7 +217,6 @@ AqlItemBlock* EnumerateListBlock::getSome (size_t, size_t atMost) {
}
size_t EnumerateListBlock::skipSome (size_t atLeast, size_t atMost) {
if (_done) {
return 0;
}
@ -255,13 +257,16 @@ size_t EnumerateListBlock::skipSome (size_t atLeast, size_t atMost) {
case AqlValue::DOCVEC: {
if (_index == 0) { // this is a (maybe) new DOCVEC
_DOCVECsize = 0;
_docVecSize = 0;
// we require the total number of items
for (size_t i = 0; i < inVarReg._vector->size(); i++) {
_DOCVECsize += inVarReg._vector->at(i)->size();
_docVecSize += inVarReg._vector->at(i)->size();
}
}
sizeInVar = _DOCVECsize;
sizeInVar = _docVecSize;
if (sizeInVar > 0) {
_collection = inVarReg._vector->at(0)->getDocumentCollection(0);
}
break;
}
@ -280,7 +285,7 @@ size_t EnumerateListBlock::skipSome (size_t atLeast, size_t atMost) {
// eat the whole of the current inVariable and proceed . . .
skipped += (sizeInVar - _index);
_index = 0;
_thisblock = 0;
_thisBlock = 0;
_seen = 0;
delete cur;
_buffer.pop_front();
@ -310,11 +315,11 @@ AqlValue EnumerateListBlock::getAqlValue (AqlValue const& inVarReg) {
return AqlValue(new Json(static_cast<double>(inVarReg._range->at(_index++))));
}
case AqlValue::DOCVEC: { // incoming doc vec has a single column
AqlValue out = inVarReg._vector->at(_thisblock)->getValue(_index -
_seen, 0).clone();
if (++_index == (inVarReg._vector->at(_thisblock)->size() + _seen)) {
_seen += inVarReg._vector->at(_thisblock)->size();
_thisblock++;
auto& block = inVarReg._vector->at(_thisBlock);
AqlValue out = block->getValue(_index - _seen, 0).clone();
if (++_index == block->size() + _seen) {
_seen += block->size();
_thisBlock++;
}
return out;
}

View File

@ -108,7 +108,7 @@ namespace triagens {
/// @brief current block in DOCVEC
////////////////////////////////////////////////////////////////////////////////
size_t _thisblock;
size_t _thisBlock;
////////////////////////////////////////////////////////////////////////////////
/// @brief number of elements in DOCVEC before the current block
@ -120,7 +120,7 @@ namespace triagens {
/// @brief total number of elements in DOCVEC
////////////////////////////////////////////////////////////////////////////////
size_t _DOCVECsize;
size_t _docVecSize;
////////////////////////////////////////////////////////////////////////////////
/// @brief document collection from DOCVEC

View File

@ -223,8 +223,8 @@ static inline uint32_t TRI_64to32 (uint64_t x) {
#define TRI_FAKE_SPIN_LOCKS 1
#ifndef TRI_ASSERT
#define TRI_ASSERT(expr) { if (! (expr)) TRI_PrintBacktrace(); assert(expr); }
#define TRI_ASSERT_EXPENSIVE(expr) { if (! (expr)) TRI_PrintBacktrace(); assert(expr); }
#define TRI_ASSERT(expr) { if (! (expr)) { TRI_PrintBacktrace(); assert(expr); } }
#define TRI_ASSERT_EXPENSIVE(expr) { if (! (expr)) { TRI_PrintBacktrace(); assert(expr); } }
#endif
@ -234,8 +234,9 @@ static inline uint32_t TRI_64to32 (uint64_t x) {
#undef TRI_FAKE_SPIN_LOCKS
#ifndef TRI_ASSERT
#define TRI_ASSERT(expr) (static_cast<void>(0))
#define TRI_ASSERT_EXPENSIVE(expr) (static_cast<void>(0))
#define TRI_ASSERT(expr) do { (void) 0; } while (0)
#define TRI_ASSERT_EXPENSIVE(expr) do { (void) 0; } while (0)
#endif
#endif

View File

@ -173,7 +173,7 @@ namespace RandomHelper {
// ..............................................................................
{
#ifdef _WIN32
abort();
std::abort();
#else
long flags = fcntl(fd, F_GETFL, 0);
bool ok = (flags >= 0);
@ -190,16 +190,12 @@ namespace RandomHelper {
fillBuffer();
}
~RandomDeviceCombined () {
if (fd >= 0) {
TRI_CLOSE(fd);
}
}
uint32_t random () {
if (pos >= N) {
fillBuffer();