scwhittle commented on code in PR #36959:
URL: https://github.com/apache/beam/pull/36959#discussion_r2584376657


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/VarInt.java:
##########
@@ -136,16 +136,19 @@ public static long decodeLong(InputStream stream) throws 
IOException {
 
   /** Returns the length of the encoding of the given value (in bytes). */
   public static int getLength(int v) {
-    return getLength(convertIntToLongNoSignExtend(v));
+    // log2(v) / 7 + 1 rewritten as multiplication by 9/64 instead of a 
division by 7.

Review Comment:
   for decode we could unroll but still just read single bytes as needed, for 
encode we could loop.  But sounds good to investigate in a separate PR with 
benchmark.



-- 
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]

Reply via email to