void RoxieSimpleInputRowArray::kill() { if (rows) { for (rowidx_t i = firstRow; i < numRows; i++) ReleaseRoxieRow(rows[i]); firstRow = 0; numRows = 0; ReleaseRoxieRow(rows); rows = NULL; } }
void RoxieOutputRowArray::kill() { clearRows(); maxRows = 0; ReleaseRoxieRow(rows); rows = NULL; }
void OwnedRowArray::clearPart(aindex_t from, aindex_t to) { aindex_t idx; for(idx = from; idx < to; idx++) ReleaseRoxieRow(buff.item(idx)); buff.removen(from, to-from); }
void RoxieOutputRowArray::clearRows() { for (rowidx_t i = firstRow; i < numRows; i++) ReleaseRoxieRow(rows[i]); firstRow = 0; numRows = 0; commitRows = 0; }
bool DynamicRoxieOutputRowArray::ensure(rowidx_t requiredRows) { unsigned newSize = maxRows; //This condition must be <= at least 1/scaling factor below otherwise you'll get an infinite loop. if (newSize <= 4) newSize = requiredRows; else { //What algorithm should we use to increase the size? Trading memory usage against copying row pointers. // adding 50% would reduce the number of allocations. // anything below 32% would mean that blocks n,n+1 when freed have enough space for block n+3 which might // reduce fragmentation. //Use 25% for the moment. It should possibly be configurable - e.g., higher for thor global sort. while (newSize < requiredRows) newSize += newSize/4; } const void * * newRows; try { newRows = static_cast<const void * *>(rowManager->allocate(newSize * sizeof(void*), RowArrayActivityId)); if (!newRows) return false; } catch (IException * e) { //Pahological cases - not enough memory to reallocate the target row buffer, or no contiguous pages available. unsigned code = e->errorCode(); if ((code == ROXIE_MEMORY_LIMIT_EXCEEDED) || (code == ROXIE_MEMORY_POOL_EXHAUSTED)) { e->Release(); return false; } throw; } //Only the writer is allowed to reallocate rows (otherwise append can't be optimized), so rows is valid outside the lock const void * * oldRows = rows; { RoxieOutputRowArrayLock block(*this); oldRows = rows; memcpy(newRows, oldRows+firstRow, (numRows - firstRow) * sizeof(void*)); numRows -= firstRow; commitRows -= firstRow; firstRow = 0; rows = newRows; maxRows = RoxieRowCapacity(newRows) / sizeof(void *); } ReleaseRoxieRow(oldRows); return true; }
void RoxieRowBlock::operator delete (void * ptr) { ReleaseRoxieRow(ptr); }
void RoxieRowBlock::releaseRows() { while (readPos < writePos) ReleaseRoxieRow(rows[readPos++]); }
virtual void releaseRow(const void * row) { ReleaseRoxieRow(row); }
void CRHRollingCacheElem::set(const void *_row) { if (row) ReleaseRoxieRow(row); row = _row; }
CRHRollingCacheElem::~CRHRollingCacheElem() { if (row) ReleaseRoxieRow(row); }
void OwnedRowArray::replace(const void * row, aindex_t pos) { ReleaseRoxieRow(buff.item(pos)); buff.replace(row, pos); }
//OwnedRowArray void OwnedRowArray::clear() { ForEachItemIn(idx, buff) ReleaseRoxieRow(buff.item(idx)); buff.kill(); }