com.google.common.hash.Hashing.adler32()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中com.google.common.hash.Hashing.adler32()方法的一些代码示例,展示了Hashing.adler32()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hashing.adler32()方法的具体详情如下:
包路径:com.google.common.hash.Hashing
类名称:Hashing
方法名:adler32

Hashing.adler32介绍

[英]Returns a hash function implementing the Adler-32 checksum algorithm (32 hash bits).

To get the long value equivalent to Checksum#getValue() for a HashCode produced by this function, use HashCode#padToLong().

This function is best understood as a checksum rather than a true hash function.
[中]返回实现Adler-32校验和算法的哈希函数(32个哈希位)。
要获取此函数生成的HashCode的与Checksum#getValue()等价的长值,请使用HashCode#padToLong()。
最好将此函数理解为checksum,而不是真正的hash function

代码示例

代码示例来源:origin: google/guava

public void testAdler32() {
 HashTestUtils.assertInvariants(Hashing.adler32());
 assertEquals("Hashing.adler32()", Hashing.adler32().toString());
}

代码示例来源:origin: Netflix/EVCache

hf = Hashing.adler32();
break;

代码示例来源:origin: omero/common

public Adler32ChecksumProviderImpl() {
  super(Hashing.adler32());
}

代码示例来源:origin: com.google.guava/guava-tests

public void testAdler32() {
 HashTestUtils.assertInvariants(Hashing.adler32());
 assertEquals("Hashing.adler32()", Hashing.adler32().toString());
}

代码示例来源:origin: com.google.guava/guava-tests

private byte runHashFunction(int reps, HashFunction hashFunction) {
  byte result = 0x01;
  // Trick the JVM to prevent it from using the hash function non-polymorphically
  result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
  result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
  for (int i = 0; i < reps; i++) {
   result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
  }
  return result;
 }
}

代码示例来源:origin: com.google.guava/guava-tests

@Benchmark byte adler32HashFunction(int reps) {
 return runHashFunction(reps, Hashing.adler32());
}

相关文章