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

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

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

import Alachisoft.NCache.Common.Caching.UserBinaryObject;
import Alachisoft.NCache.Common.DataTypes.List.ListRemoveWithoutIndexOperation;
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.ListRemoveWithPivotProtocol;
import com.alachisoft.ncache.common.protobuf.ListRemoveWithoutPivotProtocol;
import com.google.protobuf.ByteString;

import java.nio.charset.StandardCharsets;
import java.util.List;

public class ListRemoveWihoutIndexCommand extends ListCommandBase {
    private List _collection;
    private ListRemoveWithoutPivotProtocol.ListRemoveWithoutIndex.Builder _listRemoveWithoutIndex;
    public ListRemoveWihoutIndexCommand(ListRemoveWithoutIndexOperation operation)
    {
        super.name = "ListRemoveWihoutIndex";
        super.key = operation.getName();
        _writeThruOption = operation.getWriteThruOptions();
        _lockId = (String)operation.getLockId();
        _lockTimeout = operation.getLockTimeout();
        _collection = operation.getCollection();
    }

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

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

    @Override
    protected void createCommand()
    {
        _listRemoveWithoutIndex = ListRemoveWithoutPivotProtocol.ListRemoveWithoutIndex.newBuilder();

        for (int i = 0; i < _collection.size(); i++)
        {
            byte[] serializeValue = _collection.get(i).toJson().getBytes(StandardCharsets.UTF_8);
            UserBinaryObject ubObject = UserBinaryObject.createUserBinaryObject(serializeValue);

            CollectionItemProtocol.CollectionItem.Builder item = CollectionItemProtocol.CollectionItem.newBuilder();
            for(byte[] bytes : ubObject.getDataList())
                item.addData(ByteString.copyFrom(bytes));
            _listRemoveWithoutIndex.addData(item.build());
        }

        super.createCommand();

        _listCommandBuilder.setType(ListCommandProtocol.ListCommand.Type.LIST_REMOVE_WITHOUT_INDEX);
        _listCommandBuilder.setListRemoveWithoutIndex(_listRemoveWithoutIndex);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy