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

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

package com.alachisoft.ncache.client.internal.command;

import Alachisoft.NCache.Common.Caching.UserBinaryObject;
import Alachisoft.NCache.Common.DataTypes.List.ListSearchOperation;
import Alachisoft.NCache.Common.JSON.ExtendedJsonValue;
import Alachisoft.NCache.Common.JSON.ExtendedJsonValueBase;
import com.alachisoft.ncache.common.protobuf.CollectionItemProtocol;
import com.alachisoft.ncache.common.protobuf.ListCommandProtocol;
import com.alachisoft.ncache.common.protobuf.ListSearchProtocol;
import com.google.protobuf.ByteString;

import java.nio.charset.StandardCharsets;

public class ListSearchCommand extends ListCommandBase {
    private ExtendedJsonValueBase _value;
    private ListSearchProtocol.ListSearch.Builder _listSearchCommandBuilder;

    public ListSearchCommand(ListSearchOperation operation)
    {
        super.name = "ListSearch";
        super.key = operation.getName();
        _lockId = (String)operation.getLockId();
        _lockTimeout = operation.getLockTimeout();
        _value = operation.getItem();
    }

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

    @Override
    public CommandType getCommandType()
    {
        return CommandType.DATA_TYPE;
    }

    @Override
    protected void createCommand()
    {
        _listSearchCommandBuilder = ListSearchProtocol.ListSearch.newBuilder();

        UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(_value.toJson().getBytes(StandardCharsets.UTF_8));

        CollectionItemProtocol.CollectionItem.Builder cItem = CollectionItemProtocol.CollectionItem.newBuilder();
        for(byte[] value : ubObject.getDataList())
            cItem.addData(ByteString.copyFrom(value));

        _listSearchCommandBuilder.setItem(cItem);

        super.createCommand();

        _listCommandBuilder.setType(ListCommandProtocol.ListCommand.Type.LIST_SEARCH);
        _listCommandBuilder.setListSearch(_listSearchCommandBuilder);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy