Search in sources :

Example 1 with IndexPartGetRowsRequest

use of com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest in project angel by Tencent.

the class IndexGetRowsHandler method parseRequest.

@Override
public RequestData parseRequest(ByteBuf in) {
    IndexPartGetRowsRequest request = new IndexPartGetRowsRequest();
    request.deserialize(in);
    return request;
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)

Example 2 with IndexPartGetRowsRequest

use of com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest in project angel by Tencent.

the class StreamIndexGetRowsHandler method parseRequest.

@Override
public RequestData parseRequest(ByteBuf in) {
    IndexPartGetRowsRequest request = new IndexPartGetRowsRequest();
    request.deserializeHeader(in);
    request.setIn(in);
    return request;
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)

Example 3 with IndexPartGetRowsRequest

use of com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest in project angel by Tencent.

the class UserRequestAdapter method sendIndexGetRowsRequest.

private void sendIndexGetRowsRequest(MatrixTransportClient matrixClient, int userRequestId, int matrixId, int[] rowIds, int partId, KeyPart keyPart, InitFunc func) {
    // Request header
    RequestHeader header = createRequestHeader(userRequestId, TransportMethod.INDEX_GET_ROWS, matrixId, partId);
    // Request body
    IndexPartGetRowsRequest requestData = new IndexPartGetRowsRequest(rowIds, keyPart, func);
    // Request
    Request request = new Request(header, requestData);
    // Send the request
    matrixClient.sendGetRequest(request);
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) GetRowSplitRequest(com.tencent.angel.ps.server.data.request.GetRowSplitRequest) UpdateRequest(com.tencent.angel.ps.server.data.request.UpdateRequest) Request(com.tencent.angel.ps.server.data.request.Request) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest) GetRowsSplitRequest(com.tencent.angel.ps.server.data.request.GetRowsSplitRequest) IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader)

Example 4 with IndexPartGetRowsRequest

use of com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest in project angel by Tencent.

the class StreamIndexGetRowsHandler method handle.

@Override
public ResponseData handle(RequestHeader requestHeader, RequestData data) throws Exception {
    IndexPartGetRowsRequest request = (IndexPartGetRowsRequest) data;
    IndexPartGetRowsResponse response = new IndexPartGetRowsResponse();
    int[] rowIds = request.getRowIds();
    int rowNum = rowIds.length;
    ServerBasicTypeRow row0 = (ServerBasicTypeRow) context.getMatrixStorageManager().getRow(requestHeader.matrixId, request.getRowIds()[0], requestHeader.partId);
    ValueType valueType = MatrixUtils.getValueType(row0.getRowType());
    ResponseHeader responseHeader = new ResponseHeader(requestHeader.seqId, requestHeader.methodId, context.getRunningContext().getState(), ResponseType.SUCCESS);
    ByteBuf in = request.getInputBuffer();
    // Read router type
    RouterType routerType = RouterType.valueOf(in.readInt());
    // Key type
    KeyType keyType = KeyType.valueOf(in.readInt());
    // Row id
    int rowId = in.readInt();
    // Key number
    int size = in.readInt();
    // Calculate final output buffer len
    // Response header
    int buffLen = responseHeader.bufferLen();
    // Data flag
    buffLen += ByteBufSerdeUtils.BOOLEN_LENGTH;
    // Value type
    buffLen += ByteBufSerdeUtils.INT_LENGTH;
    // Row id
    buffLen += ByteBufSerdeUtils.INT_LENGTH;
    // Size
    buffLen += ByteBufSerdeUtils.INT_LENGTH;
    // Data
    buffLen += size * ByteBufSerdeUtils.serializedValueLen(valueType);
    // Allocate result buffer
    ByteBuf resultBuf = ByteBufUtils.allocResultBuf(buffLen, context.isUseDirectBuffer());
    // Header
    responseHeader.serialize(resultBuf);
    ByteBufSerdeUtils.serializeBoolean(resultBuf, true);
    int colNum = 0;
    int markPos = in.readerIndex();
    for (int i = 0; i < rowNum; i++) {
        in.readerIndex(markPos);
        // Serialize Value part head
        ByteBufSerdeUtils.serializeInt(resultBuf, valueType.getTypeId());
        ByteBufSerdeUtils.serializeInt(resultBuf, rowIds[i]);
        ByteBufSerdeUtils.serializeInt(resultBuf, colNum);
        ServerBasicTypeRow row = (ServerBasicTypeRow) context.getMatrixStorageManager().getRow(requestHeader.matrixId, rowIds[i], requestHeader.partId);
        resultBuf.writeInt(rowIds[i]);
        if (request.getFunc() == null) {
            row.startRead();
            try {
                row.indexGet(keyType, colNum, in, resultBuf, null);
            } finally {
                row.endRead();
            }
        } else {
            row.startWrite();
            try {
                row.indexGet(keyType, colNum, in, resultBuf, request.getFunc());
            } finally {
                row.endWrite();
            }
        }
    }
    // response.setOutputBuffer(resultBuf);
    return response;
}
Also used : ResponseHeader(com.tencent.angel.ps.server.data.response.ResponseHeader) IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) KeyType(com.tencent.angel.ps.server.data.request.KeyType) ValueType(com.tencent.angel.ps.server.data.request.ValueType) RouterType(com.tencent.angel.psagent.matrix.transport.router.RouterType) IndexPartGetRowsResponse(com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse) ServerBasicTypeRow(com.tencent.angel.ps.storage.vector.ServerBasicTypeRow) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with IndexPartGetRowsRequest

use of com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest in project angel by Tencent.

the class IndexGetRowsHandler method handle.

@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
    IndexPartGetRowsRequest request = (IndexPartGetRowsRequest) data;
    int[] rowIds = request.getRowIds();
    KeyPart keyPart = request.getKeyPart();
    ServerRow[] rows = new ServerRow[rowIds.length];
    ValuePart[] results = new ValuePart[rowIds.length];
    for (int i = 0; i < rowIds.length; i++) {
        rows[i] = context.getMatrixStorageManager().getRow(header.matrixId, rowIds[i], header.partId);
        rows[i].startRead();
        try {
            results[i] = ServerRowUtils.getByKeys(rows[i], keyPart);
        } finally {
            rows[i].endRead();
        }
    }
    IndexPartGetRowsResponse response = new IndexPartGetRowsResponse(results);
    return response;
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) ValuePart(com.tencent.angel.psagent.matrix.transport.router.ValuePart) IndexPartGetRowsResponse(com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Aggregations

IndexPartGetRowsRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)5 IndexPartGetRowsResponse (com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse)2 GetRowSplitRequest (com.tencent.angel.ps.server.data.request.GetRowSplitRequest)1 GetRowsSplitRequest (com.tencent.angel.ps.server.data.request.GetRowsSplitRequest)1 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)1 IndexPartGetRowRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest)1 KeyType (com.tencent.angel.ps.server.data.request.KeyType)1 Request (com.tencent.angel.ps.server.data.request.Request)1 RequestHeader (com.tencent.angel.ps.server.data.request.RequestHeader)1 UpdateRequest (com.tencent.angel.ps.server.data.request.UpdateRequest)1 UpdateUDFRequest (com.tencent.angel.ps.server.data.request.UpdateUDFRequest)1 ValueType (com.tencent.angel.ps.server.data.request.ValueType)1 ResponseHeader (com.tencent.angel.ps.server.data.response.ResponseHeader)1 ServerBasicTypeRow (com.tencent.angel.ps.storage.vector.ServerBasicTypeRow)1 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)1 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)1 RouterType (com.tencent.angel.psagent.matrix.transport.router.RouterType)1 ValuePart (com.tencent.angel.psagent.matrix.transport.router.ValuePart)1 ByteBuf (io.netty.buffer.ByteBuf)1