当前位置: 首页>>代码示例>>Java>>正文


Java Encoder类代码示例

本文整理汇总了Java中org.redisson.client.protocol.Encoder的典型用法代码示例。如果您正苦于以下问题:Java Encoder类的具体用法?Java Encoder怎么用?Java Encoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Encoder类属于org.redisson.client.protocol包,在下文中一共展示了Encoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
private Encoder encoder(CommandData<Object, Object> msg, int param) {
    int typeIndex = 0;
    if (msg.getCommand().getInParamType().size() > 1) {
        typeIndex = param;
    }
    if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP) {
        if (param % 2 != 0) {
            return msg.getCodec().getMapValueEncoder();
        } else {
            return msg.getCodec().getMapKeyEncoder();
        }
    }
    if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP_KEY) {
        return msg.getCodec().getMapKeyEncoder();
    }
    if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP_VALUE) {
        return msg.getCodec().getMapValueEncoder();
    }
    if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.OBJECTS) {
        return msg.getCodec().getValueEncoder();
    }
    throw new IllegalStateException();
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:24,代码来源:CommandEncoder.java

示例2: encode

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, CommandData<Object, Object> msg, ByteBuf out) throws Exception {
    out.writeByte(ARGS_PREFIX);
    int len = 1 + msg.getParams().length;
    if (msg.getCommand().getSubName() != null) {
        len++;
    }
    out.writeBytes(toChars(len));
    out.writeBytes(CRLF);

    writeArgument(out, msg.getCommand().getName().getBytes("UTF-8"));
    if (msg.getCommand().getSubName() != null) {
        writeArgument(out, msg.getCommand().getSubName().getBytes("UTF-8"));
    }
    int i = 1;
    for (Object param : msg.getParams()) {
        Encoder encoder = paramsEncoder;
        if (msg.getCommand().getInParamType().size() == 1) {
            if (msg.getCommand().getInParamIndex() == i && msg.getCommand().getInParamType().get(0) == ValueType.OBJECT) {
                encoder = msg.getCodec().getValueEncoder();
            } else if (msg.getCommand().getInParamIndex() <= i && msg.getCommand().getInParamType().get(0) != ValueType.OBJECT) {
                encoder = encoder(msg, i - msg.getCommand().getInParamIndex());
            }
        } else {
            int paramNum = i - msg.getCommand().getInParamIndex();
            if (msg.getCommand().getInParamIndex() <= i) {
                encoder = encoder(msg, paramNum);
            }
        }

        writeArgument(out, encoder.encode(param));

        i++;
    }

    if (log.isTraceEnabled()) {
        log.trace("channel: {} message: {}", ctx.channel(), out.toString(CharsetUtil.UTF_8));
    }
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:40,代码来源:CommandEncoder.java

示例3: getValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
    return new Encoder() {
        @Override
        public byte[] encode(Object in) throws IOException {
            return in.toString().getBytes("UTF-8");
        }
    };
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:10,代码来源:StringCodec.java

示例4: getValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
    return new Encoder() {

        @Override
        public byte[] encode(Object in) throws IOException {
            ByteArrayOutputStream result = new ByteArrayOutputStream();
            ObjectOutputStream outputStream = new ObjectOutputStream(result);
            outputStream.writeObject(in);
            outputStream.close();
            return result.toByteArray();
        }
    };
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:15,代码来源:SerializationCodec.java

示例5: getMapValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
    return new Encoder() {

        @Override
        public byte[] encode(Object in) throws IOException {
            return mapObjectMapper.writeValueAsBytes(in);
        }
    };
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:11,代码来源:JsonJacksonCodec.java

示例6: getValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
    return new Encoder() {

        @Override
        public byte[] encode(Object in) throws IOException {
            Kryo kryo = null;
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                Output output = new Output(baos);
                kryo = kryoPool.get();
                kryo.writeClassAndObject(output, in);
                output.close();
                return baos.toByteArray();
            } catch (Exception e) {
                if (e instanceof RuntimeException) {
                    throw (RuntimeException) e;
                }
                throw new RedissonKryoCodecException(e);
            } finally {
                if (kryo != null) {
                    kryoPool.yield(kryo);
                }
            }
        }
    };
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:28,代码来源:KryoCodec.java

示例7: getMapValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
    return getValueEncoder();
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:5,代码来源:StringCodec.java

示例8: getMapKeyEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
    return getValueEncoder();
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:5,代码来源:StringCodec.java

示例9: getMapKeyEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
    return getMapValueEncoder();
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:5,代码来源:JsonJacksonCodec.java

示例10: getValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
    return getMapValueEncoder();
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:5,代码来源:JsonJacksonCodec.java

示例11: getMapValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
  public Encoder getMapValueEncoder() {
return resultEncoder;
  }
 
开发者ID:ICIJ,项目名称:extract,代码行数:5,代码来源:RedisReportMap.java

示例12: getMapKeyEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
	return documentEncoder;
   }
 
开发者ID:ICIJ,项目名称:extract,代码行数:5,代码来源:RedisReportMap.java

示例13: getValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
	return resultEncoder;
   }
 
开发者ID:ICIJ,项目名称:extract,代码行数:5,代码来源:RedisReportMap.java

示例14: getMapValueEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
	return documentEncoder;
}
 
开发者ID:ICIJ,项目名称:extract,代码行数:5,代码来源:RedisDocumentQueue.java

示例15: getMapKeyEncoder

import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
	return documentEncoder;
}
 
开发者ID:ICIJ,项目名称:extract,代码行数:5,代码来源:RedisDocumentQueue.java


注:本文中的org.redisson.client.protocol.Encoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。