
com.alachisoft.ncache.client.internal.command.HashSetRemoveCommand Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Common.Caching.UserBinaryObject;
import Alachisoft.NCache.Common.DataTypes.HashSet.HashSetRemoveOperation;
import Alachisoft.NCache.Common.JSON.ExtendedJsonValueBase;
import com.alachisoft.ncache.common.protobuf.CollectionItemProtocol;
import com.alachisoft.ncache.common.protobuf.HashSetCommandProtocol;
import com.alachisoft.ncache.common.protobuf.HashSetRemoveProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import com.google.protobuf.ByteString;
import java.nio.charset.StandardCharsets;
import java.util.Set;
public class HashSetRemoveCommand extends HashSetCommandBase {
private Set _collection;
private HashSetRemoveProtocol.HashSetRemove.Builder _hashSetRemoveBuilder;
public HashSetRemoveCommand(HashSetRemoveOperation operation)
{
super.name = "HashSetRemove";
super.key = operation.getName();
_writeThruOption = operation.getWriteThruOptions();
_lockId = (String)operation.getLockId();
_lockTimeout = operation.getLockTimeout();
_collection = operation.getCollection();
}
@Override
public RequestType getCommandRequestType()
{
return RequestType.AtomicRead;
}
@Override
public CommandType getCommandType()
{
return CommandType.DATA_TYPE;
}
@Override
protected void createCommand() throws CommandException {
_hashSetRemoveBuilder = HashSetRemoveProtocol.HashSetRemove.newBuilder();
for (ExtendedJsonValueBase value : _collection)
{
UserBinaryObject valueObject = UserBinaryObject.createUserBinaryObject(value.toJson().getBytes(StandardCharsets.UTF_8));
CollectionItemProtocol.CollectionItem.Builder valueItem = CollectionItemProtocol.CollectionItem.newBuilder();
for(byte[] bytes : valueObject.getDataList())
valueItem.addData(ByteString.copyFrom(bytes));
_hashSetRemoveBuilder.addValue(valueItem.build());
}
super.createCommand();
_hashSetCommandBuilder.setType(HashSetCommandProtocol.HashSetCommand.Type.HASHSET_REMOVE);
_hashSetCommandBuilder.setHashSetRemove(_hashSetRemoveBuilder);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy