org.apache.hadoop.hbase.util.Hash类的使用及代码示例

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

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

Hash介绍

[英]This class represents a common API for hashing functions.
[中]此类表示哈希函数的通用API。

代码示例

代码示例来源: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

/**
 * Get a singleton instance of hash function of a type
 * defined in the configuration.
 * @param conf current configuration
 * @return defined hash type, or null if type is invalid
 */
public static Hash getInstance(Configuration conf) {
 int type = getHashType(conf);
 return getInstance(type);
}

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

/**
 * This utility method converts the name of the configured
 * hash type to a symbolic constant.
 * @param conf configuration
 * @return one of the predefined constants
 */
public static int getHashType(Configuration conf) {
 String name = conf.get("hbase.hash.type", "murmur");
 return parseHashType(name);
}

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

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

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

public BloomFilterChunk(int hashType, BloomType bloomType) {
 this.hashType = hashType;
 this.hash = Hash.getInstance(hashType);
 this.bloomType = bloomType;
}

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

err, Hash.getHashType(conf), maxFold, cacheConf.shouldCacheBloomsOnWrite(),
  bloomType == BloomType.ROWCOL ? CellComparatorImpl.COMPARATOR : null, bloomType);
writer.addInlineBlockWriter(bloomWriter);

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

/**
 * Loads bloom filter meta data from file input.
 * @param meta stored bloom meta data
 * @throws IllegalArgumentException meta data is invalid
 */
public BloomFilterChunk(DataInput meta)
  throws IOException, IllegalArgumentException {
 this.byteSize = meta.readInt();
 this.hashCount = meta.readInt();
 this.hashType = meta.readInt();
 this.keyCount = meta.readInt();
 this.maxKeys = this.keyCount;
 this.hash = Hash.getInstance(this.hashType);
 if (hash == null) {
  throw new IllegalArgumentException("Invalid hash type: " + hashType);
 }
 sanityCheck();
}

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

err, Hash.getHashType(conf), maxFold, cacheConf.shouldCacheBloomsOnWrite(),
  null, BloomType.ROW);
writer.addInlineBlockWriter(bloomWriter);

代码示例来源: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: com.aliyun.hbase/alihbase-common

/**
 * Get a singleton instance of hash function of a type
 * defined in the configuration.
 * @param conf current configuration
 * @return defined hash type, or null if type is invalid
 */
public static Hash getInstance(Configuration conf) {
 int type = getHashType(conf);
 return getInstance(type);
}

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

hash = Hash.getInstance(hashType);
if (hash == null) {
 throw new IllegalArgumentException("Invalid hash type: " + hashType);

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

getBloomBlockSize(conf), err, Hash.getHashType(conf), maxFold,
  cacheConf.shouldCacheBloomsOnWrite(), bloomType == BloomType.ROWCOL
    ? KeyValue.KEY_COMPARATOR : Bytes.BYTES_RAWCOMPARATOR);
} else if (maxKeys < tooBig) {
 BloomFilterWriter bloom = new ByteBloomFilter((int) maxKeys, err,
   Hash.getHashType(conf), maxFold);
 bloom.allocBloom();
 return bloom;

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

/**
 * This utility method converts the name of the configured
 * hash type to a symbolic constant.
 * @param conf configuration
 * @return one of the predefined constants
 */
public static int getHashType(Configuration conf) {
 String name = conf.get("hbase.hash.type", "murmur");
 return parseHashType(name);
}

代码示例来源: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: org.apache.hbase/hbase-common

/**
 * Get a singleton instance of hash function of a type
 * defined in the configuration.
 * @param conf current configuration
 * @return defined hash type, or null if type is invalid
 */
public static Hash getInstance(Configuration conf) {
 int type = getHashType(conf);
 return getInstance(type);
}

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

/** Private constructor used by other constructors. */
private ByteBloomFilter(int hashType) {
 this.hashType = hashType;
 this.hash = Hash.getInstance(hashType);
}

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

getBloomBlockSize(conf), err, Hash.getHashType(conf),
maxFold,
cacheConf.shouldCacheBloomsOnWrite(), Bytes.BYTES_RAWCOMPARATOR);

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

/**
 * This utility method converts the name of the configured
 * hash type to a symbolic constant.
 * @param conf configuration
 * @return one of the predefined constants
 */
public static int getHashType(Configuration conf) {
 String name = conf.get("hbase.hash.type", "murmur");
 return parseHashType(name);
}

代码示例来源: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: co.cask.hbase/hbase

/**
 * Get a singleton instance of hash function of a type
 * defined in the configuration.
 * @param conf current configuration
 * @return defined hash type, or null if type is invalid
 */
public static Hash getInstance(Configuration conf) {
 int type = getHashType(conf);
 return getInstance(type);
}

相关文章

微信公众号

最新文章

更多