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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations