Search in sources :

Example 1 with StreamIndexPartGetRowResponse

use of com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse in project angel by Tencent.

the class IndexGetRowHandler method parseResponse.

@Override
public ResponseData parseResponse(ByteBuf in) {
    StreamIndexPartGetRowResponse response = new StreamIndexPartGetRowResponse();
    response.deserialize(in);
    return response;
}
Also used : StreamIndexPartGetRowResponse(com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse)

Example 2 with StreamIndexPartGetRowResponse

use of com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse in project angel by Tencent.

the class IndexGetRowHandler method handle.

@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
    IndexPartGetRowRequest request = (IndexPartGetRowRequest) data;
    KeyPart keyPart = request.getKeyPart();
    ServerRow row = MatrixUtils.getRow(context.getMatrixStorageManager(), header.matrixId, header.partId, request.getRowId());
    ValuePart result;
    StreamIndexPartGetRowResponse response;
    row.startRead();
    try {
        result = ServerRowUtils.getByKeys(row, keyPart);
        response = new StreamIndexPartGetRowResponse(result);
        return response;
    } finally {
        row.endRead();
    }
}
Also used : IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) ValuePart(com.tencent.angel.psagent.matrix.transport.router.ValuePart) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) StreamIndexPartGetRowResponse(com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse)

Example 3 with StreamIndexPartGetRowResponse

use of com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse in project angel by Tencent.

the class StreamIndexGetRowHandler method handle.

@Override
public ResponseData handle(RequestHeader requestHeader, RequestData data) throws Exception {
    IndexPartGetRowRequest request = (IndexPartGetRowRequest) data;
    StreamIndexPartGetRowResponse response = new StreamIndexPartGetRowResponse();
    ByteBuf in = request.getInputBuffer();
    ServerBasicTypeRow row = (ServerBasicTypeRow) context.getMatrixStorageManager().getRow(requestHeader.matrixId, request.getRowId(), requestHeader.partId);
    ValueType valueType = MatrixUtils.getValueType(row.getRowType());
    ResponseHeader responseHeader = new ResponseHeader(requestHeader.seqId, requestHeader.methodId, context.getRunningContext().getState(), ResponseType.SUCCESS);
    // 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 final result byte buffer
    ByteBuf resultBuf = ByteBufUtils.allocResultBuf(buffLen, context.isUseDirectBuffer());
    // Write response header
    responseHeader.serialize(resultBuf);
    // Data
    // Value part flag
    ByteBufSerdeUtils.serializeBoolean(resultBuf, true);
    // Value type
    ByteBufSerdeUtils.serializeInt(resultBuf, valueType.getTypeId());
    // Row id
    ByteBufSerdeUtils.serializeInt(resultBuf, rowId);
    // Values number
    ByteBufSerdeUtils.serializeInt(resultBuf, size);
    // Result data
    if (request.getFunc() == null) {
        row.startRead();
        try {
            row.indexGet(keyType, size, in, resultBuf, null);
        } finally {
            row.endRead();
        }
    } else {
        row.startWrite();
        try {
            row.indexGet(keyType, size, in, resultBuf, request.getFunc());
        } finally {
            row.endWrite();
        }
    }
    response.setOutputBuffer(resultBuf);
    return response;
}
Also used : ResponseHeader(com.tencent.angel.ps.server.data.response.ResponseHeader) 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) IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) StreamIndexPartGetRowResponse(com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse) ByteBuf(io.netty.buffer.ByteBuf) ServerBasicTypeRow(com.tencent.angel.ps.storage.vector.ServerBasicTypeRow)

Aggregations

StreamIndexPartGetRowResponse (com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse)3 IndexPartGetRowRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest)2 KeyType (com.tencent.angel.ps.server.data.request.KeyType)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