Search in sources :

Example 16 with DoubleWrapper

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));
}
Also used : ByteArrayWrapper(org.apache.geode.redis.internal.ByteArrayWrapper) DoubleWrapper(org.apache.geode.redis.internal.DoubleWrapper)

Aggregations

ByteArrayWrapper (org.apache.geode.redis.internal.ByteArrayWrapper)16 DoubleWrapper (org.apache.geode.redis.internal.DoubleWrapper)16 FunctionDomainException (org.apache.geode.cache.query.FunctionDomainException)3 NameResolutionException (org.apache.geode.cache.query.NameResolutionException)3 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)3 TypeMismatchException (org.apache.geode.cache.query.TypeMismatchException)3 ArrayList (java.util.ArrayList)2 Struct (org.apache.geode.cache.query.Struct)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Region (org.apache.geode.cache.Region)1 Entry (org.apache.geode.cache.Region.Entry)1