liangyepianzhou commented on code in PR #23525:
URL: https://github.com/apache/pulsar/pull/23525#discussion_r1862155795
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java:
##########
@@ -169,9 +169,20 @@ protected ByteBuf getCompressedBatchMetadataAndPayload() {
}
int uncompressedSize =
batchedMessageMetadataAndPayload.readableBytes();
- ByteBuf compressedPayload =
compressor.encode(batchedMessageMetadataAndPayload);
- batchedMessageMetadataAndPayload.release();
- if (compressionType != CompressionType.NONE) {
+ ByteBuf compressedPayload;
+ boolean isCompressed = false;
+ if (!isBrokerTwoPhaseCompactor && producer != null){
+ if (uncompressedSize > producer.conf.getCompressMinMsgBodySize()) {
+ compressedPayload =
producer.applyCompression(batchedMessageMetadataAndPayload);
+ isCompressed = true;
+ } else {
+ compressedPayload = batchedMessageMetadataAndPayload;
+ }
+ } else {
+ compressedPayload =
compressor.encode(batchedMessageMetadataAndPayload);
+ batchedMessageMetadataAndPayload.release();
+ }
+ if (compressionType != CompressionType.NONE && isCompressed) {
messageMetadata.setCompression(compressionType);
messageMetadata.setUncompressedSize(uncompressedSize);
Review Comment:
done
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java:
##########
@@ -141,7 +141,7 @@ public boolean add(MessageImpl<?> msg, SendCallback
callback) {
return isBatchFull();
}
- protected ByteBuf getCompressedBatchMetadataAndPayload() {
+ protected ByteBuf getCompressedBatchMetadataAndPayload(boolean
isBrokerTwoPhaseCompactor) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]