use of com.tencent.angel.psagent.matrix.transport.router.KeyHash in project angel by Tencent.
the class HashRouterUtils method computeHashCode.
private static int[] computeHashCode(MatrixMeta matrixMeta, IElement[] keys) {
Class<? extends KeyHash> hashClass = matrixMeta.getRouterHash();
KeyHash hasher = HasherFactory.getHasher(hashClass);
int[] hashCodes = new int[keys.length];
for (int i = 0; i < keys.length; i++) {
hashCodes[i] = computeHashCode(hasher, keys[i]);
}
return hashCodes;
}
use of com.tencent.angel.psagent.matrix.transport.router.KeyHash in project angel by Tencent.
the class HashRouterUtils method computeHashCode.
private static int[] computeHashCode(MatrixMeta matrixMeta, int[] keys) {
Class<? extends KeyHash> hashClass = matrixMeta.getRouterHash();
KeyHash hasher = HasherFactory.getHasher(hashClass);
int[] hashCodes = new int[keys.length];
for (int i = 0; i < keys.length; i++) {
hashCodes[i] = computeHashCode(hasher, keys[i]);
}
return hashCodes;
}
use of com.tencent.angel.psagent.matrix.transport.router.KeyHash in project angel by Tencent.
the class HasherFactory method getHasher.
public static KeyHash getHasher(Class hasherClass) {
KeyHash hasher = hasherCache.get(hasherClass);
if (hasher == null) {
try {
KeyHash newHasher = (KeyHash) hasherClass.newInstance();
hasher = hasherCache.putIfAbsent(hasherClass, newHasher);
if (hasher == null) {
hasher = hasherCache.get(hasherClass);
}
} catch (Throwable e) {
throw new RuntimeException("Can not init hash class " + hasherClass, e);
}
}
return hasher;
}
use of com.tencent.angel.psagent.matrix.transport.router.KeyHash in project angel by Tencent.
the class HashRouterUtils method computeHashCode.
private static int[] computeHashCode(MatrixMeta matrixMeta, long[] keys) {
Class<? extends KeyHash> hashClass = matrixMeta.getRouterHash();
KeyHash hasher = HasherFactory.getHasher(hashClass);
int[] hashCodes = new int[keys.length];
for (int i = 0; i < keys.length; i++) {
hashCodes[i] = computeHashCode(hasher, keys[i]);
}
return hashCodes;
}
use of com.tencent.angel.psagent.matrix.transport.router.KeyHash in project angel by Tencent.
the class HashRouterUtils method computeHashCode.
private static int[] computeHashCode(MatrixMeta matrixMeta, String[] keys) {
Class<? extends KeyHash> hashClass = matrixMeta.getRouterHash();
KeyHash hasher = HasherFactory.getHasher(hashClass);
int[] hashCodes = new int[keys.length];
for (int i = 0; i < keys.length; i++) {
hashCodes[i] = computeHashCode(hasher, keys[i]);
}
return hashCodes;
}
Aggregations