use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IndexGetRowHashTest method testSparseDoubleLongKeyUDF.
public void testSparseDoubleLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongDoubleVector deltaVec = new LongDoubleVector(feaNum, new LongDoubleSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec);
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongDoubleVector row = (LongDoubleVector) client1.get(0, index);
for (long id : index) {
// System.out.println("id=" + id + ", value=" + row.get(id));
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
// Assert.assertTrue(index.length == row.size());
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IndexGetRowsHashTest method testSparseFloatUDF.
public void testSparseFloatUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntFloatVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new IntFloatVector(feaNum, new IntFloatSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (int id : index) {
Assert.assertEquals(((IntFloatVector) rows[i]).get(id), deltaVec.get(id), zero);
}
Assert.assertTrue(index.length == ((IntFloatVector) rows[i]).size());
}
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IndexGetRowsHashTest method testSparseIntLongKeyUDF.
public void testSparseIntLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_INT_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongIntVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new LongIntVector(feaNum, new LongIntSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], (int) index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (long id : index) {
Assert.assertEquals(((LongIntVector) rows[i]).get(id), deltaVec.get(id), zero);
}
}
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IndexGetRowsHashTest method testSparseLongLongKeyUDF.
public void testSparseLongLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_LONG_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongLongVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new LongLongVector(feaNum, new LongLongSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (long id : index) {
Assert.assertEquals(((LongLongVector) rows[i]).get(id), deltaVec.get(id), zero);
}
}
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IndexGetRowsHashTest method testSparseDoubleLongKeyUDF.
public void testSparseDoubleLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_LONG_MAT, 0);
long[] index = genLongIndexs(feaNum, nnz);
LongDoubleVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new LongDoubleVector(feaNum, new LongDoubleSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (long id : index) {
Assert.assertEquals(((LongDoubleVector) rows[i]).get(id), deltaVec.get(id), zero);
}
}
}
Aggregations