org.apache.hadoop.hbase.util.Hash.hash()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(119)

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

Hash.hash介绍

[英]Calculate a hash using bytes from HashKey and the provided seed value.
[中]使用HashKey中的字节和提供的种子值计算哈希。

代码示例

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

private static <T> boolean contains(ByteBuff bloomBuf, int bloomOffset, int bloomSize, Hash hash,
  int hashCount, HashKey<T> hashKey) {
 int hash1 = hash.hash(hashKey, 0);
 int bloomBitSize = bloomSize << 3;
 int hash2 = 0;
 int compositeHash = 0;
 if (randomGeneratorForTest == null) {
  // Production mode
  compositeHash = hash1;
  hash2 = hash.hash(hashKey, hash1);
 }
 for (int i = 0; i < hashCount; i++) {
  int hashLoc = (randomGeneratorForTest == null
    // Production mode
    ? Math.abs(compositeHash % bloomBitSize)
    // Test mode with "fake look-ups" to estimate "ideal false positive rate"
    : randomGeneratorForTest.nextInt(bloomBitSize));
  compositeHash += hash2;
  if (!checkBit(hashLoc, bloomBuf, bloomOffset)) {
   return false;
  }
 }
 return true;
}

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

public void add(Cell cell) {
 /*
  * For faster hashing, use combinatorial generation
  * http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf
  */
 int hash1;
 int hash2;
 HashKey<Cell> hashKey;
 if (this.bloomType == BloomType.ROWCOL) {
  hashKey = new RowColBloomHashKey(cell);
  hash1 = this.hash.hash(hashKey, 0);
  hash2 = this.hash.hash(hashKey, hash1);
 } else {
  hashKey = new RowBloomHashKey(cell);
  hash1 = this.hash.hash(hashKey, 0);
  hash2 = this.hash.hash(hashKey, hash1);
 }
 setHashLoc(hash1, hash2);
}

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

/**
 * @return the encodedName
 */
@InterfaceAudience.Private
static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
  regionName.length - MD5_HEX_LENGTH - 1,
  MD5_HEX_LENGTH);
 } else {
  // old format region name. First hbase:meta region also
  // use this format.EncodedName is the JenkinsHash value.
  HashKey<byte[]> key = new ByteArrayHashKey(regionName, 0, regionName.length);
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(key, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

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

LOG.info("Client=" + j + ", input=" + s);
byte[] b = Bytes.toBytes(s);
int hash = h.hash(new ByteArrayHashKey(b, 0, b.length), -1);
m.put(hash, s);

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

", noOfTags=" + this.noOfTags;
byte[] b = Bytes.toBytes(s);
int hash = h.hash(new ByteArrayHashKey(b, 0, b.length), -1);
m.put(hash, s);

代码示例来源:origin: org.apache.hbase/hbase-client

/**
 * @return the encodedName
 */
@InterfaceAudience.Private
static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
  regionName.length - MD5_HEX_LENGTH - 1,
  MD5_HEX_LENGTH);
 } else {
  // old format region name. First hbase:meta region also
  // use this format.EncodedName is the JenkinsHash value.
  HashKey<byte[]> key = new ByteArrayHashKey(regionName, 0, regionName.length);
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(key, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Calculate a hash using bytes from 0 to <code>length</code>, and
 * the provided seed value
 * @param bytes input bytes
 * @param length length of the valid bytes after offset to consider
 * @param initval seed value
 * @return hash value
 */
public int hash(byte[] bytes, int length, int initval) {
 return hash(bytes, 0, length, initval);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Calculate a hash using all bytes from the input argument,
 * and a provided seed value.
 * @param bytes input bytes
 * @param initval seed value
 * @return hash value
 */
public int hash(byte[] bytes, int initval) {
 return hash(bytes, 0, bytes.length, initval);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Calculate a hash using all bytes from the input argument, and
 * a seed of -1.
 * @param bytes input bytes
 * @return hash value
 */
public int hash(byte[] bytes) {
 return hash(bytes, bytes.length, -1);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Calculate a hash using all bytes from the input argument,
 * and a provided seed value.
 * @param bytes input bytes
 * @param initval seed value
 * @return hash value
 */
public int hash(byte[] bytes, int initval) {
 return hash(bytes, 0, bytes.length, initval);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Calculate a hash using all bytes from the input argument, and
 * a seed of -1.
 * @param bytes input bytes
 * @return hash value
 */
public int hash(byte[] bytes) {
 return hash(bytes, bytes.length, -1);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Calculate a hash using bytes from 0 to <code>length</code>, and
 * the provided seed value
 * @param bytes input bytes
 * @param length length of the valid bytes after offset to consider
 * @param initval seed value
 * @return hash value
 */
public int hash(byte[] bytes, int length, int initval) {
 return hash(bytes, 0, length, initval);
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws IOException 
  Hash hasher = new Hash();
  ...
      if (file.toString().endsWith(".raw")) {
        hasher.hash(file);
      }
  ...
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void add(byte [] buf, int offset, int len) {
 /*
  * For faster hashing, use combinatorial generation
  * http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf
  */
 int hash1 = this.hash.hash(buf, offset, len, 0);
 int hash2 = this.hash.hash(buf, offset, len, hash1);
 for (int i = 0; i < this.hashCount; i++) {
  long hashLoc = Math.abs((hash1 + i * hash2) % (this.byteSize * 8));
  set(hashLoc);
 }
 ++this.keyCount;
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
public void add(byte [] buf, int offset, int len) {
 /*
  * For faster hashing, use combinatorial generation
  * http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf
  */
 int hash1 = this.hash.hash(buf, offset, len, 0);
 int hash2 = this.hash.hash(buf, offset, len, hash1);
 for (int i = 0; i < this.hashCount; i++) {
  long hashLoc = Math.abs((hash1 + i * hash2) % (this.byteSize * 8));
  set(hashLoc);
 }
 ++this.keyCount;
}

代码示例来源:origin: alibaba/wasp

/**
 * @param entityGroupName
 * @return the encodedName
 */
public static String encodeEntityGroupName(final byte[] entityGroupName) {
 String encodedName;
 if (hasEncodedName(entityGroupName)) {
  // entityGroup is in new format:
  // <tableName>,<startKey>,<entityGroupIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(entityGroupName, entityGroupName.length
    - MD5_HEX_LENGTH - 1, MD5_HEX_LENGTH);
 } else {
  // old format entityGroup name. first META entityGroup also
  // use this format.EncodedName is the JenkinsHash value.
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(entityGroupName,
    entityGroupName.length, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * @param regionName
 * @return the encodedName
 */
public static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
    regionName.length - MD5_HEX_LENGTH - 1,
    MD5_HEX_LENGTH);
 } else {
  // old format region name. ROOT and first META region also 
  // use this format.EncodedName is the JenkinsHash value.
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(regionName,
   regionName.length, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * @param regionName
 * @return the encodedName
 */
public static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
    regionName.length - MD5_HEX_LENGTH - 1,
    MD5_HEX_LENGTH);
 } else {
  // old format region name. ROOT and first META region also
  // use this format.EncodedName is the JenkinsHash value.
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(regionName,
   regionName.length, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

代码示例来源:origin: harbby/presto-connectors

/**
 * @param regionName
 * @return the encodedName
 */
public static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
    regionName.length - MD5_HEX_LENGTH - 1,
    MD5_HEX_LENGTH);
 } else {
  // old format region name. First hbase:meta region also
  // use this format.EncodedName is the JenkinsHash value.
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(regionName,
   regionName.length, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
 * @return the encodedName
 */
@InterfaceAudience.Private
static String encodeRegionName(final byte [] regionName) {
 String encodedName;
 if (hasEncodedName(regionName)) {
  // region is in new format:
  // <tableName>,<startKey>,<regionIdTimeStamp>/encodedName/
  encodedName = Bytes.toString(regionName,
  regionName.length - MD5_HEX_LENGTH - 1,
  MD5_HEX_LENGTH);
 } else {
  // old format region name. First hbase:meta region also
  // use this format.EncodedName is the JenkinsHash value.
  HashKey<byte[]> key = new ByteArrayHashKey(regionName, 0, regionName.length);
  int hashVal = Math.abs(JenkinsHash.getInstance().hash(key, 0));
  encodedName = String.valueOf(hashVal);
 }
 return encodedName;
}

相关文章

微信公众号

最新文章

更多