diff --git a/writeengine/bulk/we_colbufcompressed.cpp b/writeengine/bulk/we_colbufcompressed.cpp index 9abc0038a..43534dc75 100644 --- a/writeengine/bulk/we_colbufcompressed.cpp +++ b/writeengine/bulk/we_colbufcompressed.cpp @@ -167,11 +167,16 @@ int ColumnBufferCompressed::resetToBeCompressedColBuf( // file, and instead buffer up the data to be compressed in 4M chunks before // writing it out. //------------------------------------------------------------------------------ -int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) +int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize, + bool fillUpWEmpties) { if (writeSize == 0) // skip unnecessary write, if 0 bytes given return NO_ERROR; + int fillUpWEmptiesWriteSize = 0; + if (fillUpWEmpties) + fillUpWEmptiesWriteSize = BYTE_PER_BLOCK - writeSize % BYTE_PER_BLOCK; + // If we are starting a new file, we need to reinit the buffer and // find out what our file offset should be set to. if (!fToBeCompressedCapacity) @@ -219,7 +224,7 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) // Expand the compression buffer size if working with an abbrev extent, and // the bytes we are about to add will overflow the abbreviated extent. if ((fToBeCompressedCapacity < IDBCompressInterface::UNCOMPRESSED_INBUF_LEN) && - ((fNumBytes + writeSize) > fToBeCompressedCapacity) ) + ((fNumBytes + writeSize + fillUpWEmptiesWriteSize) > fToBeCompressedCapacity) ) { std::ostringstream oss; oss << "Expanding abbrev to-be-compressed buffer for: OID-" << @@ -231,7 +236,7 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) fToBeCompressedCapacity = IDBCompressInterface::UNCOMPRESSED_INBUF_LEN; } - if ((fNumBytes + writeSize) <= fToBeCompressedCapacity) + if ((fNumBytes + writeSize + fillUpWEmptiesWriteSize) <= fToBeCompressedCapacity) { if (fLog->isDebug( DEBUG_2 )) { @@ -242,12 +247,14 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) "; part-" << fColInfo->curCol.dataFile.fPartition << "; seg-" << fColInfo->curCol.dataFile.fSegment << "; addBytes-" << writeSize << + "; extraBytes-" << fillUpWEmptiesWriteSize << "; totBytes-" << (fNumBytes + writeSize); fLog->logMsg( oss.str(), MSGLVL_INFO2 ); } memcpy(bufOffset, (fBuffer + startOffset), writeSize); fNumBytes += writeSize; + fNumBytes += fillUpWEmptiesWriteSize; } else // Not enough room to add all the data to the to-be-compressed buffer { @@ -338,6 +345,7 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) memcpy(bufOffset, (fBuffer + startOffsetX), writeSizeOut); fNumBytes += writeSizeOut; + fNumBytes += fillUpWEmptiesWriteSize; } startOffsetX += writeSizeOut; @@ -347,7 +355,6 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize) return NO_ERROR; } - //------------------------------------------------------------------------------ // Compress and write out the data in the to-be-compressed buffer. // Also may write out the compression header. diff --git a/writeengine/bulk/we_colbufcompressed.h b/writeengine/bulk/we_colbufcompressed.h index 335a8f2ba..5c4cccffc 100644 --- a/writeengine/bulk/we_colbufcompressed.h +++ b/writeengine/bulk/we_colbufcompressed.h @@ -83,11 +83,11 @@ public: * * @param startOffset The buffer offset from where the write should begin * @param writeSize The number of bytes to be written to the file - * @param fillUpWNulls The flag to fill the buffer with NULLs up to - * the block boundary. + * @param fillUpWEmpties The flag to fill the buffer with empty magic + * values up to the block boundary. */ virtual int writeToFile(int startOffset, int writeSize, - bool fillUpWNulls = false); + bool fillUpWEmpties = false); private: diff --git a/writeengine/bulk/we_colbufmgr.cpp b/writeengine/bulk/we_colbufmgr.cpp index 0ae34b6c9..9e6e78dc7 100644 --- a/writeengine/bulk/we_colbufmgr.cpp +++ b/writeengine/bulk/we_colbufmgr.cpp @@ -573,7 +573,7 @@ int ColumnBufferManager::writeToFileExtentCheck( if (availableFileSize >= writeSize) { - int rc = fCBuf->writeToFile(startOffset, writeSize); + int rc = fCBuf->writeToFile(startOffset, writeSize, fillUpWEmpties); if (rc != NO_ERROR) { @@ -632,7 +632,7 @@ int ColumnBufferManager::writeToFileExtentCheck( } int writeSize2 = writeSize - writeSize1; - rc = fCBuf->writeToFile(startOffset + writeSize1, writeSize2); + rc = fCBuf->writeToFile(startOffset + writeSize1, writeSize2, fillUpWEmpties); if (rc != NO_ERROR) {