New posts

This commit is contained in:
2026-11-06 21:43:48 +05:30
parent ecceaa8b32
commit f7b6c1efca
33 changed files with 1258 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import com.google.common.hash.Hashing;
import com.google.common.primitives.UnsignedBytes;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Comparator;
/** Three Guava features whose implementations have an Unsafe fast path (see output/11): hashing, byte comparison, futures. Needs guava on the class path. */
public class GuavaProbe {
public static void main(String[] args) throws Exception {
byte[] data = "unsafe-migration".getBytes();
System.out.println("murmur3_128 = " + Hashing.murmur3_128().hashBytes(data));
Comparator<byte[]> cmp = UnsignedBytes.lexicographicalComparator();
System.out.println("comparator = " + cmp.getClass().getName());
System.out.println("compare = " + Integer.signum(cmp.compare(new byte[] {1, 2, 3}, new byte[] {1, 2, 4})));
SettableFuture<String> f = SettableFuture.create();
f.set("ok");
System.out.println("future = " + f.get());
}
}