You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "cmccabe (via GitHub)" <gi...@apache.org> on 2023/05/02 17:22:37 UTC

[GitHub] [kafka] cmccabe commented on a diff in pull request #13653: KAFKA-14946: fix NPE when merging the deltatable

cmccabe commented on code in PR #13653:
URL: https://github.com/apache/kafka/pull/13653#discussion_r1182836931


##########
server-common/src/main/java/org/apache/kafka/timeline/SnapshottableHashTable.java:
##########
@@ -113,7 +113,7 @@ public void mergeFrom(long epoch, Delta source) {
             HashTier<T> other = (HashTier<T>) source;
             // As an optimization, the deltaTable might not exist for a new key
             // as there is no previous value
-            if (other.deltaTable != null) {
+            if (deltaTable != null && other.deltaTable != null) {

Review Comment:
   Hmm, if our deltaTable doesn't exist here, we should create it like this, right?
   ```
               if (other.deltaTable != null) {
                   List<T> list = new ArrayList<>();
                   Object[] otherElements = other.deltaTable.baseElements();
                   for (int slot = 0; slot < otherElements.length; slot++) {
                       BaseHashTable.unpackSlot(list, otherElements, slot);
                       for (T element : list) {
                           // When merging in a later hash tier, we want to keep only the elements
                           // that were present at our epoch.
                           if (element.startEpoch() <= epoch) {
                               if (deltaTable == null) {
                                   deltaTable = new BaseHashTable<>(1);
                               }
                               deltaTable.baseAddOrReplace(element);
                           }
                       }
                   }
               }
   ```
   
   Otherwise we're not merging in all the stuff we should be from the later snapshot



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org