提交 05c84685 编写于 作者: N Nikita

Avro and Smile codecs added. #571

上级 f184d91e
......@@ -214,6 +214,18 @@
<version>2.6.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
<version>2.6.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-avro</artifactId>
<version>2.6.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>zero-allocation-hashing</artifactId>
......
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.codec;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.avro.AvroFactory;
/**
* Avro binary codec
*
* @author Nikita Koksharov
*
*/
public class AvroJacksonCodec extends JsonJacksonCodec {
public AvroJacksonCodec() {
super(new ObjectMapper(new AvroFactory()));
}
public AvroJacksonCodec(ClassLoader classLoader) {
super(createObjectMapper(classLoader, new ObjectMapper(new AvroFactory())));
}
}
......@@ -124,7 +124,8 @@ public class JsonJacksonCodec implements Codec {
// warm up codec
try {
mapObjectMapper.readValue("1".getBytes(), Object.class);
byte[] s = mapObjectMapper.writeValueAsBytes(1);
mapObjectMapper.readValue(s, Object.class);
} catch (IOException e) {
throw new IllegalStateException(e);
}
......
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.codec;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
/**
* Smile binary codec
*
* @author Nikita Koksharov
*
*/
public class SmileJacksonCodec extends JsonJacksonCodec {
public SmileJacksonCodec() {
super(new ObjectMapper(new SmileFactory()));
}
public SmileJacksonCodec(ClassLoader classLoader) {
super(createObjectMapper(classLoader, new ObjectMapper(new SmileFactory())));
}
}
......@@ -13,6 +13,7 @@ import org.redisson.codec.KryoCodec;
import org.redisson.codec.LZ4Codec;
import org.redisson.codec.MsgPackJacksonCodec;
import org.redisson.codec.SerializationCodec;
import org.redisson.codec.SmileJacksonCodec;
import org.redisson.codec.SnappyCodec;
import org.redisson.config.Config;
......@@ -26,6 +27,8 @@ import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
public class RedissonCodecTest extends BaseTest {
private Codec avroCodec = new SmileJacksonCodec();
private Codec smileCodec = new SmileJacksonCodec();
private Codec codec = new SerializationCodec();
private Codec kryoCodec = new KryoCodec();
private Codec jsonCodec = new JsonJacksonCodec();
......@@ -54,7 +57,7 @@ public class RedissonCodecTest extends BaseTest {
test();
}
@Test
public void testMsgPack() {
Config config = createConfig();
......@@ -63,6 +66,24 @@ public class RedissonCodecTest extends BaseTest {
test();
}
@Test
public void testSmile() {
Config config = createConfig();
config.setCodec(smileCodec);
redisson = Redisson.create(config);
test();
}
@Test
public void testAvro() {
Config config = createConfig();
config.setCodec(avroCodec);
redisson = Redisson.create(config);
test();
}
@Test
public void testFst() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册