8000 [sona] enable PartitionSourceArray by sagewe · Pull Request #479 · Angel-ML/angel · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class ServerPartition implements Serialize {
/**
* Row index to server row map
*/
private final PartitionSource rows;
private PartitionSource rows;

private String PartitionSourceClassName;

/**
* Partition key
Expand Down Expand Up @@ -257,6 +259,10 @@ public void reset() {
return;
}

byte[] bytes = this.PartitionSourceClassName.getBytes();
buf.writeInt(bytes.length);
buf.writeBytes(bytes);

partitionKey.serialize(buf);
buf.writeInt(rowType.getNumber());
buf.writeInt(rows.rowNum());
Expand All @@ -270,6 +276,17 @@ public void reset() {
}

@Override public void deserialize(ByteBuf buf) {
int size = buf.readInt();
byte[] bytes = new byte[size];
buf.readBytes(bytes);
this.PartitionSourceClassName = new String(bytes);
try {
rows = (PartitionSource) Class.forName(this.PartitionSourceClassName).newInstance();
} catch (Throwable e) {
LOG.error("Can not init partition source for type " + this.PartitionSourceClassName + " use default instead ",
e);
rows = new PartitionSourceMap();
}
partitionKey = new PartitionKey();
partitionKey.deserialize(buf);
rowType = RowType.valueOf(buf.readInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.tencent.angel.psagent.matrix.cache;

import com.tencent.angel.PartitionKey;
import com.tencent.angel.conf.AngelConf;
import com.tencent.angel.ml.matrix.MatrixMeta;
import com.tencent.angel.ps.storage.matrix.PartitionSourceMap;
import com.tencent.angel.ps.storage.matrix.ServerPartition;
Expand Down Expand Up @@ -123,8 +124,10 @@ public void update(PartitionKey partKey, ServerRow rowSplit) {
ServerPartition partCache = partitionCacheMap.get(partKey);
if (partCache == null) {
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
String partitionSource = matrixMeta.getAttribute(AngelConf.ANGEL_PS_PARTITION_SOURCE_CLASS,
AngelConf.DEFAULT_ANGEL_PS_PARTITION_SOURCE_CLASS);
partitionCacheMap
.putIfAbsent(partKey, new ServerPartition(partKey, matrixMeta.getRowType(), 0));
.putIfAbsent(partKey, new ServerPartition(partKey, matrixMeta.getRowType(), 0, partitionSource));
partCache = partitionCacheMap.get(partKey);
}

Expand All @@ -141,8 +144,10 @@ public void update(PartitionKey partKey, List<ServerRow> rowsSplit) {
ServerPartition partCache = partitionCacheMap.get(partKey);
if (partCache == null) {
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
String partitionSource = matrixMeta.getAttribute(AngelConf.ANGEL_PS_PARTITION_SOURCE_CLASS,
AngelConf.DEFAULT_ANGEL_PS_PARTITION_SOURCE_CLASS);
partitionCacheMap
.putIfAbsent(partKey, new ServerPartition(partKey, matrixMeta.getRowType(), 0));
.putIfAbsent(partKey, new ServerPartition(partKey, matrixMeta.getRowType(), 0, partitionSource));
partCache = partitionCacheMap.get(partKey);
}

Expand Down
0