From 488ab8ac3623b1f5b60cb9b436d0b86d3ac39d44 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 9 Mar 2023 08:04:52 -0800 Subject: [PATCH] Delete unused utility `BigIntegerFingerprintUtils`. PiperOrigin-RevId: 515337486 Change-Id: Ia5621b1f8302486ac059876118f38f8f6fcebdab --- .../com/google/devtools/build/lib/util/BUILD | 1 - .../lib/util/BigIntegerFingerprintUtils.java | 58 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 src/main/java/com/google/devtools/build/lib/util/BigIntegerFingerprintUtils.java diff --git a/src/main/java/com/google/devtools/build/lib/util/BUILD b/src/main/java/com/google/devtools/build/lib/util/BUILD index dd376b5fc01804..807bba303ef869 100644 --- a/src/main/java/com/google/devtools/build/lib/util/BUILD +++ b/src/main/java/com/google/devtools/build/lib/util/BUILD @@ -158,7 +158,6 @@ java_library( srcs = [ "AbstractIndexer.java", "AnsiStrippingOutputStream.java", - "BigIntegerFingerprintUtils.java", "CPU.java", "CanonicalStringIndexer.java", "ClassName.java", diff --git a/src/main/java/com/google/devtools/build/lib/util/BigIntegerFingerprintUtils.java b/src/main/java/com/google/devtools/build/lib/util/BigIntegerFingerprintUtils.java deleted file mode 100644 index 3fffe02ab33af6..00000000000000 --- a/src/main/java/com/google/devtools/build/lib/util/BigIntegerFingerprintUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2018 The Bazel Authors. All rights reserved. -// -// Licensed 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 com.google.devtools.build.lib.util; - -import com.google.common.annotations.VisibleForTesting; -import java.math.BigInteger; -import javax.annotation.Nullable; - -/** Utility class for fingerprint composition. */ -public final class BigIntegerFingerprintUtils { - private static final int BITS = 128; - public static final int BYTES = BITS / 8; - - private static final BigInteger UINT128_LIMIT = BigInteger.ONE.shiftLeft(BITS); - @VisibleForTesting public static final int RELATIVE_PRIME_INT = 31; - private static final BigInteger RELATIVE_PRIME = BigInteger.valueOf(RELATIVE_PRIME_INT); - - private BigIntegerFingerprintUtils() {} - - public static BigInteger compose(BigInteger v1, BigInteger v2) { - return v1.add(v2).mod(UINT128_LIMIT); - } - - /** - * Unordered, nullable composition. - * - *

null is absorbing and is used to convey errors and unavailability - */ - @Nullable - public static BigInteger composeNullable(@Nullable BigInteger v1, @Nullable BigInteger v2) { - if (v1 == null || v2 == null) { - return null; - } - return compose(v1, v2); - } - - @Nullable - public static BigInteger composeOrderedNullable( - @Nullable BigInteger accumulator, @Nullable BigInteger v) { - if (accumulator == null || v == null) { - return null; - } - return compose(accumulator.multiply(RELATIVE_PRIME).mod(UINT128_LIMIT), v); - } - -}