From 4e204c771b2ae61ffdb93e860f73edbd7df9e60b 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 --- .../api/producer/validation/PrimaryKeyViolationValidator.java | 2 ++ .../com/netflix/hollow/core/write/HollowMapTypeWriteState.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 hollow/src/main/java/com/netflix/hollow/api/producer/validation/PrimaryKeyViolationValidator.java diff --git a/hollow/src/main/java/com/netflix/hollow/api/producer/validation/PrimaryKeyViolationValidator.java b/hollow/src/main/java/com/netflix/hollow/api/producer/validation/PrimaryKeyViolationValidator.java new file mode 100644 index 000000000..1fb01f997 --- /dev/null +++ b/hollow/src/main/java/com/netflix/hollow/api/producer/validation/PrimaryKeyViolationValidator.java @@ -0,0 +1,2 @@ +package com.netflix.hollow.api.producer.validation;public class PrimaryKeyViolationValidator { +} 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);