use of com.tencent.angel.psagent.matrix.transport.FutureResult in project angel by Tencent.
the class MatrixClientImpl method asyncGet.
@Override
public Future<Vector> asyncGet(int rowId, long[] indices) throws AngelException {
checkRowId(rowId);
checkNotNull(indices, "indices");
// Return a empty vector
if (indices.length == 0) {
LOG.warn("parameter indices is empty, you should check it, just return a empty vector now!!!");
FutureResult<Vector> result = new FutureResult<>();
result.set(generateEmptyVec(rowId));
return result;
}
try {
return PSAgentContext.get().getUserRequestAdapter().get(matrixId, rowId, indices);
} catch (Throwable x) {
throw new AngelException(x);
}
}
use of com.tencent.angel.psagent.matrix.transport.FutureResult in project angel by Tencent.
the class MatrixClientImpl method asyncGet.
@Override
public Future<Vector> asyncGet(int rowId, int[] indices) throws AngelException {
checkRowId(rowId);
checkNotNull(indices, "indices");
// Return a empty vector
if (indices.length == 0) {
LOG.warn("parameter indices is empty, you should check it, just return a empty vector now!!!");
FutureResult<Vector> result = new FutureResult<>();
result.set(generateEmptyVec(rowId));
return result;
}
try {
return PSAgentContext.get().getUserRequestAdapter().get(matrixId, rowId, indices);
} catch (Throwable x) {
throw new AngelException(x);
}
}
use of com.tencent.angel.psagent.matrix.transport.FutureResult in project angel by Tencent.
the class MatrixClientImpl method asyncGet.
@Override
public Future<Vector[]> asyncGet(int[] rowIds, int[] indices) throws AngelException {
checkNotNull(rowIds, "rowIds");
checkNotNull(indices, "indices");
if (rowIds.length == 0) {
LOG.warn("parameter rowIds is empty, you should check it, just return a empty vector array now!!!");
FutureResult<Vector[]> result = new FutureResult<>();
result.set(new Vector[0]);
return result;
}
// Return a empty vector
if (indices.length == 0) {
LOG.warn("parameter indices is empty, you should check it, just return empty vectors now!!!");
FutureResult<Vector[]> result = new FutureResult<>();
result.set(generateEmptyVecs(rowIds));
return result;
}
try {
return PSAgentContext.get().getUserRequestAdapter().get(matrixId, rowIds, indices);
} catch (Throwable x) {
throw new AngelException(x);
}
}
use of com.tencent.angel.psagent.matrix.transport.FutureResult in project angel by Tencent.
the class MatrixClientImpl method asyncGet.
@Override
public Future<Vector[]> asyncGet(int[] rowIds, long[] indices) throws AngelException {
checkNotNull(rowIds, "rowIds");
checkNotNull(indices, "indices");
if (rowIds.length == 0) {
LOG.warn("parameter rowIds is empty, you should check it, just return a empty vector array now!!!");
FutureResult<Vector[]> result = new FutureResult<>();
result.set(new Vector[0]);
return result;
}
// Return a empty vector
if (indices.length == 0) {
LOG.warn("parameter indices is empty, you should check it, just return empty vectors now!!!");
FutureResult<Vector[]> result = new FutureResult<>();
result.set(generateEmptyVecs(rowIds));
return result;
}
try {
return PSAgentContext.get().getUserRequestAdapter().get(matrixId, rowIds, indices);
} catch (Throwable x) {
throw new AngelException(x);
}
}
use of com.tencent.angel.psagent.matrix.transport.FutureResult in project angel by Tencent.
the class UserRequestAdapter method getRow.
public FutureResult<Vector> getRow(int matrixId, int rowId) {
checkParams(matrixId, rowId);
// Get partitions for this row
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId, rowId);
GetRowRequest request = new GetRowRequest(matrixId, rowId);
int requestId = request.getRequestId();
FutureResult<Vector> result = new FutureResult<>();
ResponseCache responseCache = new MapResponseCache(parts.size());
requests.put(requestId, request);
requestIdToResultMap.put(requestId, result);
requestIdToResponseCache.put(requestId, responseCache);
MatrixTransportClient matrixClient = PSAgentContext.get().getMatrixTransportClient();
for (PartitionKey part : parts) {
LOG.info("Get row " + part);
sendGetRowRequest(matrixClient, requestId, part.getMatrixId(), rowId, part.getPartitionId());
}
return result;
}
Aggregations