All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.client.internal.command.ExecuteReaderCommand Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package com.alachisoft.ncache.client.internal.command;

import com.alachisoft.ncache.client.internal.util.IndexHelper;
import com.alachisoft.ncache.client.internal.util.QueryCommandHelper;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import com.alachisoft.ncache.runtime.util.NCDateTime;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ExecuteReaderCommand extends Command{

    String _query;
    Map _values;
    boolean _getData;
    int _chunkSize;
    int _methodOverload;


    protected com.alachisoft.ncache.common.protobuf.ExecuteReaderCommandProtocol.ExecuteReaderCommand _commandInstance;

    java.util.List valuesToSend;

    public ExecuteReaderCommand(String query, Map values, boolean getData, int chunkSize, int methodOverload)
    {
        super.name = "ExecuteReaderCommand";
        this._query = query;
        this._values = values;
        this._getData = getData;
        this._chunkSize = chunkSize;
        this._methodOverload = methodOverload;
        valuesToSend = QueryCommandHelper.getValuesFromMap(_values);
    }

    @Override
    public RequestType getCommandRequestType() {
        return RequestType.NonKeyBulkRead;
    }

    @Override
    public CommandType getCommandType() {
        return CommandType.EXECUTE_READER;
    }
    @Override
    protected  void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
    {
        _commandInstance.writeTo(stream);
    }
    @Override
    protected void createCommand() throws CommandException {
        com.alachisoft.ncache.common.protobuf.ExecuteReaderCommandProtocol.ExecuteReaderCommand.Builder builder = com.alachisoft.ncache.common.protobuf.ExecuteReaderCommandProtocol.ExecuteReaderCommand.newBuilder();
        builder.setQuery(_query)
                .setGetData(_getData)
                .setChunkSize(_chunkSize)
                .setMethodOverload(_methodOverload);
                if(valuesToSend!=null){
                    builder.addAllValues(valuesToSend);
                }
        _commandInstance = builder.setRequestId(super.getRequestId())
                .setCommandId(getCommandID())
                .setCommandVersion(1)
                .setClientLastViewId(super.getClientLastViewId()).build();


    }
    @Override
    protected short getCommandHandle()
    {
        return (short) CommandProtocol.Command.Type.EXECUTE_READER.getNumber();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy