1
0
Fork 0

Peng geht.

This commit is contained in:
Max Neunhoeffer 2014-07-29 15:13:16 +02:00
parent 1de4492bec
commit 7c5245eff9
2 changed files with 16 additions and 10 deletions

View File

@ -181,6 +181,7 @@ namespace triagens {
auto p = reinterpret_cast<SingletonPlan const*>(_exePlan);
AqlItem* res = new AqlItem(p->_nrVars);
_done = true;
return res;
}
@ -222,7 +223,7 @@ namespace triagens {
for (size_t i = 0; i < n; ++i) {
TRI_shaped_json_t shaped;
TRI_EXTRACT_SHAPED_JSON_MARKER(shaped, docs[i]->getDataPtr());
_allDocs.push_back(new Json(TRI_UNKNOWN_MEM_ZONE,
_allDocs.push_back(new Json(shaper->_memoryZone,
TRI_JsonShapedJson(shaper, &shaped)));
}
@ -261,8 +262,11 @@ namespace triagens {
}
}
AqlItem* res = new AqlItem(_input, 1);
res->setValue(0,0,new AqlValue(_allDocs[_pos]));
res->setValue(0,0,new AqlValue( new Json(_allDocs[_pos]->copy())));
if (++_pos >= _allDocs.size()) {
if (--_input->_refCount == 0) {
delete _input;
}
_input = nullptr; // get a new item next time
}
@ -274,7 +278,6 @@ namespace triagens {
vector<Json*> _allDocs;
size_t _pos;
AqlItem* _input;
bool _done;
};
class RootBlock : public ExecutionBlock {

View File

@ -96,10 +96,13 @@ namespace triagens {
return _json->toString();
case DOCVEC:
return "I am a DOCVEC.";
case RANGE:
case RANGE: {
std::stringstream s;
s << "I am a range: " << _range._low << " .. " << _range._high;
return s.str();
}
default:
return std::string("");
}
}
@ -107,12 +110,12 @@ namespace triagens {
struct AqlItem {
AqlItem* _outer;
int32_t _refcount;
int32_t _refCount;
int32_t _nrvars;
AqlValue** _vars;
AqlItem (int nrvars)
: _outer(nullptr), _refcount(1), _nrvars(nrvars) {
: _outer(nullptr), _refCount(1), _nrvars(nrvars) {
if (nrvars > 0) {
_vars = new AqlValue* [nrvars];
}
@ -122,8 +125,8 @@ namespace triagens {
}
AqlItem (AqlItem* outer, int nrvars)
: _outer(outer), _refcount(1), _nrvars(nrvars) {
outer->_refcount++;
: _outer(outer), _refCount(1), _nrvars(nrvars) {
outer->_refCount++;
if (nrvars > 0) {
_vars = new AqlValue* [nrvars];
for (int i = 0; i < nrvars; i++) {
@ -141,8 +144,8 @@ namespace triagens {
~AqlItem () {
if (_outer != nullptr) {
_outer->_refcount--;
if (_outer->_refcount == 0) {
_outer->_refCount--;
if (_outer->_refCount == 0) {
delete _outer;
}
_outer = nullptr;