gpt4 book ai didi

net.jpountz.xxhash.XXHash64类的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 06:05:05 24 4
gpt4 key购买 nike

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

XXHash64介绍

[英]A 64-bits hash.

Instances of this class are thread-safe.
[中]64位哈希。
此类的实例是线程安全的。

代码示例

代码示例来源:origin: net.jpountz.lz4/lz4

/**
 * Compute the hash of the given {@link ByteBuffer}. The
 * {@link ByteBuffer#position() position} is moved in order to reflect bytes
 * which have been read.
 */
public final long hash(ByteBuffer buf, long seed) {
 final long hash = hash(buf, buf.position(), buf.remaining(), seed);
 buf.position(buf.limit());
 return hash;
}

代码示例来源:origin: com.github.swri-robotics/lz4

/**
 * Compute the hash of the given {@link ByteBuffer}. The
 * {@link ByteBuffer#position() position} is moved in order to reflect bytes
 * which have been read.
 */
public final long hash(ByteBuffer buf, long seed) {
 final long hash = hash(buf, buf.position(), buf.remaining(), seed);
 buf.position(buf.limit());
 return hash;
}

代码示例来源:origin: snazy/ohc

long hash(byte[] array)
  {
    return xx.hash64().hash(array, 0, array.length, 0);
  }
}

代码示例来源:origin: yahoo/HaloDB

long hash(byte[] array) {
    return xx.hash64().hash(array, 0, array.length, 0);
  }
}

代码示例来源:origin: snazy/ohc

long hash(ByteBuffer buffer)
  {
    return xx.hash64().hash(buffer, 0);
  }
}

代码示例来源:origin: org.caffinitas.ohc/ohc-core

long hash(ByteBuffer buffer)
  {
    return xx.hash64().hash(buffer, 0);
  }
}

代码示例来源:origin: diennea/herddb

public static byte[] digest(byte[] array, int offset, int len) {
  long hash = HASHER.hash(array, offset, len, DEFAULT_SEED);
  byte[] digest = Bytes.longToByteArray(hash);
  return digest;
}

代码示例来源:origin: org.caffinitas.ohc/ohc-core

long hash(byte[] array)
  {
    return xx.hash64().hash(array, 0, array.length, 0);
  }
}

代码示例来源:origin: diennea/herddb

public static boolean verifyBlockWithFooter(byte[] array, int offset, int len) {
  byte[] expectedFooter = Arrays.copyOfRange(array, len - HASH_LEN, len);
  long expectedHash = HASHER.hash(array, offset, len - HASH_LEN, DEFAULT_SEED);
  long hash = Bytes.toLong(expectedFooter, 0);
  return hash == expectedHash;
}

代码示例来源:origin: com.orientechnologies/orientdb-core

private static boolean pageIsBroken(final ByteBuffer buffer, int walPageSize) {
 buffer.position(OCASWALPage.MAGIC_NUMBER_OFFSET);
 if (buffer.getLong() != OCASWALPage.MAGIC_NUMBER) {
  return true;
 }
 final int pageSize = buffer.getShort(OCASWALPage.PAGE_SIZE_OFFSET);
 if (pageSize == 0 || pageSize > walPageSize) {
  return true;
 }
 buffer.limit(pageSize);
 buffer.position(OCASWALPage.RECORDS_OFFSET);
 final XXHash64 hash64 = xxHashFactory.hash64();
 final long hash = hash64.hash(buffer, XX_SEED);
 buffer.position(OCASWALPage.XX_OFFSET);
 if (hash != buffer.getLong()) {
  return true;
 }
 return false;
}

代码示例来源:origin: com.yahoo.vespa/filedistribution

public FileReferenceDataBlob(FileReference fileReference, String filename, Type type, byte[] content) {
  this(fileReference, filename, type, content, XXHashFactory.fastestInstance().hash64().hash(ByteBuffer.wrap(content), 0));
}

代码示例来源:origin: snazy/ohc

long hash(long address, long offset, int length)
{
  return xx.hash64().hash(Uns.directBufferFor(address, offset, length, true), 0);
}

代码示例来源:origin: org.caffinitas.ohc/ohc-core

long hash(long address, long offset, int length)
{
  return xx.hash64().hash(Uns.directBufferFor(address, offset, length, true), 0);
}

代码示例来源:origin: yahoo/HaloDB

long hash(long address, long offset, int length) {
  return xx.hash64().hash(Uns.directBufferFor(address, offset, length, true), 0);
}

代码示例来源:origin: com.github.swri-robotics/lz4

@Override
public long hash(ByteBuffer buf, int off, int len, long seed) {
 if (buf.isDirect()) {
  checkRange(buf, off, len);
  return XXHashJNI.XXH64BB(buf, off, len, seed);
 } else if (buf.hasArray()) {
  return hash(buf.array(), off + buf.arrayOffset(), len, seed);
 } else {
  XXHash64 safeInstance = SAFE_INSTANCE;
  if (safeInstance == null) {
   safeInstance = SAFE_INSTANCE = XXHashFactory.safeInstance().hash64();
  }
  return safeInstance.hash(buf, off, len, seed);
 }
}

代码示例来源:origin: net.jpountz.lz4/lz4

@Override
public long hash(ByteBuffer buf, int off, int len, long seed) {
 if (buf.isDirect()) {
  checkRange(buf, off, len);
  return XXHashJNI.XXH64BB(buf, off, len, seed);
 } else if (buf.hasArray()) {
  return hash(buf.array(), off, len, seed);
 } else {
  XXHash64 safeInstance = SAFE_INSTANCE;
  if (safeInstance == null) {
   safeInstance = SAFE_INSTANCE = XXHashFactory.safeInstance().hash64();
  }
  return safeInstance.hash(buf, off, len, seed);
 }
}

代码示例来源:origin: com.github.swri-robotics/lz4

private XXHashFactory(String impl) throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
 this.impl = impl;
 hash32 = classInstance("net.jpountz.xxhash.XXHash32" + impl);
 streamingHash32Factory = classInstance("net.jpountz.xxhash.StreamingXXHash32" + impl + "$Factory");
 hash64 = classInstance("net.jpountz.xxhash.XXHash64" + impl);
 streamingHash64Factory = classInstance("net.jpountz.xxhash.StreamingXXHash64" + impl + "$Factory");
 // make sure it can run
 final byte[] bytes = new byte[100];
 final Random random = new Random();
 random.nextBytes(bytes);
 final int seed = random.nextInt();
 final int h1 = hash32.hash(bytes, 0, bytes.length, seed);
 final StreamingXXHash32 streamingHash32 = newStreamingHash32(seed);
 streamingHash32.update(bytes, 0, bytes.length);
 final int h2 = streamingHash32.getValue();
 final long h3 = hash64.hash(bytes, 0, bytes.length, seed);
 final StreamingXXHash64 streamingHash64 = newStreamingHash64(seed);
 streamingHash64.update(bytes, 0, bytes.length);
 final long h4 = streamingHash64.getValue();
 if (h1 != h2) {
  throw new AssertionError();
 }
 if (h3 != h4) {
  throw new AssertionError();
 }
}

代码示例来源:origin: net.jpountz.lz4/lz4

private XXHashFactory(String impl) throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
 this.impl = impl;
 hash32 = classInstance("net.jpountz.xxhash.XXHash32" + impl);
 streamingHash32Factory = classInstance("net.jpountz.xxhash.StreamingXXHash32" + impl + "$Factory");
 hash64 = classInstance("net.jpountz.xxhash.XXHash64" + impl);
 streamingHash64Factory = classInstance("net.jpountz.xxhash.StreamingXXHash64" + impl + "$Factory");
 // make sure it can run
 final byte[] bytes = new byte[100];
 final Random random = new Random();
 random.nextBytes(bytes);
 final int seed = random.nextInt();
 final int h1 = hash32.hash(bytes, 0, bytes.length, seed);
 final StreamingXXHash32 streamingHash32 = newStreamingHash32(seed);
 streamingHash32.update(bytes, 0, bytes.length);
 final int h2 = streamingHash32.getValue();
 final long h3 = hash64.hash(bytes, 0, bytes.length, seed);
 final StreamingXXHash64 streamingHash64 = newStreamingHash64(seed);
 streamingHash64.update(bytes, 0, bytes.length);
 final long h4 = streamingHash64.getValue();
 if (h1 != h2) {
  throw new AssertionError();
 }
 if (h3 != h4) {
  throw new AssertionError();
 }
}

代码示例来源:origin: com.orientechnologies/orientdb-core

final long hash = xxHash64.hash(buffer, XX_SEED);

代码示例来源:origin: com.yahoo.vespa/filedistribution

void receive(FileReference reference, String filename, byte[] content) {
    log.log(LogLevel.INFO, "Preparing receive call for " + reference.value() + " and file " + filename);
    XXHash64 hasher = XXHashFactory.fastestInstance().hash64();
    Request fileBlob = new Request("filedistribution.receiveFile");
    log.log(LogLevel.INFO, "Calling " + fileBlob.methodName() + " with target " + target);
    fileBlob.parameters().add(new StringValue(reference.value()));
    fileBlob.parameters().add(new StringValue(filename));
    fileBlob.parameters().add(new DataValue(content));
    fileBlob.parameters().add(new Int64Value(hasher.hash(ByteBuffer.wrap(content), 0)));
    fileBlob.parameters().add(new Int32Value(0));
    fileBlob.parameters().add(new StringValue("OK"));
    log.log(LogLevel.INFO, "Doing invokeSync");
    target.invokeSync(fileBlob, 5);
    log.log(LogLevel.INFO, "Done with invokeSync");
  }
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com