|
@@ -195,7 +195,6 @@ protected:
|
|
|
spillFile.setown(createIFile(tempname.str()));
|
|
|
|
|
|
rows.save(*spillFile, useCompression); // saves committed rows
|
|
|
- rows.noteSpilled(numRows);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -365,9 +364,7 @@ public:
|
|
|
if (fetch >= granularity)
|
|
|
fetch = granularity;
|
|
|
// consume 'fetch' rows
|
|
|
- const void **toRead = rows.getBlock(fetch);
|
|
|
- memcpy(readRows, toRead, fetch * sizeof(void *));
|
|
|
- rows.noteSpilled(fetch);
|
|
|
+ rows.readBlock(readRows, fetch);
|
|
|
numReadRows = fetch;
|
|
|
pos = 0;
|
|
|
}
|
|
@@ -1148,6 +1145,7 @@ void CThorSpillableRowArray::clearRows()
|
|
|
|
|
|
void CThorSpillableRowArray::compact()
|
|
|
{
|
|
|
+ CThorArrayLockBlock block(*this);
|
|
|
assertex(0 == firstRow && numRows == commitRows);
|
|
|
CThorExpandingRowArray::compact();
|
|
|
commitRows = numRows;
|
|
@@ -1234,6 +1232,7 @@ rowidx_t CThorSpillableRowArray::save(IFile &iFile, bool useCompression)
|
|
|
rows[i] = NULL;
|
|
|
}
|
|
|
writer->flush();
|
|
|
+ firstRow += n;
|
|
|
offset_t bytesWritten = writer->getPosition();
|
|
|
writer.clear();
|
|
|
ActPrintLog(&activity, "CThorSpillableRowArray::save done, bytes = %"I64F"d", (__int64)bytesWritten);
|
|
@@ -1308,12 +1307,21 @@ void CThorSpillableRowArray::swap(CThorSpillableRowArray &other)
|
|
|
commitRows = otherCommitRows;
|
|
|
}
|
|
|
|
|
|
+void CThorSpillableRowArray::readBlock(const void **outRows, rowidx_t readRows)
|
|
|
+{
|
|
|
+ CThorArrayLockBlock block(*this);
|
|
|
+ dbgassertex(firstRow + readRows <= commitRows);
|
|
|
+ memcpy(outRows, rows + firstRow, readRows*sizeof(void *));
|
|
|
+ firstRow += readRows;
|
|
|
+}
|
|
|
+
|
|
|
void CThorSpillableRowArray::transferRowsCopy(const void **outRows, bool takeOwnership)
|
|
|
{
|
|
|
+ CThorArrayLockBlock block(*this);
|
|
|
if (0 == numRows)
|
|
|
return;
|
|
|
assertex(numRows == commitRows);
|
|
|
- memcpy(outRows, rows, numRows*sizeof(void **));
|
|
|
+ memcpy(outRows, rows, numRows*sizeof(void *));
|
|
|
if (takeOwnership)
|
|
|
firstRow = commitRows = numRows = 0;
|
|
|
else
|
|
@@ -1360,6 +1368,7 @@ protected:
|
|
|
|
|
|
bool spillRows()
|
|
|
{
|
|
|
+ //This must only be called while a lock is held on spillableRows()
|
|
|
rowidx_t numRows = spillableRows.numCommitted();
|
|
|
if (numRows == 0)
|
|
|
return false;
|
|
@@ -1378,7 +1387,6 @@ protected:
|
|
|
Owned<IFile> iFile = createIFile(tempname.str());
|
|
|
spillFiles.append(new CFileOwner(iFile.getLink()));
|
|
|
spillableRows.save(*iFile, activity.getOptBool(THOROPT_COMPRESS_SPILLS, true)); // saves committed rows
|
|
|
- spillableRows.noteSpilled(numRows);
|
|
|
|
|
|
++overflowCount;
|
|
|
|