use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IncrementRowHashTest 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 = new LongDoubleVector(feaNum, new LongDoubleSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
LongDoubleVector row = (LongDoubleVector) client1.getRow(0);
for (long id : index) {
// System.out.println("id=" + id + ", value=" + row.get(id));
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IncrementRowHashTest method testDenseIntUDF.
public void testDenseIntUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_INT_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntIntVector deltaVec = new IntIntVector(feaNum, new IntIntDenseVectorStorage(feaNum));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
IntIntVector row = (IntIntVector) client1.getRow(0);
for (int id : index) {
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
Assert.assertTrue(feaNum == row.size());
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IncrementRowHashTest method testSparseFloatLongKeyUDF.
public void testSparseFloatLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_LONG_MAT, 0);
long[] index = genLongIndexs(feaNum, nnz);
LongFloatVector deltaVec = new LongFloatVector(feaNum, new LongFloatSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < nnz; i++) deltaVec.set(index[i], index[i]);
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
LongFloatVector row = (LongFloatVector) client1.getRow(0);
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 IncrementRowHashTest method testSparseDoubleUDF.
public void testSparseDoubleUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntDoubleVector deltaVec = new IntDoubleVector(feaNum, new IntDoubleSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
IntDoubleVector row = (IntDoubleVector) client1.getRow(0);
for (int 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 IncrementRowHashTest method testDenseDoubleUDF.
public void testDenseDoubleUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_DOUBLE_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntDoubleVector deltaVec = new IntDoubleVector(feaNum, new IntDoubleDenseVectorStorage(feaNum));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
IntDoubleVector row = (IntDoubleVector) client1.getRow(0);
for (int id : index) {
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
Assert.assertEquals(feaNum, row.size());
}
Aggregations