Menu

Tree [c10029] master /
 History

HTTPS access


File Date Author Commit
 src 2016-10-23 Emmanuel Keller Emmanuel Keller [34ca39] Add unit tests
 .gitignore 2016-10-16 Emmanuel Keller Emmanuel Keller [bbb075] First compilable version
 .travis.yml 2016-10-16 Emmanuel Keller Emmanuel Keller [bbb075] First compilable version
 LICENSE 2016-10-17 Emmanuel Keller Emmanuel Keller [861eac] Update readme
 README.md 2017-05-18 Emmanuel Keller Emmanuel Keller [af33cd] Update README
 benchmark.xls 2016-10-22 Emmanuel Keller Emmanuel Keller [1441a5] Update benchmarks
 byte_size.png 2016-10-22 Emmanuel Keller Emmanuel Keller [1441a5] Update benchmarks
 pom.xml 2017-08-14 Emmanuel Keller Emmanuel Keller [c10029] Update roaring
 rate.png 2016-10-22 Emmanuel Keller Emmanuel Keller [1441a5] Update benchmarks

Read Me

Externalizor

Build Status
Maven Central
Coverage Status
Javadocs

Fast and compact serialization of Java object.

  • Concrete Collections (Map, Set, Vector, List) with compression/decompression using Snappy
  • Primitive types: int, long, short, double, float, boolean, char, byte, enum
  • Primitive array: with compression/decompression using Snappy
  • Time types: Date, LocalDate, LocalTime, LocalDateTime, Instant, Duration, Period, MonthDay, Year
  • Other types are serialized using Java's default serialization

Usage

Use the provided static methods to serialize and/or deserialize your object(s). There is two ways:
- Raw serialization: the fastest
- Compressed serialization: slower but more compact

Raw serialization (fastest)

The serialization used our Snappy based specialized compressors.

import java.io.*;
import com.qwazr.externalizor.Externalizor;

public class FastSerialization {

    public FastSerialization() {

        MyClass object = new MyClass();
        byte[] bytes;

        // Serialization

        try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
            Externalizor.serializeRaw(object, output);
            bytes = output.toByteArray();
        }

        // Deserialization

        try (ByteArrayInputStream input = new ByteArrayInputStream(bytes)) {
            MyClass object = Externalizor.deserializeRaw(input);
        }
    }
 }
 ```

### Compressed serialization (slower but more compact)

In addition of the specialized compression (snappy) a GZIP compression is used on the final serialized stream
(slower but more compact).

```java
import java.io.*;
import com.qwazr.externalizor.Externalizor;

public class CompactSerialization {

    public CompactSerialization() {

        MyClass object = new MyClass();
        byte[] bytes;

        // Serialization

        try (ByteArrayOutputStream input = new ByteArrayOutputStream()) {
            Externalizor.serialize(object, output);
            bytes = output.toByteArray();
        }

        // Deserialization

        try (ByteArrayInputStream input = new ByteArrayInputStream(bytes)) {
            object = Externalizor.deserialize(input);
        }
    }
}

Maven dependency

In Maven's central repository:
central.maven.org/maven2/com/qwazr/externalizor

Add the following dependency to your pom.xml:

<dependency>
    <groupId>com.qwazr</groupId>
    <artifactId>externalizor</artifactId>
    <version>1.3.1</version>
</dependency>

Benchmark

The code of the benchmark is here:
BenchmarkTest

  • Serialization raw: Default Java serialization without compression.
  • Serialization compressed: Default Java serialization with Gzip compression.
  • Externalizor raw: Using Externalizor without compression.
  • Externalizor compressed: Using Externalizor with Gzip compression.

Average size of the serialized objects

Bytes sizes. Smaller is better.

Byte size

Serialization/Deserialization rate

Number of serialization and deserialization per seconds. Bigger is better.

Rate

Issues

Post bug reports or feature request to the Issue Tracker:
https://github.com/qwazr/externalizor/issues

Open source license

Apache2 license