@Override public long longHash(String s, LongHashFunction hashFunction, int off, int len) { char[] value = (char[]) UnsafeAccess.UNSAFE.getObject(s, valueOffset); return hashFunction.hashChars(value, off, len); } }
@Override public long longHash(String s, LongHashFunction hashFunction, int off, int len) { char[] value = (char[]) UnsafeAccess.UNSAFE.getObject(s, valueOffset); int offset = UnsafeAccess.UNSAFE.getInt(s, offsetOffset); return hashFunction.hashChars(value, offset + off, len); } }
@Override public long hashLong(String[] keyTokens) { StringBuilder concatenatedKeys = new StringBuilder(); for (int i = 0; i < keyTokens.length; i++) { concatenatedKeys.append(keyTokens[i]); } return hashFunction.hashChars(concatenatedKeys.toString()); } }
/** * Perform xxHash64 hashing on a string. * * @param str - The string to be hashed. * @return String - The hex representation of the hash value. */ private static String performXxHash64(String str) { return Long.toHexString(LongHashFunction.xx_r39().hashChars(str)); } }
public ScopeAndMetricOnlySchemaRecordList(List<ScopeAndMetricOnlySchemaRecord> records, HashAlgorithm algorithm) { for(ScopeAndMetricOnlySchemaRecord record : records) { String id = null; String scopeAndMetricName = ScopeAndMetricOnlySchemaRecord.getFieldsAsString(record); if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(scopeAndMetricName); } else { id = String.valueOf(LongHashFunction.xx().hashChars(scopeAndMetricName)); } _idToSchemaRecordMap.put(id, record); } }
public ScopeOnlySchemaRecordList(List<ScopeOnlySchemaRecord> records, HashAlgorithm algorithm) { for(ScopeOnlySchemaRecord record : records) { String id = null; String scopeOnly = record.getScope(); if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(scopeOnly); } else { id = String.valueOf(LongHashFunction.xx().hashChars(scopeOnly)); } _idToSchemaRecordMap.put(id, record); } }
public ScopeOnlySchemaRecordList(List<ScopeOnlySchemaRecord> records, HashAlgorithm algorithm) { for(ScopeOnlySchemaRecord record : records) { String id = null; String scopeOnly = record.getScope(); if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(scopeOnly); } else { id = String.valueOf(LongHashFunction.xx().hashChars(scopeOnly)); } _idToSchemaRecordMap.put(id, record); } }
public ScopeAndMetricOnlySchemaRecordList(List<ScopeAndMetricOnlySchemaRecord> records, HashAlgorithm algorithm) { for(ScopeAndMetricOnlySchemaRecord record : records) { String id = null; String scopeAndMetricName = ScopeAndMetricOnlySchemaRecord.getFieldsAsString(record); if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(scopeAndMetricName); } else { id = String.valueOf(LongHashFunction.xx().hashChars(scopeAndMetricName)); } _idToSchemaRecordMap.put(id, record); } }
@Override default long hashCode64(int rowIndex, LongHashFunction hash) { assert !isMissing(rowIndex); //noinspection ConstantConditions return hash.hashChars(this.getString(rowIndex)); }
public MetatagsSchemaRecordList(List<MetatagsRecord> records, HashAlgorithm algorithm) { for(MetatagsRecord record : records) { String id = null; if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(record.getKey()); } else { id = String.valueOf(LongHashFunction.xx().hashChars(record.getKey())); } _idToSchemaRecordMap.put(id, record); } }
public MetatagsSchemaRecordList(List<MetatagsRecord> records, HashAlgorithm algorithm) { for(MetatagsRecord record : records) { String id = null; if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(record.getKey()); } else { id = String.valueOf(LongHashFunction.xx().hashChars(record.getKey())); } _idToSchemaRecordMap.put(id, record); } }
public MetricSchemaRecordList(List<MetricSchemaRecord> records, HashAlgorithm algorithm) { for(MetricSchemaRecord record : records) { String id = null; if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(MetricSchemaRecord.print(record)); } else { id = String.valueOf(LongHashFunction.xx().hashChars(MetricSchemaRecord.print(record))); } _idToSchemaRecordMap.put(id, record); } }
public MetricSchemaRecordList(List<MetricSchemaRecord> records, HashAlgorithm algorithm) { for(MetricSchemaRecord record : records) { String id = null; if(HashAlgorithm.MD5.equals(algorithm)) { id = DigestUtils.md5Hex(MetricSchemaRecord.print(record)); } else { id = String.valueOf(LongHashFunction.xx().hashChars(MetricSchemaRecord.print(record))); } _idToSchemaRecordMap.put(id, record); } }
private long computeHash(final Endpoint endpoint) { return hashFunction.hashChars(endpoint.getHostname()) * 31 + hashFunction.hashInt(endpoint.getPort()); }
@Override @SuppressWarnings("ConstantConditions") public long hashCode64(int rowIndex, LongHashFunction hash) { assert !isMissing(rowIndex); switch (this.description.kind) { case String: case Json: return hash.hashChars(this.getString(rowIndex)); case Integer: return hash.hashInt(this.getInt(rowIndex)); case Date: case Double: case Duration: return hash.hashLong(Double.doubleToRawLongBits(this.asDouble(rowIndex))); default: throw new RuntimeException("Unexpected kind " + this.description.kind); } }
@Override public long hashCode64(int rowIndex, LongHashFunction hash) { if (this.isMissing(rowIndex)) return MISSING_HASH_VALUE; switch (ObjectArrayColumn.this.description.kind) { case Json: case String: String str = this.getString(rowIndex); assert str != null; return hash.hashChars(str); case Date: Instant inst = this.getDate(rowIndex); assert inst != null; return hash.hashLong(Double.doubleToLongBits(Converters.toDouble(inst))); case Integer: return hash.hashInt(this.getInt(rowIndex)); case Double: return hash.hashLong(Double.doubleToLongBits(this.getDouble(rowIndex))); case Duration: Duration d = this.getDuration(rowIndex); assert d != null; return hash.hashLong(Double.doubleToLongBits(Converters.toDouble(d))); default: throw new RuntimeException("Unexpected data type"); } } }
static long getConfigurationId(final Collection<NodeId> identifiers, final Collection<Endpoint> endpoints) { long hash = 1; for (final NodeId id: identifiers) { hash = hash * 37 + HASH_FUNCTION.hashLong(id.getHigh()); hash = hash * 37 + HASH_FUNCTION.hashLong(id.getLow()); } for (final Endpoint endpoint : endpoints) { hash = hash * 37 + HASH_FUNCTION.hashChars(endpoint.getHostname()); hash = hash * 37 + HASH_FUNCTION.hashInt(endpoint.getPort()); } return hash; } }