poorbarcode commented on code in PR #16685:
URL: https://github.com/apache/pulsar/pull/16685#discussion_r925584342
##########
pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/MLTransactionLogImpl.java:
##########
@@ -209,15 +238,46 @@ class TransactionLogReplayer {
}
public void start() {
- TransactionMetadataEntry transactionMetadataEntry = new
TransactionMetadataEntry();
-
while (fillEntryQueueCallback.fillQueue() || entryQueue.size() >
0) {
Entry entry = entryQueue.poll();
if (entry != null) {
try {
- ByteBuf buffer = entry.getDataBuffer();
- transactionMetadataEntry.parseFrom(buffer,
buffer.readableBytes());
-
transactionLogReplayCallback.handleMetadataEntry(entry.getPosition(),
transactionMetadataEntry);
+ List<TransactionMetadataEntry> logs =
deserializeEntry(entry);
+ if (logs.isEmpty()){
+ continue;
+ } else if (logs.size() == 1){
+ TransactionMetadataEntry log = logs.get(0);
+
transactionLogReplayCallback.handleMetadataEntry(entry.getPosition(), log);
+ } else {
+ /**
+ * 1. Query batch index of current entry from
cursor.
+ * 2. Filter the data which has already ack.
+ * 3. Build batched position and handle valid data.
+ */
+ long[] ackSetAlreadyAck =
cursor.getDeletedBatchIndexesAsLongArray(
+ PositionImpl.get(entry.getLedgerId(),
entry.getEntryId()));
+ BitSetRecyclable bitSetAlreadyAck = null;
+ if (ackSetAlreadyAck != null){
+ bitSetAlreadyAck =
BitSetRecyclable.valueOf(ackSetAlreadyAck);
+ }
+ int batchSize = logs.size();
+ for (int batchIndex = 0; batchIndex < batchSize;
batchIndex++){
+ if (bitSetAlreadyAck != null &&
!bitSetAlreadyAck.get(batchIndex)){
+ continue;
+ }
+ TransactionMetadataEntry log =
logs.get(batchIndex);
+ BitSetRecyclable bitSetOfCurrentRecord =
BitSetRecyclable.create();
+ bitSetOfCurrentRecord.set(batchIndex);
+ long[] ackSetOfCurrentRecord =
bitSetOfCurrentRecord.toLongArray();
+ bitSetOfCurrentRecord.recycle();
+ PositionImpl batchedPosition =
PositionImpl.get(entry.getLedgerId(),
+ entry.getEntryId(),
ackSetOfCurrentRecord);
Review Comment:
Already deleted.
--
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]