Search in sources :

Example 1 with IIntKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.IIntKeyPartOp in project angel by Tencent.

the class ServerRowUtils method getByKeys.

public static ValuePart getByKeys(ServerRow row, KeyPart keyPart) {
    ValuePart result;
    if (keyPart instanceof IIntKeyPartOp) {
        // Index is int
        IIntKeyPartOp intKeyPart = (IIntKeyPartOp) keyPart;
        if (row instanceof ServerIntFloatRow) {
            float[] values = ((ServerIntFloatRow) row).get(intKeyPart.getKeys());
            result = new FloatValuesPart(values);
        } else if (row instanceof ServerIntDoubleRow) {
            double[] values = ((ServerIntDoubleRow) row).get(intKeyPart.getKeys());
            result = new DoubleValuesPart(values);
        } else if (row instanceof ServerIntIntRow) {
            int[] values = ((ServerIntIntRow) row).get(intKeyPart.getKeys());
            result = new IntValuesPart(values);
        } else if (row instanceof ServerIntLongRow) {
            long[] values = ((ServerIntLongRow) row).get(intKeyPart.getKeys());
            result = new LongValuesPart(values);
        } else {
            throw new UnsupportedOperationException("Unsupport row type " + row.getClass().getName());
        }
    } else if (keyPart instanceof ILongKeyPartOp) {
        // Index is long
        ILongKeyPartOp longKeyPart = (ILongKeyPartOp) keyPart;
        if (row instanceof ServerLongFloatRow) {
            float[] values = ((ServerLongFloatRow) row).get(longKeyPart.getKeys());
            result = new FloatValuesPart(values);
        } else if (row instanceof ServerLongDoubleRow) {
            double[] values = ((ServerLongDoubleRow) row).get(longKeyPart.getKeys());
            result = new DoubleValuesPart(values);
        } else if (row instanceof ServerLongIntRow) {
            int[] values = ((ServerLongIntRow) row).get(longKeyPart.getKeys());
            result = new IntValuesPart(values);
        } else if (row instanceof ServerLongLongRow) {
            long[] values = ((ServerLongLongRow) row).get(longKeyPart.getKeys());
            result = new LongValuesPart(values);
        } else {
            throw new UnsupportedOperationException("Unsupport row type " + row.getClass().getName());
        }
    } else {
        throw new UnsupportedOperationException("Unsupport index type " + keyPart.getClass().getName());
    }
    return result;
}
Also used : FloatValuesPart(com.tencent.angel.psagent.matrix.transport.router.value.FloatValuesPart) ValuePart(com.tencent.angel.psagent.matrix.transport.router.ValuePart) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp) LongValuesPart(com.tencent.angel.psagent.matrix.transport.router.value.LongValuesPart) IIntKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.IIntKeyPartOp) IntValuesPart(com.tencent.angel.psagent.matrix.transport.router.value.IntValuesPart) DoubleValuesPart(com.tencent.angel.psagent.matrix.transport.router.value.DoubleValuesPart)

Aggregations

ValuePart (com.tencent.angel.psagent.matrix.transport.router.ValuePart)1 IIntKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.IIntKeyPartOp)1 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)1 DoubleValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.DoubleValuesPart)1 FloatValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.FloatValuesPart)1 IntValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.IntValuesPart)1 LongValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.LongValuesPart)1