lordcheng10 edited a comment on pull request #3061:
URL: https://github.com/apache/bookkeeper/pull/3061#issuecomment-1042613806


   in addition,I added the following logic to reduce unnecessary rehash: 
@merlimat @hangc0276 @eolivelli 
   
           private void cleanBucket(int bucket) {
               int nextInArray = (bucket + 4) & (table.length - 1);
               if (table[nextInArray] == EmptyKey) {
                   table[bucket] = EmptyKey;
                   table[bucket + 1] = EmptyKey;
                   table[bucket + 2] = ValueNotFound;
                   table[bucket + 3] = ValueNotFound;
                   --usedBuckets;
   
                   // Reduce unnecessary rehash
                   bucket = (bucket - 4) & (table.length - 1);
                   while (table[bucket] == DeletedKey) {
                       table[bucket] = EmptyKey;
                       table[bucket + 1] = EmptyKey;
                       table[bucket + 2] = ValueNotFound;
                       table[bucket + 3] = ValueNotFound;
                       --usedBuckets;
   
                       bucket = (bucket - 4) & (table.length - 1);
                   }
               } else {
                   table[bucket] = DeletedKey;
                   table[bucket + 1] = DeletedKey;
                   table[bucket + 2] = ValueNotFound;
                   table[bucket + 3] = ValueNotFound;
               }
           }


-- 
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]


Reply via email to