@@ -0,0 +1,3216 @@
+/*%0A * Copyright 2013 Basho Technologies Inc%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.basho.riak.client.core.operations;%0A%0Aimport com.basho.riak.client.core.FutureOperation;%0Aimport com.basho.riak.client.core.RiakMessage;%0Aimport com.basho.riak.client.query.indexes.RawIndex;%0Aimport com.basho.riak.client.util.ByteArrayWrapper;%0Aimport com.basho.riak.client.util.RiakMessageCodes;%0Aimport com.basho.riak.protobuf.RiakKvPB;%0Aimport com.google.protobuf.ByteString;%0Aimport com.google.protobuf.InvalidProtocolBufferException;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.concurrent.ExecutionException;%0A%0Apublic class MapReduceOperation extends FutureOperation%3CList%3CByteArrayWrapper%3E, RiakKvPB.RpbMapRedResp%3E%0A%7B%0A%0A    private final ByteArrayWrapper mrFunction;%0A    private final String contentType;%0A%0A    public MapReduceOperation(ByteArrayWrapper function, String contentType)%0A    %7B%0A%0A        if ((null == function) %7C%7C function.length() == 0)%0A        %7B%0A            throw new IllegalArgumentException(%22Function can not be null or empty%22);%0A        %7D%0A%0A        if ((null == contentType) %7C%7C contentType.length() == 0)%0A        %7B%0A            throw new IllegalArgumentException(%22contentType can not be null or empty%22);%0A        %7D%0A%0A        this.mrFunction = function;%0A        this.contentType = contentType;%0A    %7D%0A%0A    @Override%0A    protected List%3CByteArrayWrapper%3E convert(List%3CRiakKvPB.RpbMapRedResp%3E rawResponse) throws ExecutionException%0A    %7B%0A        List%3CByteArrayWrapper%3E results = new ArrayList%3CByteArrayWrapper%3E(rawResponse.size());%0A        for (RiakKvPB.RpbMapRedResp response : rawResponse) %7B%0A            results.add(ByteArrayWrapper.create(response.getResponse().toByteArray()));%0A        %7D%0A        return results;%0A    %7D%0A%0A    @Override%0A    protected RiakMessage createChannelMessage()%0A    %7B%0A        RiakKvPB.RpbMapRedReq request =%0A            RiakKvPB.RpbMapRedReq.newBuilder()%0A                .setRequest(ByteString.copyFrom(mrFunction.unsafeGetValue()))%0A                .setContentType(ByteString.copyFromUtf8(contentType))%0A                .build();%0A%0A        return new RiakMessage(RiakMessageCodes.MSG_MapRedReq, request.toByteArray());%0A%0A    %7D%0A%0A    @Override%0A    protected RiakKvPB.RpbMapRedResp decode(RiakMessage rawMessage)%0A    %7B%0A        Operations.checkMessageType(rawMessage, RiakMessageCodes.MSG_MapRedResp);%0A        try%0A        %7B%0A            return RiakKvPB.RpbMapRedResp.parseFrom(rawMessage.getData());%0A        %7D%0A        catch (InvalidProtocolBufferException e)%0A        %7B%0A            throw new IllegalArgumentException(e);%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected boolean done(RiakKvPB.RpbMapRedResp message)%0A    %7B%0A        return message.getDone();%0A    %7D%0A%7D%0A

Add MapReduceOperation