void Journal::journal(const JSectHeader& h, const AlignedBuilder& uncompressed) {
|
RACECHECK
|
static AlignedBuilder b(32*1024*1024);
|
/* buffer to journal will be
|
JSectHeader
|
compressed operations
|
JSectFooter
|
*/
|
const unsigned headTailSize = sizeof(JSectHeader) + sizeof(JSectFooter);
|
const unsigned max = maxCompressedLength(uncompressed.len()) + headTailSize;
|
b.reset(max);
|
|
{
|
dassert( h.sectionLen() == (unsigned) 0xffffffff ); // we will backfill later
|
b.appendStruct(h);
|
}
|
|
size_t compressedLength = 0;
|
rawCompress(uncompressed.buf(), uncompressed.len(), b.cur(), &compressedLength);
|
verify( compressedLength < 0xffffffff );
|
verify( compressedLength < max );
|
b.skip(compressedLength);
|