当前位置: 首页>>代码示例>>Java>>正文


Java StreamSerializer类代码示例

本文整理汇总了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());
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:25,代码来源:AccumulatorSerializerHooks.java

示例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() {
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:25,代码来源:DataModelSerializerHooks.java

示例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() {
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:25,代码来源:MapEntryHook.java

示例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());
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:24,代码来源:ExecutionSerializerHooks.java

示例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());
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:24,代码来源:CoreSerializerHooks.java

示例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);
}
 
开发者ID:jerrinot,项目名称:subzero,代码行数:9,代码来源:TestUtils.java

示例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;
}
 
开发者ID:noctarius,项目名称:hazelcast-unaware-serialization,代码行数:16,代码来源:KryoSerializerHook.java


注:本文中的com.hazelcast.nio.serialization.StreamSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。