Search in sources :

Example 1 with IElement

use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.

the class ComplexRowFormat method save.

private void save(ServerIntAnyRow row, PSMatrixSaveContext saveContext, MatrixPartitionMeta partMeta, DataOutputStream output) throws IOException {
    IntElementStorage storage = row.getStorage();
    long startPos = partMeta.getStartCol();
    if (storage instanceof IntArrayElementStorage) {
        IElement[] data = ((IntArrayElementStorage) storage).getData();
        for (int i = 0; i < data.length; i++) {
            save(i + startPos, data[i], output);
        }
    } else if (storage instanceof IntElementMapStorage) {
        Int2ObjectOpenHashMap<IElement> data = ((IntElementMapStorage) storage).getData();
        ObjectIterator<Int2ObjectMap.Entry<IElement>> iter = data.int2ObjectEntrySet().fastIterator();
        while (iter.hasNext()) {
            Int2ObjectMap.Entry<IElement> entry = iter.next();
            save(entry.getIntKey() + startPos, entry.getValue(), output);
        }
    }
}
Also used : Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) IElement(com.tencent.angel.ps.storage.vector.element.IElement) Entry(java.util.Map.Entry) IntArrayElementStorage(com.tencent.angel.ps.storage.vector.storage.IntArrayElementStorage) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) IntElementMapStorage(com.tencent.angel.ps.storage.vector.storage.IntElementMapStorage) IntElementStorage(com.tencent.angel.ps.storage.vector.storage.IntElementStorage) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator)

Example 2 with IElement

use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.

the class ComplexRowFormat method save.

private void save(ServerLongAnyRow row, PSMatrixSaveContext saveContext, MatrixPartitionMeta partMeta, DataOutputStream output) throws IOException {
    LongElementStorage storage = row.getStorage();
    ObjectIterator<Long2ObjectMap.Entry<IElement>> iter = storage.iterator();
    long startPos = partMeta.getStartCol();
    while (iter.hasNext()) {
        Long2ObjectMap.Entry<IElement> entry = iter.next();
        save(entry.getLongKey() + startPos, entry.getValue(), output);
    }
}
Also used : Entry(java.util.Map.Entry) IElement(com.tencent.angel.ps.storage.vector.element.IElement) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) LongElementStorage(com.tencent.angel.ps.storage.vector.storage.LongElementStorage)

Example 3 with IElement

use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.

the class ComplexRowFormat method save.

private void save(ServerStringAnyRow row, PSMatrixSaveContext saveContext, MatrixPartitionMeta partMeta, DataOutputStream output) throws IOException {
    StringElementStorage storage = row.getStorage();
    ObjectIterator<Object2ObjectMap.Entry<String, IElement>> iter = storage.iterator();
    while (iter.hasNext()) {
        Object2ObjectMap.Entry<String, IElement> entry = iter.next();
        save(entry.getKey(), entry.getValue(), output);
    }
}
Also used : Entry(java.util.Map.Entry) IElement(com.tencent.angel.ps.storage.vector.element.IElement) Object2ObjectMap(it.unimi.dsi.fastutil.objects.Object2ObjectMap) StringElementStorage(com.tencent.angel.ps.storage.vector.storage.StringElementStorage)

Example 4 with IElement

use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.

the class IntElementMapStorage method deserialize.

@Override
public void deserialize(ByteBuf buf) {
    super.deserialize(buf);
    // Valid element number
    int elementNum = buf.readInt();
    data = new Int2ObjectOpenHashMap<>(elementNum);
    // Deserialize the data
    for (int i = 0; i < elementNum; i++) {
        IElement element = newElement();
        data.put(buf.readInt(), element);
        element.deserialize(buf);
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement)

Example 5 with IElement

use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.

the class IntElementMapStorage method deserialize.

@Override
public void deserialize(DataInputStream input) throws IOException {
    super.deserialize(input);
    // Valid element number
    int elementNum = input.readInt();
    data = new Int2ObjectOpenHashMap<>(elementNum);
    // Deserialize the data
    for (int i = 0; i < elementNum; i++) {
        IElement element = newElement();
        data.put(input.readInt(), element);
        element.deserialize(input);
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement)

Aggregations

IElement (com.tencent.angel.ps.storage.vector.element.IElement)38 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)19 ILongKeyAnyValuePartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)13 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)12 GraphNode (com.tencent.angel.graph.data.GraphNode)7 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)6 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)6 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)6 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)6 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)4 Entry (java.util.Map.Entry)4 GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)3 DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)3 Object2ObjectMap (it.unimi.dsi.fastutil.objects.Object2ObjectMap)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1 PartitionKey (com.tencent.angel.PartitionKey)1 AngelException (com.tencent.angel.exception.AngelException)1 WalkPath (com.tencent.angel.graph.client.node2vec.data.WalkPath)1 GetElementResult (com.tencent.angel.graph.common.psf.result.GetElementResult)1 GetFloatsResult (com.tencent.angel.graph.common.psf.result.GetFloatsResult)1