2018-10-29 17:19:37 +08:00
|
|
|
/*
|
2020-01-02 07:24:59 -05:00
|
|
|
* Copyright (C) 2015-2020 Lightbend Inc. <https://www.lightbend.com>
|
2015-07-02 12:12:34 +02:00
|
|
|
*/
|
2018-03-13 23:45:55 +09:00
|
|
|
|
2017-03-16 09:30:00 +01:00
|
|
|
package jdocs.ddata.protobuf;
|
2015-07-02 12:12:34 +02:00
|
|
|
|
2017-03-16 09:30:00 +01:00
|
|
|
import jdocs.ddata.TwoPhaseSet;
|
2015-07-02 12:12:34 +02:00
|
|
|
|
|
|
|
|
import akka.actor.ExtendedActorSystem;
|
|
|
|
|
|
|
|
|
|
public class TwoPhaseSetSerializerWithCompression extends TwoPhaseSetSerializer {
|
|
|
|
|
public TwoPhaseSetSerializerWithCompression(ExtendedActorSystem system) {
|
|
|
|
|
super(system);
|
|
|
|
|
}
|
2019-01-12 04:00:53 +08:00
|
|
|
|
|
|
|
|
// #compression
|
2015-07-02 12:12:34 +02:00
|
|
|
@Override
|
|
|
|
|
public byte[] toBinary(Object obj) {
|
|
|
|
|
if (obj instanceof TwoPhaseSet) {
|
|
|
|
|
return compress(twoPhaseSetToProto((TwoPhaseSet) obj));
|
|
|
|
|
} else {
|
2019-01-12 04:00:53 +08:00
|
|
|
throw new IllegalArgumentException("Can't serialize object of type " + obj.getClass());
|
2015-07-02 12:12:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object fromBinaryJava(byte[] bytes, Class<?> manifest) {
|
|
|
|
|
return twoPhaseSetFromBinary(decompress(bytes));
|
|
|
|
|
}
|
2019-01-12 04:00:53 +08:00
|
|
|
// #compression
|
2015-07-02 12:12:34 +02:00
|
|
|
}
|