szetszwo commented on PR #5398:
URL: https://github.com/apache/ozone/pull/5398#issuecomment-1841711841

   @vtutrinov , thanks for working on this which is a very good performance 
improvement!
   
   Indeed, we could generate the `byte[]` directly instead of generating an 
`UUID` and then convert it to `byte[]`.  We could also get ride of the 
`java-uuid-generator` dependency.
   
   ```java
   +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/util/UUIDUtil.java
   @@ -15,13 +15,9 @@
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
   -
    package org.apache.hadoop.util;
    
   -import com.fasterxml.uuid.Generators;
   -
    import java.security.SecureRandom;
   -import java.util.UUID;
    
    /**
     * Helper methods to deal with random UUIDs.
   @@ -35,8 +31,14 @@ private UUIDUtil() {
      private static final ThreadLocal<SecureRandom> GENERATOR =
          ThreadLocal.withInitial(SecureRandom::new);
    
   -  public static UUID randomUUID() {
   -    return Generators.randomBasedGenerator(GENERATOR.get()).generate();
   +  public static byte[] randomUuidBytes() {
   +    final byte[] bytes = new byte[16];
   +    GENERATOR.get().nextBytes(bytes);
   +    // See RFC 4122 section 4.4
   +    bytes[6]  &= 0x0f;
   +    bytes[6]  |= 0x40;
   +    bytes[8]  &= 0x3f;
   +    bytes[8]  |= 0x80;
   +    return bytes;
      }
   -
    }
   ```


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