You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "hongkunxu (via GitHub)" <gi...@apache.org> on 2025/08/18 17:27:18 UTC

[PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

hongkunxu opened a new pull request, #18415:
URL: https://github.com/apache/druid/pull/18415

   This PR fixes a bug in CacheKeyBuilder.appendCacheable where null or empty Cacheable objects were not properly marked as invalid.
   - appendCacheable now marks keys that serialize to EMPTY_BYTES as invalid.
   - Ensures that build() returns null for invalid keys instead of producing a misleading byte array.
   
   Updates unit tests to reflect the corrected behavior.
   Impact:
   - Only affects cache key generation logic in SPI skeleton.
   - No changes to existing cache storage or retrieval mechanisms.


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] fix: Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "hongkunxu (via GitHub)" <gi...@apache.org>.
hongkunxu closed pull request #18415: fix: Fix CacheKeyBuilder to correctly handle empty Cacheable keys
URL: https://github.com/apache/druid/pull/18415


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "hongkunxu (via GitHub)" <gi...@apache.org>.
hongkunxu commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-4186044256

   Hi @FrankChen021 , Could you help move this forward?
   


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] fix: Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "GWphua (via GitHub)" <gi...@apache.org>.
GWphua commented on code in PR #18415:
URL: https://github.com/apache/druid/pull/18415#discussion_r3043715801


##########
processing/src/main/java/org/apache/druid/query/cache/CacheKeyBuilder.java:
##########
@@ -269,12 +271,12 @@ public CacheKeyBuilder appendFloatArray(float[] input)
 
   public CacheKeyBuilder appendCacheable(@Nullable Cacheable input)
   {
-    byte[] cacheableToByteArray = cacheableToByteArray(input);
-    if (cacheableToByteArray == null) {
+    final byte[] bytes = cacheableToByteArray(input);
+    if (bytes == null) {
       invalidKey = true;
       return this;
     }
-    appendItem(CACHEABLE_KEY, cacheableToByteArray);
+    appendItem(CACHEABLE_KEY, bytes);

Review Comment:
   This change is a pure rename right? Can we leave this untouched?



-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "GWphua (via GitHub)" <gi...@apache.org>.
GWphua commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-4191609663

   @hongkunxu Thanks for the contribution. Please address the problems that were highlighted in the CI.
   
   Notably, 
   1. PR title. (prefix title with `fix: `)
   2. Checkstyle (Test with `mvn checkstyle:check`)


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-3447891821

   This pull request has been marked as stale due to 60 days of inactivity.
   It will be closed in 4 weeks if no further activity occurs. If you think
   that's incorrect or this pull request should instead be reviewed, please simply
   write any comment. Even if closed, you can still revive the PR at any time or
   discuss it on the dev@druid.apache.org list.
   Thank you for your contributions.


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-3519612996

   close and repen to trigger the CI @hongkunxu 


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-3868690180

   This pull request/issue has been closed due to lack of activity. If you think that
   is incorrect, or the pull request requires review, you can revive the PR at any time.


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #18415: [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys
URL: https://github.com/apache/druid/pull/18415


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-3736531390

   This pull request has been marked as stale due to 60 days of inactivity.
   It will be closed in 4 weeks if no further activity occurs. If you think
   that's incorrect or this pull request should instead be reviewed, please simply
   write any comment. Even if closed, you can still revive the PR at any time or
   discuss it on the dev@druid.apache.org list.
   Thank you for your contributions.


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] fix: Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "hongkunxu (via GitHub)" <gi...@apache.org>.
hongkunxu commented on code in PR #18415:
URL: https://github.com/apache/druid/pull/18415#discussion_r3043966993


##########
processing/src/main/java/org/apache/druid/query/cache/CacheKeyBuilder.java:
##########
@@ -269,12 +271,12 @@ public CacheKeyBuilder appendFloatArray(float[] input)
 
   public CacheKeyBuilder appendCacheable(@Nullable Cacheable input)
   {
-    byte[] cacheableToByteArray = cacheableToByteArray(input);
-    if (cacheableToByteArray == null) {
+    final byte[] bytes = cacheableToByteArray(input);
+    if (bytes == null) {
       invalidKey = true;
       return this;
     }
-    appendItem(CACHEABLE_KEY, cacheableToByteArray);
+    appendItem(CACHEABLE_KEY, bytes);

Review Comment:
   Since this PR has been open for quite some time and I no longer recall the original context clearly, I revisited it and found the changes are unnecessary. I’ve closed the PR. Thanks @GWphua  for the review.



-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 closed pull request #18415: [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys
URL: https://github.com/apache/druid/pull/18415


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] [BugFix] Fix CacheKeyBuilder to correctly handle empty Cacheable keys (druid)

Posted by "hongkunxu (via GitHub)" <gi...@apache.org>.
hongkunxu commented on PR #18415:
URL: https://github.com/apache/druid/pull/18415#issuecomment-3519606789

   Hi @FrankChen021 , Could you please tell me why not merge this PR?


-- 
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-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org