Search in sources :

Example 16 with IElement

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

the class InitDynamicNbrs method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
    // Get nodes and features
    ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
    long[] nodeIds = split.getKeys();
    IElement[] neighbors = split.getValues();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            LongArrayElement data = (LongArrayElement) neighbors[i];
            DynamicNeighborElement ele = (DynamicNeighborElement) row.get(nodeIds[i]);
            if (ele == null) {
                ele = new DynamicNeighborElement();
                ele.add(data.getData());
                row.set(nodeIds[i], ele);
            } else {
                ele.add(data.getData());
            }
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) GeneralPartUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam) DynamicNeighborElement(com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement) LongArrayElement(com.tencent.angel.ps.storage.vector.element.LongArrayElement) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Example 17 with IElement

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

the class ElementElementMapStorage method deserialize.

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

Example 18 with IElement

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

the class StringElementMapStorage method deserialize.

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

Example 19 with IElement

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

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 0);
    LongArrayList ret = new LongArrayList();
    row.startRead();
    try {
        ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
        while (it.hasNext()) {
            Long2ObjectMap.Entry<IElement> entry = it.next();
            ret.add(entry.getLongKey() + partParam.getPartKey().getStartCol());
        }
    } finally {
        row.endRead();
    }
    return new IndexPartGetLongResult(part.getPartitionKey(), ret.toLongArray());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) IElement(com.tencent.angel.ps.storage.vector.element.IElement) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 20 with IElement

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

the class GetSort method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
    ServerLongAnyRow row = (ServerLongAnyRow) part.getRow(0);
    ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.getStorage().iterator();
    row.startWrite();
    try {
        while (it.hasNext()) {
            Long2ObjectMap.Entry<IElement> next = it.next();
            DynamicNeighborElement ele = (DynamicNeighborElement) next.getValue();
            if (ele != null) {
                ele.trans();
            }
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) DynamicNeighborElement(com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

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