예제 #1
0
    def _decode_get_row(self, body):
        proto = pb.GetRowResponse()
        proto.ParseFromString(body)

        consumed = self._parse_capacity_unit(proto.consumed.capacity_unit)
        next_token = proto.next_token

        return_row = None

        if len(proto.row) != 0:
            inputStream = PlainBufferInputStream(proto.row)
            codedInputStream = PlainBufferCodedInputStream(inputStream)
            primary_key, attributes = codedInputStream.read_row()
            return_row = Row(primary_key, attributes)

        return (consumed, return_row, next_token), proto
    def _mock_get_row(self, body):
        proto = pb2.GetRowResponse()
        proto.consumed.capacity_unit.read = 10
        primary_key_columns = proto.row.primary_key_columns.add()
        primary_key_columns.name = 'PK1'
        primary_key_columns.value.type = pb2.STRING
        primary_key_columns.value.v_string = 'Hello'
        primary_key_columns = proto.row.primary_key_columns.add()
        primary_key_columns.name = 'PK2'
        primary_key_columns.value.type = pb2.BINARY
        primary_key_columns.value.v_binary = 'World'

        column = proto.row.attribute_columns.add()
        column.name = 'COL1'
        column.value.type = pb2.STRING
        column.value.v_string = 'test'
        column = proto.row.attribute_columns.add()
        column.name = 'COL2'
        column.value.type = pb2.INTEGER
        column.value.v_int = 100

        return proto