Search in sources :

Example 1 with IntElementMapStorage

use of com.tencent.angel.ps.storage.vector.storage.IntElementMapStorage 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)

Aggregations

IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 IntArrayElementStorage (com.tencent.angel.ps.storage.vector.storage.IntArrayElementStorage)1 IntElementMapStorage (com.tencent.angel.ps.storage.vector.storage.IntElementMapStorage)1 IntElementStorage (com.tencent.angel.ps.storage.vector.storage.IntElementStorage)1 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)1 Entry (java.util.Map.Entry)1