If compression type not != NONE put all operations in one chunk.
@@ -252,7 +252,7 @@ DomainPart::buildPacketMapping(bool allowTruncate)
DomainPart::DomainPart(const string & name, const string & baseDir, SerialNum s, Encoding encoding,
uint8_t compressionLevel, const FileHeaderContext &fileHeaderContext, bool allowTruncate)
- : _encoding(encoding.getCrc(), Encoding::Compression::none), //TODO We do not yet support compression
+ : _encoding(encoding),
_compressionLevel(compressionLevel),
_lock(),
_fileLock(),
@@ -396,16 +396,19 @@ DomainPart::commit(SerialNum firstSerial, const Packet &packet)
if (_range.from() == 0) {
_range.from(firstSerial);
}
+ IChunk::UP chunk = IChunk::create(_encoding, _compressionLevel);
for (size_t i(0); h.size() > 0; i++) {
//LOG(spam,
//"Pos(%d) Len(%d), Lim(%d), Remaining(%d)",
//h.getPos(), h.getLength(), h.getLimit(), h.getRemaining());
- IChunk::UP chunk = IChunk::create(_encoding, _compressionLevel);
Packet::Entry entry;
entry.deserialize(h);
if (_range.to() < entry.serial()) {
chunk->add(entry);
+ if (_encoding.getCompression() == Encoding::Compression::none) {
write(*_transLog, *chunk);
+ chunk = IChunk::create(_encoding, _compressionLevel);
+ }
_sz++;
_range.to(entry.serial());
} else {
@@ -413,6 +416,9 @@ DomainPart::commit(SerialNum firstSerial, const Packet &packet)
entry.serial(), _range.to()));
}
}
+ if ( ! chunk->getEntries().empty()) {
+ write(*_transLog, *chunk);
+ }
bool merged(false);
LockGuard guard(_lock);
