gy-deng commented on code in PR #1410: URL: https://github.com/apache/pulsar-client-go/pull/1410#discussion_r2348883380
########## pulsar/negative_acks_tracker.go: ########## @@ -103,14 +134,20 @@ func (t *negativeAcksTracker) AddMessage(msg Message) { t.Lock() defer t.Unlock() - _, present := t.negativeAcks[batchMsgID] - if present { - // The batch is already being tracked - return - } - targetTime := time.Now().Add(nackBackoffDelay) - t.negativeAcks[batchMsgID] = targetTime + trimmedTime := time.UnixMilli(trimLowerBit(targetTime.UnixMilli(), t.nackPrecisionBit)) + // try get trimmedTime + value, exists := t.negativeAcks.Get(trimmedTime) + if !exists { + newMap := make(map[LedgerID]*roaring64.Bitmap) + t.negativeAcks.Put(trimmedTime, newMap) + value = newMap + } + bitmapMap := value.(map[LedgerID]*roaring64.Bitmap) + if _, exists := bitmapMap[batchMsgID.ledgerID]; !exists { + bitmapMap[batchMsgID.ledgerID] = roaring64.NewBitmap() + } + bitmapMap[batchMsgID.ledgerID].Add(uint64(batchMsgID.entryID)) Review Comment: Added `putNackEntry` function to reduce code redundancy. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org