java.util.zip.Checksum.reset()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(104)

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

Checksum.reset介绍

[英]Resets the checksum value applied before beginning calculations on a new stream of data.
[中]重置在开始计算新数据流之前应用的校验和值。

代码示例

代码示例来源:origin: netty/netty

@Override
  public void reset() {
    checksum.reset();
  }
}

代码示例来源:origin: redisson/redisson

@Override
  public void reset() {
    checksum.reset();
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void reset() {
    checksum.reset();
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private void resetState() {
  // invalidate buffer
  count = 0;
  pos = 0;
  // reset Checksum
  if (sum != null) {
   sum.reset();
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public void reset() {
 summer.reset();
 inSum = 0;
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public void reset() {
 upto = 0;
 in.reset();
}

代码示例来源:origin: greenrobot/essentials

@Override
public void reset() {
  checksum.reset();
}

代码示例来源:origin: apache/flume

protected long calculateChecksum(byte[] body) {
 checksum.reset();
 checksum.update(body, 0, body.length);
 return checksum.getValue();
}

代码示例来源:origin: apache/ignite

/**
 * Resets this to an empty file.
 */
public void reset() {
  currBuf = 0;
  currBufIdx = -1;
  bufPosition = 0;
  bufStart = 0;
  bufLength = 0;
  file.setLength(0);
  crc.reset();
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** Resets this to an empty file. */
public void reset() {
 currentBuffer = null;
 currentBufferIndex = -1;
 bufferPosition = 0;
 bufferStart = 0;
 bufferLength = 0;
 file.setLength(0);
 if (crc != null) {
  crc.reset();
 }
}

代码示例来源:origin: greenrobot/essentials

private long getHash(ByteBuffer byteBuffer) {
  byte[] bytes = byteBuffer.array();
  checksum.reset();
  checksum.update(bytes, 0, bytes.length);
  long value = checksum.getValue();
  checksum.reset();
  return value;
}

代码示例来源:origin: commons-codec/commons-codec

@Override
 public void run() {
  final long st = System.nanoTime();
  crc.reset();
  for (int i = 0; i < trials; i++) {
   crc.update(bytes, 0, size);
  }
  final long et = System.nanoTime();
  final double secsElapsed = (et - st) / 1000000000.0d;
  results[index] = new BenchResult(crc.getValue(), mbProcessed/secsElapsed);
 }
};

代码示例来源:origin: greenrobot/essentials

@Before
public void setUp() {
  checksum.reset();
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testMixedUnaligned() {
  checksum.update(INPUT16, 0, INPUT16.length);
  long hash = checksum.getValue();
  checksum.reset();
  checksum.update(INPUT16, 0, 2);
  checksum.update(INPUT16[2]);
  checksum.update(INPUT16, 3, 11);
  checksum.update(INPUT16[14]);
  checksum.update(INPUT16[15]);
  Assert.assertEquals(hash, checksum.getValue());
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testRestUnaligned() {
  checksum.update(42);
  long hash = checksum.getValue();
  checksum.reset();
  checksum.update(42);
  Assert.assertEquals(hash, checksum.getValue());
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testExpectedHashVariableOffset() {
  byte[] bytes = new byte[512];
  new Random(31).nextBytes(bytes);
  for (int i = 0; i <= bytes.length; i++) {
    int expected = MurmurHash3Yonik.murmurhash3_x86_32(bytes, i, bytes.length - i, 0);
    checksum.reset();
    checksum.update(bytes, i, bytes.length - i);
    int value = (int) checksum.getValue();
    Assert.assertEquals(expected, value);
  }
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testFnv32UpdateBytesZeroHash() {
  checksum.update(INPUT32_ZERO1, 0, INPUT32_ZERO1.length);
  Assert.assertEquals(0, checksum.getValue());
  checksum.reset();
  checksum.update(INPUT32_ZERO2, 0, INPUT32_ZERO1.length);
  Assert.assertEquals(0, checksum.getValue());
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testExpectedHashVariableLength() {
  byte[] bytes = new byte[512];
  new Random(23).nextBytes(bytes);
  for (int i = 0; i <= bytes.length; i++) {
    int expected = MurmurHash3Yonik.murmurhash3_x86_32(bytes, 0, i, 0);
    checksum.reset();
    checksum.update(bytes, 0, i);
    int value = (int) checksum.getValue();
    Assert.assertEquals(expected, value);
  }
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testFnv32UpdateZeroHash() {
  for (int b : INPUT32_ZERO1) {
    checksum.update(b);
  }
  Assert.assertEquals(0, checksum.getValue());
  checksum.reset();
  for (int b : INPUT32_ZERO2) {
    checksum.update(b);
  }
  Assert.assertEquals(0, checksum.getValue());
}

代码示例来源:origin: greenrobot/essentials

@Test
public void testBasics() {
  long initialHash = checksum.getValue();
  for (int b : INPUT4) {
    checksum.update(b);
    Assert.assertNotEquals(initialHash, checksum.getValue());
  }
  long hash = checksum.getValue();
  checksum.reset();
  Assert.assertEquals(initialHash, checksum.getValue());
  checksum.update(INPUT4, 0, INPUT4.length);
  Assert.assertEquals(hash, checksum.getValue());
}

相关文章