本文整理汇总了Java中com.hazelcast.nio.serialization.StreamSerializer类的典型用法代码示例。如果您正苦于以下问题:Java StreamSerializer类的具体用法?Java StreamSerializer怎么用?Java StreamSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamSerializer类属于com.hazelcast.nio.serialization包,在下文中一共展示了StreamSerializer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSerializer
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<LongAccumulator>() {
@Override
public int getTypeId() {
return SerializerHookConstants.LONG_ACC;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, LongAccumulator object) throws IOException {
out.writeLong(object.get());
}
@Override
public LongAccumulator read(ObjectDataInput in) throws IOException {
return new LongAccumulator(in.readLong());
}
};
}
示例2: createSerializer
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Tuple2>() {
@Override
public void write(ObjectDataOutput out, Tuple2 t) throws IOException {
out.writeObject(t.f0());
out.writeObject(t.f1());
}
@Override
public Tuple2 read(ObjectDataInput in) throws IOException {
return tuple2(in.readObject(), in.readObject());
}
@Override
public int getTypeId() {
return SerializerHookConstants.TUPLE2;
}
@Override
public void destroy() {
}
};
}
示例3: createSerializer
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Entry>() {
@Override
public int getTypeId() {
return SerializerHookConstants.MAP_ENTRY;
}
@Override
public void write(ObjectDataOutput out, Entry object) throws IOException {
out.writeObject(object.getKey());
out.writeObject(object.getValue());
}
@Override
public Entry read(ObjectDataInput in) throws IOException {
return entry(in.readObject(), in.readObject());
}
@Override
public void destroy() {
}
};
}
示例4: createSerializer
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<SnapshotBarrier>() {
@Override
public int getTypeId() {
return SerializerHookConstants.SNAPSHOT_BARRIER;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, SnapshotBarrier object) throws IOException {
out.writeLong(object.snapshotId());
}
@Override
public SnapshotBarrier read(ObjectDataInput in) throws IOException {
return new SnapshotBarrier(in.readLong());
}
};
}
示例5: createSerializer
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Watermark>() {
@Override
public int getTypeId() {
return SerializerHookConstants.WATERMARK;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, Watermark object) throws IOException {
out.writeLong(object.timestamp());
}
@Override
public Watermark read(ObjectDataInput in) throws IOException {
return new Watermark(in.readLong());
}
};
}
示例6: serializeAndDeserializeObject
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
public static <T> T serializeAndDeserializeObject(StreamSerializer<T> serializer, T input) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectDataOutputStream odos = new ObjectDataOutputStream(os, mockSerializationService);
serializer.write(odos, input);
ObjectDataInputStream odis = new ObjectDataInputStream(new ByteArrayInputStream(os.toByteArray()),
mockSerializationService);
return serializer.read(odis);
}
示例7: KryoSerializerHook
import com.hazelcast.nio.serialization.StreamSerializer; //导入依赖的package包/类
public KryoSerializerHook() {
StreamSerializer<KryoMarker> serializer;
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
cl.loadClass("com.esotericsoftware.kryo.Kryo");
Class<? extends StreamSerializer<KryoMarker>> serializerClass;
serializerClass = (Class<? extends StreamSerializer<KryoMarker>>) cl
.loadClass("org.hazelcast.example.kryo.KryoAvailableSerializer");
serializer = serializerClass.newInstance();
} catch (ReflectiveOperationException e) {
serializer = new KryoUnavailableSerializer();
}
this.serializer = serializer;
}