From commits-return-13399-archive-asf-public=cust-asf.ponee.io@hudi.apache.org Sun Mar 15 05:03:54 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id AF6F618063D for ; Sun, 15 Mar 2020 06:03:53 +0100 (CET) Received: (qmail 30043 invoked by uid 500); 15 Mar 2020 05:03:52 -0000 Mailing-List: contact commits-help@hudi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hudi.apache.org Delivered-To: mailing list commits@hudi.apache.org Received: (qmail 30034 invoked by uid 99); 15 Mar 2020 05:03:51 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Mar 2020 05:03:51 +0000 From: GitBox To: commits@hudi.apache.org Subject: [GitHub] [incubator-hudi] s-sanjay commented on a change in pull request #1350: [HUDI-629]: Replace Guava's Hashing with an equivalent in NumericUtils.java Message-ID: <158424863159.13131.12856814984064261221.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Sun, 15 Mar 2020 05:03:51 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit s-sanjay commented on a change in pull request #1350: [HUDI-629]: Replace Guava's Hashing with an equivalent in NumericUtils.java URL: https://github.com/apache/incubator-hudi/pull/1350#discussion_r392641969 ########## File path: hudi-common/src/main/java/org/apache/hudi/common/util/NumericUtils.java ########## @@ -31,4 +38,27 @@ public static String humanReadableByteCount(double bytes) { String pre = "KMGTPE".charAt(exp - 1) + ""; return String.format("%.1f %sB", bytes / Math.pow(1024, exp), pre); } + + public static long getMessageDigestHash(final String algorithmName, final String string) { + MessageDigest md; + try { + md = MessageDigest.getInstance(algorithmName); + } catch (NoSuchAlgorithmException e) { + throw new HoodieException(e); + } + return asLong(Objects.requireNonNull(md).digest(string.getBytes(StandardCharsets.UTF_8))); + } + + public static long asLong(byte[] bytes) { + ValidationUtils.checkState(bytes.length >= 8, "HashCode#asLong() requires >= 8 bytes."); + return padToLong(bytes); + } + + public static long padToLong(byte[] bytes) { + long retVal = (bytes[0] & 0xFF); Review comment: do we need & 0xFF ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services