Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support byte[] in @HollowPrimaryKey for ObjectInternPool in HollowHistoryUI #664

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

PiotrAuguscik
Copy link
Contributor

@PiotrAuguscik PiotrAuguscik commented Feb 19, 2024

When loading states with byte[] as the primary key in Hollow, the ObjectInternPool throws an IllegalArgumentException. This issue occurs because the current implementation of ObjectInternPool does not support interning objects of type byte[], which is needed by HollowHistoryUI.

The proposed solution extends the ObjectInternPool functionality to handle byte[] effectively, allowing HollowHistoryUI to intern these objects without errors.

Current implementation throws exception:

Caused by: java.lang.IllegalArgumentException: Cannot intern object of type [B
	at com.netflix.hollow.tools.util.ObjectInternPool.writeAndGetOrdinal(ObjectInternPool.java:123)
	at com.netflix.hollow.tools.history.keyindex.HollowOrdinalMapper.storeFieldObjects(HollowOrdinalMapper.java:182)
	at com.netflix.hollow.tools.history.keyindex.HollowOrdinalMapper.storeNewRecord(HollowOrdinalMapper.java:168)
	at com.netflix.hollow.tools.history.keyindex.HollowHistoryTypeKeyIndex.writeKeyObject(HollowHistoryTypeKeyIndex.java:159)
	at com.netflix.hollow.tools.history.keyindex.HollowHistoryTypeKeyIndex.populateAllCurrentRecordKeysIntoIndex(HollowHistoryTypeKeyIndex.java:153)
	at com.netflix.hollow.tools.history.keyindex.HollowHistoryTypeKeyIndex.update(HollowHistoryTypeKeyIndex.java:126)
	at com.netflix.hollow.tools.history.keyindex.HollowHistoryKeyIndex.lambda$updateTypeIndexes$0(HollowHistoryKeyIndex.java:143)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)

Copy link
Contributor

@stevenewald stevenewald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sunjeet
Copy link
Contributor

Sunjeet commented Mar 14, 2024

Hi @PiotrAuguscik , this breaks the build so I reverted the commit, I think it should just be a matter of applying this diff, but i haven't tested it beyond successful build-

diff --git a/hollow/src/main/java/com/netflix/hollow/tools/util/ObjectInternPool.java b/hollow/src/main/java/com/netflix/hollow/tools/util/ObjectInternPool.java
index af0fb18c5..27ad0c466 100644
--- a/hollow/src/main/java/com/netflix/hollow/tools/util/ObjectInternPool.java
+++ b/hollow/src/main/java/com/netflix/hollow/tools/util/ObjectInternPool.java
@@ -115,6 +115,11 @@ public class ObjectInternPool {
             for (byte b : ((String) objectToIntern).getBytes()) {
                 buf.write(b);
             }
+        } else if(objectToIntern instanceof byte[]) {
+            VarInt.writeVInt(buf, ((byte[]) objectToIntern).length);
+            for (byte b : ((byte[]) objectToIntern)) {
+                buf.write(b);
+            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants