use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.
the class MatrixRowGetTask method run.
@Override
public void run(TaskContext taskContext) throws AngelException {
try {
MatrixClient matrixClient = taskContext.getMatrix(MatrixRowGetTest.SPARSE_LONGKEY_FLOAT_MAT);
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(MatrixRowGetTest.SPARSE_LONGKEY_FLOAT_MAT);
long[] indices = genLongIndexs(matrixMeta.getColNum(), MatrixRowGetTest.longnnz);
long[] getIndices = genGetLongIndexs(indices, MatrixRowGetTest.nGet);
LongFloatVector deltatest = VFactory.sparseLongKeyFloatVector(matrixMeta.getColNum(), MatrixRowGetTest.longnnz);
for (int i = 0; i < MatrixRowGetTest.longnnz; i++) {
deltatest.set(indices[i], (float) (indices[i] * 1.3));
}
deltatest.setRowId(0);
LOG.info(" delta use " + deltatest.getType() + " type storage");
int updateTime = 0;
long startTs = System.currentTimeMillis();
try {
matrixClient.increment(0, deltatest, true);
long startoneTs = System.currentTimeMillis();
LOG.info("increment time= " + (startoneTs - startTs));
while (true) {
LongFloatVector temp = (LongFloatVector) matrixClient.get(0, getIndices);
updateTime++;
if (updateTime % 10 == 0) {
LOG.info("get times = " + updateTime + ", avg update time=" + (System.currentTimeMillis() - startoneTs) / updateTime);
}
}
} catch (Throwable ie) {
LOG.info("mistake happened in MatrixRowGet try");
}
} catch (InvalidParameterException e) {
LOG.error("get matrix failed ", e);
throw new AngelException(e);
}
}
use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.
the class MatrixRowGetUDFTask method run.
@Override
public void run(TaskContext taskContext) throws AngelException {
try {
MatrixClient matrixClient = taskContext.getMatrix(MatrixRowGetTest.SPARSE_LONGKEY_FLOAT_MAT);
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(MatrixRowGetTest.SPARSE_LONGKEY_FLOAT_MAT);
long[] indices = genLongIndexs(matrixMeta.getColNum(), MatrixRowGetTest.longnnz);
long[] getIndices = genGetLongIndexs(indices, MatrixRowGetTest.nGet);
LongFloatVector deltatest = VFactory.sparseLongKeyFloatVector(matrixMeta.getColNum(), MatrixRowGetTest.longnnz);
for (int i = 0; i < MatrixRowGetTest.longnnz; i++) {
deltatest.set(indices[i], (float) (indices[i] * 1.3));
}
deltatest.setRowId(0);
LOG.info(" delta use " + deltatest.getType() + " type storage");
int updateTime = 0;
long startTs = System.currentTimeMillis();
try {
matrixClient.increment(0, deltatest, true);
long startoneTs = System.currentTimeMillis();
LOG.info("increment time= " + (startoneTs - startTs));
while (true) {
LongIndexGet funca = new LongIndexGet(new LongIndexGetParam(matrixClient.getMatrixId(), 0, getIndices));
LongFloatVector tempOne = (LongFloatVector) ((GetRowResult) PSAgentContext.get().getUserRequestAdapter().get(funca).get()).getRow();
updateTime++;
if (updateTime % 10 == 0) {
LOG.info("get times = " + updateTime + ", avg update time=" + (System.currentTimeMillis() - startoneTs) / updateTime);
}
}
} catch (Throwable ie) {
LOG.info("mistake happened in MatrixRowGet try");
}
} catch (InvalidParameterException e) {
LOG.error("get matrix failed ", e);
throw new AngelException(e);
}
}
use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.
the class AnyKeysUpdateParam method split.
@Override
public List<PartitionUpdateParam> split() {
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
KeyValuePart[] splits = RouterUtils.split(meta, 0, nodeIds, neighbors);
assert parts.length == splits.length;
List<PartitionUpdateParam> partParams = new ArrayList<>(parts.length);
for (int i = 0; i < parts.length; i++) {
if (splits[i] != null && splits[i].size() > 0) {
partParams.add(new GeneralPartUpdateParam(matrixId, parts[i], splits[i]));
}
}
return partParams;
}
use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.
the class IntKeysUpdateParam method split.
@Override
public List<PartitionUpdateParam> split() {
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
KeyValuePart[] splits = RouterUtils.split(meta, 0, nodeIds, neighbors);
assert parts.length == splits.length;
List<PartitionUpdateParam> partParams = new ArrayList<>(parts.length);
for (int i = 0; i < parts.length; i++) {
if (splits[i] != null && splits[i].size() > 0) {
partParams.add(new GeneralPartUpdateParam(matrixId, parts[i], splits[i]));
}
}
return partParams;
}
use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.
the class LongKeysUpdateParam method split.
@Override
public List<PartitionUpdateParam> split() {
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
KeyValuePart[] splits = RouterUtils.split(meta, 0, nodeIds, neighbors);
assert parts.length == splits.length;
List<PartitionUpdateParam> partParams = new ArrayList<>(parts.length);
for (int i = 0; i < parts.length; i++) {
if (splits[i] != null && splits[i].size() > 0) {
partParams.add(new GeneralPartUpdateParam(matrixId, parts[i], splits[i]));
}
}
return partParams;
}
Aggregations