Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ protected boolean compactMessage(String topic, Map<String, Pair<MessageId, Long>
protected boolean compactBatchMessage(String topic, Map<String, Pair<MessageId, Long>> latestForKey, RawMessage m,
MessageMetadata metadata, MessageId id) {
boolean deletedMessage = false;
boolean hasMessagesRetained = false;
try {
int numMessagesInBatch = metadata.getNumMessagesInBatch();
int deleteCnt = 0;

for (MessageCompactionData mcd : extractMessageCompactionDataFromBatch(m, metadata)) {
if (mcd.key() == null) {
if (!topicCompactionRetainNullKey) {
// record delete null-key message event
deleteCnt++;
mxBean.addCompactionRemovedEvent(topic);
} else {
hasMessagesRetained = true;
}
continue;
}
Expand All @@ -120,15 +119,15 @@ protected boolean compactBatchMessage(String topic, Map<String, Pair<MessageId,
if (old != null) {
mxBean.addCompactionRemovedEvent(topic);
}
hasMessagesRetained = true;
} else {
latestForKey.remove(mcd.key());
deleteCnt++;
mxBean.addCompactionRemovedEvent(topic);
}
}
}

if (deleteCnt == numMessagesInBatch) {
if (!hasMessagesRetained) {
deletedMessage = true;
}
} catch (IOException ioe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ protected boolean compactMessage(String topic, Map<String, MessageId> latestForK
protected boolean compactBatchMessage(String topic, Map<String, MessageId> latestForKey,
RawMessage m, MessageMetadata metadata, MessageId id) {
boolean deletedMessage = false;
boolean hasMessagesRetained = false;
try {
int numMessagesInBatch = metadata.getNumMessagesInBatch();
int deleteCnt = 0;
for (ImmutableTriple<MessageId, String, Integer> e : extractIdsAndKeysAndSizeFromBatch(
m, metadata)) {
if (e != null) {
if (e.getMiddle() == null) {
if (!topicCompactionRetainNullKey) {
// record delete null-key message event
deleteCnt++;
mxBean.addCompactionRemovedEvent(topic);
} else {
hasMessagesRetained = true;
}
continue;
}
Expand All @@ -99,14 +99,14 @@ protected boolean compactBatchMessage(String topic, Map<String, MessageId> lates
if (old != null) {
mxBean.addCompactionRemovedEvent(topic);
}
hasMessagesRetained = true;
} else {
latestForKey.remove(e.getMiddle());
deleteCnt++;
mxBean.addCompactionRemovedEvent(topic);
}
}
}
if (deleteCnt == numMessagesInBatch) {
if (!hasMessagesRetained) {
deletedMessage = true;
}
} catch (IOException ioe) {
Expand Down
Loading