use of org.apache.geode.redis.internal.DoubleWrapper in project geode by apache.
the class ZRankExecutor method executeCommand.
@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
List<byte[]> commandElems = command.getProcessedCommand();
if (commandElems.size() < 3) {
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), getArgsError()));
return;
}
ByteArrayWrapper key = command.getKey();
checkDataType(key, RedisDataType.REDIS_SORTEDSET, context);
Region<ByteArrayWrapper, DoubleWrapper> keyRegion = getRegion(context, key);
if (keyRegion == null) {
command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
return;
}
ByteArrayWrapper member = new ByteArrayWrapper(commandElems.get(2));
DoubleWrapper value = keyRegion.get(member);
if (value == null) {
command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
return;
}
int rank;
try {
rank = getRange(context, key, member, value);
} catch (Exception e) {
throw new RuntimeException(e);
}
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), rank));
}
Aggregations