本文整理汇总了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();
}
示例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));
}
}
示例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");
}
};
}
示例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();
}
};
}
示例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);
}
};
}
示例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);
}
}
}
};
}
示例7: getMapValueEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
return getValueEncoder();
}
示例8: getMapKeyEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
return getValueEncoder();
}
示例9: getMapKeyEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
return getMapValueEncoder();
}
示例10: getValueEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
return getMapValueEncoder();
}
示例11: getMapValueEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
return resultEncoder;
}
示例12: getMapKeyEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
return documentEncoder;
}
示例13: getValueEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getValueEncoder() {
return resultEncoder;
}
示例14: getMapValueEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapValueEncoder() {
return documentEncoder;
}
示例15: getMapKeyEncoder
import org.redisson.client.protocol.Encoder; //导入依赖的package包/类
@Override
public Encoder getMapKeyEncoder() {
return documentEncoder;
}