From 400e6454302f69b0c76a9e1dc255552d344d22b0 Mon Sep 17 00:00:00 2001 From: Sunjeet Singh Date: Thu, 19 Dec 2024 19:46:16 -0800 Subject: [PATCH] (contd.) fix: if the max ordinal for a map value is zero then reserve 1 bit for it instead of nothing --- .../com/netflix/hollow/core/write/HollowMapTypeWriteState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hollow/src/main/java/com/netflix/hollow/core/write/HollowMapTypeWriteState.java b/hollow/src/main/java/com/netflix/hollow/core/write/HollowMapTypeWriteState.java index 8167d993c..2b94f63e1 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/write/HollowMapTypeWriteState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/write/HollowMapTypeWriteState.java @@ -185,7 +185,7 @@ private void calculateNumShards() { } long bitsPerKeyElement = 64 - Long.numberOfLeadingZeros(maxKeyOrdinal + 1); - long bitsPerValueElement = 64 - Long.numberOfLeadingZeros(maxValueOrdinal); + long bitsPerValueElement = maxValueOrdinal == 0 ? 1 : 64 - Long.numberOfLeadingZeros(maxValueOrdinal); long bitsPerMapSizeValue = 64 - Long.numberOfLeadingZeros(maxMapSize); long bitsPerMapPointer = 64 - Long.numberOfLeadingZeros(totalOfMapBuckets);