Search in sources :

Example 1 with KeyHash

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;
}
Also used : KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash)

Example 2 with KeyHash

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;
}
Also used : KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash)

Example 3 with KeyHash

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;
}
Also used : KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash)

Example 4 with KeyHash

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;
}
Also used : KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash)

Example 5 with KeyHash

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;
}
Also used : KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash)

Aggregations

KeyHash (com.tencent.angel.psagent.matrix.transport.router.KeyHash)6 PartitionKey (com.tencent.angel.PartitionKey)1 IntDoubleVector (com.tencent.angel.ml.math2.vector.IntDoubleVector)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)1 IntLongVector (com.tencent.angel.ml.math2.vector.IntLongVector)1 LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)1 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)1 LongIntVector (com.tencent.angel.ml.math2.vector.LongIntVector)1 LongLongVector (com.tencent.angel.ml.math2.vector.LongLongVector)1 CompStreamKeyValuePart (com.tencent.angel.psagent.matrix.transport.router.CompStreamKeyValuePart)1 KeyValuePart (com.tencent.angel.psagent.matrix.transport.router.KeyValuePart)1