@Override default long hashCode64(int rowIndex, LongHashFunction hash) { assert !this.isMissing(rowIndex); return hash.hashInt(this.getInt(rowIndex)); }
private int getIndex(int key, Set<T> excludes) { float minDistance = Float.MAX_VALUE; int index = 0; for (int i = 0; i < _numProbes; i++) { long hash = _hashFunctions[i].hashInt(key) & MASK; for (int j = 0; j < _buckets.size(); j++) { Bucket bucket = _buckets.get(j); if (!excludes.contains(bucket.getT())) { float distance = Math.abs(bucket.getHash() - hash) / (float) bucket.getPoints(); if (distance < minDistance) { minDistance = distance; index = j; } } } } return index; }
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; } }