Search in sources :

Example 61 with IntFloatVector

use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.

the class GraphNode method deepClone.

@Override
public GraphNode deepClone() {
    IntFloatVector cloneFeats = null;
    if (feats != null) {
        cloneFeats = feats.clone();
    }
    long[] cloneNeighbors = null;
    if (neighbors != null) {
        cloneNeighbors = new long[neighbors.length];
        System.arraycopy(neighbors, 0, cloneNeighbors, 0, neighbors.length);
    }
    int[] cloneTypes = null;
    if (types != null) {
        cloneTypes = new int[types.length];
        System.arraycopy(types, 0, cloneTypes, 0, types.length);
    }
    int[] cloneEdgeTypes = null;
    if (edgeTypes != null) {
        cloneEdgeTypes = new int[edgeTypes.length];
        System.arraycopy(edgeTypes, 0, cloneEdgeTypes, 0, edgeTypes.length);
    }
    IntFloatVector[] cloneEdgeFeatures = null;
    if (edgeFeatures != null) {
        cloneEdgeFeatures = new IntFloatVector[edgeFeatures.length];
        System.arraycopy(edgeFeatures, 0, cloneEdgeFeatures, 0, edgeFeatures.length);
    }
    float[] cloneWeights = null;
    if (weights != null) {
        cloneWeights = new float[weights.length];
        System.arraycopy(weights, 0, cloneWeights, 0, weights.length);
    }
    float[] cloneLables = null;
    if (labels != null) {
        cloneLables = new float[labels.length];
        System.arraycopy(labels, 0, cloneLables, 0, labels.length);
    }
    return new GraphNode(cloneFeats, cloneNeighbors, cloneTypes, cloneEdgeTypes, cloneEdgeFeatures, cloneWeights, cloneLables);
}
Also used : IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 62 with IntFloatVector

use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.

the class GraphNode method serialize.

@Override
public void serialize(DataOutputStream output) throws IOException {
    if (feats != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeVector(output, feats);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (neighbors != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeLongs(output, neighbors);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (types != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeInts(output, types);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (edgeTypes != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeInts(output, edgeTypes);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (edgeFeatures != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeInt(output, edgeFeatures.length);
        for (IntFloatVector edgeFeature : edgeFeatures) {
            StreamSerdeUtils.serializeVector(output, edgeFeature);
        }
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (weights != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeFloats(output, weights);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
    if (labels != null) {
        StreamSerdeUtils.serializeInt(output, 1);
        StreamSerdeUtils.serializeFloats(output, labels);
    } else {
        StreamSerdeUtils.serializeInt(output, 0);
    }
}
Also used : IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 63 with IntFloatVector

use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.

the class GraphNode method serialize.

@Override
public void serialize(ByteBuf output) {
    if (feats != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeVector(output, feats);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (neighbors != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeLongs(output, neighbors);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (types != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeInts(output, types);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (edgeTypes != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeInts(output, edgeTypes);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (edgeFeatures != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeInt(output, edgeFeatures.length);
        for (IntFloatVector edgeFeature : edgeFeatures) {
            ByteBufSerdeUtils.serializeVector(output, edgeFeature);
        }
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (weights != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeFloats(output, weights);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
    if (labels != null) {
        ByteBufSerdeUtils.serializeInt(output, 1);
        ByteBufSerdeUtils.serializeFloats(output, labels);
    } else {
        ByteBufSerdeUtils.serializeInt(output, 0);
    }
}
Also used : IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 64 with IntFloatVector

use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.

the class PartSampleNodeFeatResult method serialize.

@Override
public void serialize(ByteBuf output) {
    ByteBufSerdeUtils.serializeInt(output, partId);
    ByteBufSerdeUtils.serializeInt(output, feats.length);
    for (IntFloatVector feat : feats) {
        if (feat == null) {
            ByteBufSerdeUtils.serializeBoolean(output, true);
        } else {
            ByteBufSerdeUtils.serializeBoolean(output, false);
            ByteBufSerdeUtils.serializeVector(output, feat);
        }
    }
}
Also used : IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 65 with IntFloatVector

use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
    ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
    FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
    long[] ret;
    if (ranksVector instanceof IntFloatVector)
        ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else if (ranksVector instanceof LongFloatVector)
        ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else {
        throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
    }
    return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
Also used : AngelException(com.tencent.angel.exception.AngelException) IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) FloatVector(com.tencent.angel.ml.math2.vector.FloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Aggregations

IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)104 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)60 Int2FloatMap (it.unimi.dsi.fastutil.ints.Int2FloatMap)57 IntFloatVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatVectorStorage)50 CompIntFloatVector (com.tencent.angel.ml.math2.vector.CompIntFloatVector)34 IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)33 IntIntVectorStorage (com.tencent.angel.ml.math2.storage.IntIntVectorStorage)32 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)32 IntFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage)31 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)30 LongFloatVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatVectorStorage)30 LongIntVectorStorage (com.tencent.angel.ml.math2.storage.LongIntVectorStorage)30 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)30 Storage (com.tencent.angel.ml.math2.storage.Storage)30 IntFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSortedVectorStorage)25 IntDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)21 AngelException (com.tencent.angel.exception.AngelException)20 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)20 IntIntSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSortedVectorStorage)20 IntIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSparseVectorStorage)20