Json size: 2727kb
Json time: 26.22ms
Smile size: 1043kb
Smile time: 19.78ms
Compressed Smile size: 914kb
Compressed Smile time: 19.88ms
LZ4 size: 84kb
LZ4 time: 29.839ms
public static final Charset UTF8=Charset.forName("UTF-8");
public static final int BLOCK_SIZE=16 * 1024;
public static final ObjectMapper LZ4_OBJECT_MAPPER;
static{
final JsonFactory jsonFactory=new JsonFactory();
jsonFactory.setInputDecorator(new InputDecorator()
{
@Override
public InputStream decorate(IOContext context,InputStream inputStream)
{
return new LZ4BlockInputStream(new LZ4BlockInputStream(inputStream));
}
@Override
public InputStream decorate(IOContext context,byte[] bytes,int offset,int length)
{
return new LZ4BlockInputStream(new LZ4BlockInputStream(new ByteArrayInputStream(bytes,offset,length)));
}
@Override
public Reader decorate(IOContext context,Reader reader)
{
return new InputStreamReader(new LZ4BlockInputStream(new LZ4BlockInputStream(new ReaderInputStream(reader))),UTF8);
}
});
jsonFactory.setOutputDecorator(new OutputDecorator()
{
@Override
public OutputStream decorate(IOContext context,OutputStream outputStream)
{
return new LZ4BlockOutputStream(new LZ4BlockOutputStream(outputStream,
BLOCK_SIZE,LZ4Factory.fastestInstance().fastCompressor()),
BLOCK_SIZE,LZ4Factory.fastestInstance().fastCompressor());
}
@Override
public Writer decorate(IOContext context,Writer writer)
{
return new OutputStreamWriter(
new LZ4BlockOutputStream(new LZ4BlockOutputStream(new WriterOutputStream(writer,UTF8),
BLOCK_SIZE,LZ4Factory.fastestInstance().fastCompressor()),
BLOCK_SIZE,LZ4Factory.fastestInstance().fastCompressor())
);
}
});
LZ4_OBJECT_MAPPER=new ObjectMapper(jsonFactory).
disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).
disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).
setSerializationInclusion(JsonInclude.Include.NON_NULL).
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).
registerModule(INT_RANGE_MODULE).
registerModule(JODA_MODULE).
registerModule(TAGS_MODULE);
}Now I'm curious of smile combined with this LZ4 implementation https://github.com/lz4/lz4-javaThe time is pretty close and the compression is decent, what do you think I need to do to be able to decorate the SmileFactory?
--Json size: 2727kb
Json time: 27.43ms
Smile size: 1043kb
Smile time: 20.776ms
Compressed Smile size: 914kb
Compressed Smile time: 20.761ms
LZ4 size: 586kb
LZ4 time: 30.093ms
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Quite strangely, the JDK's GZip is winning vs these fancy compression algorithms:Json size: 2727kbJson time: 26.426msSmile size: 1043kbSmile time: 20.366msCompressed Smile size: 914kbCompressed Smile time: 20.678msGZip size: 216kbGZip time: 53.393ms
And for a reasonable price to pay, I'm happy with this now ;-)
On Saturday, November 24, 2018 at 6:46:45 PM UTC, oxy...@gmail.com wrote:I cannot set input/output decorators to the SmileFactory, I get exceptions when I do that, the following is working but it is a shame I cannot use the SmileFactory + decorators:public static final ObjectMapper SNAPPY_OBJECT_MAPPER;
public static final Charset UTF8=Charset.forName("UTF-8");
static{
final JsonFactory jsonFactory=new JsonFactory();
jsonFactory.setInputDecorator(new InputDecorator()
{
@Override
public InputStream decorate(IOContext context,InputStream inputStream) throws IOException
{
return new FramedSnappyCompressorInputStream(inputStream);
}
@Override
public InputStream decorate(IOContext context,byte[] bytes,int offset,int length) throws IOException
{
return new FramedSnappyCompressorInputStream(new ByteArrayInputStream(bytes,offset,length));
}
@Override
public Reader decorate(IOContext context,Reader reader) throws IOException
{
return new InputStreamReader(new FramedSnappyCompressorInputStream(new ReaderInputStream(reader)),UTF8);
}
});
jsonFactory.setOutputDecorator(new OutputDecorator()
{
@Override
public OutputStream decorate(IOContext context,OutputStream outputStream) throws IOException
{
return new FramedSnappyCompressorOutputStream(outputStream);
}
@Override
public Writer decorate(IOContext context,Writer writer) throws IOException
{
return new OutputStreamWriter(new FramedSnappyCompressorOutputStream(new WriterOutputStream(writer,UTF8)));
}
});
SNAPPY_OBJECT_MAPPER=new ObjectMapper(jsonFactory).
disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).
disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).
setSerializationInclusion(JsonInclude.Include.NON_NULL).
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).
registerModule(INT_RANGE_MODULE).
registerModule(JODA_MODULE).
registerModule(TAGS_MODULE);
}
This is not a JMH brenchmark but I made sure I warmed before I took these times:Json size: 1743kb
Json time: 17.322ms
Smile size: 624kb
Smile time: 12.619ms
Compressed Smile size: 556kb
Compressed Smile time: 12.003ms
Snappy size: 196kb
Snappy time: 89.368msGuido.