1
0
Fork 0

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

This commit is contained in:
Willi Goesgens 2014-08-12 17:11:06 +02:00
commit a809b58541
2 changed files with 35 additions and 10 deletions

View File

@ -1085,7 +1085,7 @@ namespace triagens {
// if we get here, then _buffer.front() exists // if we get here, then _buffer.front() exists
AqlItemBlock* cur = _buffer.front(); AqlItemBlock* cur = _buffer.front();
if (atMost > _documents.size() - _posInAllDocs) { if (atMost >= skipped + _documents.size() - _posInAllDocs) {
skipped += _documents.size() - _posInAllDocs; skipped += _documents.size() - _posInAllDocs;
_posInAllDocs = 0; _posInAllDocs = 0;
@ -1101,8 +1101,8 @@ namespace triagens {
} }
} }
else { else {
_posInAllDocs += atMost - skipped;
skipped = atMost; skipped = atMost;
_posInAllDocs += atMost;
} }
} }
return skipped; return skipped;
@ -1183,8 +1183,8 @@ namespace triagens {
// get the inVariable register id . . . // get the inVariable register id . . .
// staticAnalysis has been run, so _varOverview is set up // staticAnalysis has been run, so _varOverview is set up
auto it = _varOverview->varInfo.find(en->_inVariable->id); auto it = _varOverview->varInfo.find(en->_inVariable->id);
if (it == _varOverview->varInfo.end()){ if (it == _varOverview->varInfo.end()){
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "variable not found"); THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "variable not found");
} }
@ -1257,25 +1257,36 @@ namespace triagens {
sizeInVar = inVarReg._json->size(); sizeInVar = inVarReg._json->size();
break; break;
} }
case AqlValue::RANGE: { case AqlValue::RANGE: {
sizeInVar = inVarReg._range->_high - inVarReg._range->_low + 1; sizeInVar = inVarReg._range->size();
break; break;
} }
case AqlValue::DOCVEC: { case AqlValue::DOCVEC: {
if( _index == 0) { // this is a (maybe) new DOCVEC if( _index == 0) { // this is a (maybe) new DOCVEC
_DOCVECsize = 0; _DOCVECsize = 0;
//we require the total number of items //we require the total number of items
for (size_t i = 0; i < inVarReg._vector->size(); i++) { for (size_t i = 0; i < inVarReg._vector->size(); i++) {
_DOCVECsize += inVarReg._vector->at(i)->size(); _DOCVECsize += inVarReg._vector->at(i)->size();
} }
collection = inVarReg._vector->at(0)->getDocumentCollection(0);
} }
sizeInVar = _DOCVECsize; sizeInVar = _DOCVECsize;
if (sizeInVar > 0) {
collection = inVarReg._vector->at(0)->getDocumentCollection(0);
}
break; break;
} }
default: {
case AqlValue::SHAPED: {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"EnumerateListBlock: unexpected type in register"); "EnumerateListBlock: cannot iterate over shaped value");
}
case AqlValue::EMPTY: {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"EnumerateListBlock: cannot iterate over empty value");
} }
} }
@ -1428,10 +1439,15 @@ namespace triagens {
} }
return out; return out;
} }
default: {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unexpected value in variable to iterate over"); case AqlValue::SHAPED:
case AqlValue::EMPTY: {
// error
break;
} }
} }
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unexpected value in variable to iterate over");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -50,6 +50,15 @@ namespace triagens {
_high(high) { _high(high) {
} }
size_t size () const {
if (_low <= _high) {
// e.g. 1..1, 1..10 etc.
return _high - _low + 1;
}
// e.g. 10..1
return _low - _high + 1;
}
int64_t const _low; int64_t const _low;
int64_t const _high; int64_t const _high;
}; };