sashapolo commented on code in PR #6832: URL: https://github.com/apache/ignite-3/pull/6832#discussion_r2451788452
########## modules/raft/src/main/java/org/apache/ignite/internal/raft/util/VarlenEncoder.java: ########## @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.raft.util; + +import java.nio.ByteBuffer; +import org.apache.ignite.internal.util.GridUnsafe; + +/** + * Class contatining methods for encoding/decoding long values using variable length encoding. + */ +// Based on DirectByteBufferStreamImplV1. +public class VarlenEncoder { + /** + * Writes the given value to the given buffer. + * + * @return Number of bytes written. + */ + public static int writeLong(long val, ByteBuffer out) { + int startPos = out.position(); + + while ((val & 0xFFFF_FFFF_FFFF_FF80L) != 0) { Review Comment: > Can we extract this bitmask to a constant, and add a comment that it clears the last 7 bits? yes > Actually, I think this constant should be defined in org.apache.ignite.internal.util.VarIntUtils and re-used. I don't agree, `VarIntUtils` is a separate class with its own encoding -- 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]
