rdblue commented on code in PR #18544:
URL: https://github.com/apache/iceberg/pull/18544#discussion_r4351845836


##########
core/src/main/java/org/apache/iceberg/mumbling/MumblingBitmap.java:
##########
@@ -51,23 +64,23 @@ class MumblingBitmap implements ManifestBitmap {
   private volatile int[] offsets = null;
 
   MumblingBitmap(ByteBuffer data) {
-    int version = data.get(data.position()) & 0xFF;
+    int version = ByteBuffers.readByte(data, 0);
     if (version != VERSION) {
       throw new UnsupportedOperationException("Unsupported Mumbling bitmap 
version: " + version);
     }
 
     this.data = data;
-    this.cardinality =
-        (data.get(data.position() + 1) & 0xFF)
-            | ((data.get(data.position() + 2) & 0xFF) << 8)
-            | ((data.get(data.position() + 3) & 0xFF) << 16);
-    this.containerCount =
-        (data.get(data.position() + 4) & 0xFF) | ((data.get(data.position() + 
5) & 0xFF) << 8);
+    this.cardinality = ByteBuffers.readLittleEndianUnsigned(data, 1, 3);
+    this.containerCount = ByteBuffers.readLittleEndianUnsigned(data, 4, 2);
 
     Preconditions.checkState(
-        containerCount <= 8192, "Invalid container count: %s > 8,192 (max)", 
containerCount);
+        containerCount < MAX_CONTAINER_COUNT,

Review Comment:
   Yeah, I think this is right. The rationale for this change was that 8192 
requires one more bit than 8191. And similarly, 2097152 requires one more bit 
than 2097151. I was thinking that it would be better to use 2^n - 1 rather than 
2^n, but it doesn't really matter since we are storing these as 2-byte and 
3-byte unsigned integers anyway.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to