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


Java JavaSerializer类代码示例

本文整理汇总了Java中com.esotericsoftware.kryo.serializers.JavaSerializer的典型用法代码示例。如果您正苦于以下问题:Java JavaSerializer类的具体用法?Java JavaSerializer怎么用?Java JavaSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaSerializer类属于com.esotericsoftware.kryo.serializers包,在下文中一共展示了JavaSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFoldWindowState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testFoldWindowState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<String> src = env.fromElements("abc");

	SingleOutputStreamOperator<?> result = src
			.keyBy(new KeySelector<String, String>() {
				@Override
				public String getKey(String value) {
					return null;
				}
			})
			.timeWindow(Time.milliseconds(1000))
			.fold(new File("/"), new FoldFunction<String, File>() {

				@Override
				public File fold(File a, String e) {
					return null;
				}
			});

	validateStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:StateDescriptorPassingTest.java

示例2: serializationObject

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
private <T extends Serializable> byte[] serializationObject(T obj) {
    Kryo kryo = new Kryo();
    kryo.setReferences(false);
    kryo.register(obj.getClass(), new JavaSerializer());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:22,代码来源:TestMapDataSerialization.java

示例3: testReduceWindowState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testReduceWindowState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.keyBy(new KeySelector<File, String>() {
				@Override
				public String getKey(File value) {
					return null;
				}
			})
			.timeWindow(Time.milliseconds(1000))
			.reduce(new ReduceFunction<File>() {

				@Override
				public File reduce(File value1, File value2) {
					return null;
				}
			});

	validateStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:StateDescriptorPassingTest.java

示例4: testApplyWindowState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testApplyWindowState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.keyBy(new KeySelector<File, String>() {
				@Override
				public String getKey(File value) {
					return null;
				}
			})
			.timeWindow(Time.milliseconds(1000))
			.apply(new WindowFunction<File, String, String, TimeWindow>() {
				@Override
				public void apply(String s, TimeWindow window,
									Iterable<File> input, Collector<String> out) {}
			});

	validateListStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:StateDescriptorPassingTest.java

示例5: testProcessWindowState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testProcessWindowState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.keyBy(new KeySelector<File, String>() {
				@Override
				public String getKey(File value) {
					return null;
				}
			})
			.timeWindow(Time.milliseconds(1000))
			.process(new ProcessWindowFunction<File, String, String, TimeWindow>() {
				@Override
				public void process(String s, Context ctx,
						Iterable<File> input, Collector<String> out) {}
			});

	validateListStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:StateDescriptorPassingTest.java

示例6: testProcessAllWindowState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testProcessAllWindowState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.timeWindowAll(Time.milliseconds(1000))
			.process(new ProcessAllWindowFunction<File, String, TimeWindow>() {
				@Override
				public void process(Context ctx, Iterable<File> input, Collector<String> out) {}
			});

	validateListStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:StateDescriptorPassingTest.java

示例7: testFoldWindowAllState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testFoldWindowAllState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<String> src = env.fromElements("abc");

	SingleOutputStreamOperator<?> result = src
			.timeWindowAll(Time.milliseconds(1000))
			.fold(new File("/"), new FoldFunction<String, File>() {

				@Override
				public File fold(File a, String e) {
					return null;
				}
			});

	validateStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:StateDescriptorPassingTest.java

示例8: testReduceWindowAllState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testReduceWindowAllState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.timeWindowAll(Time.milliseconds(1000))
			.reduce(new ReduceFunction<File>() {

				@Override
				public File reduce(File value1, File value2) {
					return null;
				}
			});

	validateStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:StateDescriptorPassingTest.java

示例9: testApplyWindowAllState

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Test
public void testApplyWindowAllState() throws Exception {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.registerTypeWithKryoSerializer(File.class, JavaSerializer.class);

	DataStream<File> src = env.fromElements(new File("/"));

	SingleOutputStreamOperator<?> result = src
			.timeWindowAll(Time.milliseconds(1000))
			.apply(new AllWindowFunction<File, String, TimeWindow>() {
				@Override
				public void apply(TimeWindow window, Iterable<File> input, Collector<String> out) {}
			});

	validateListStateDescriptorConfigured(result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:StateDescriptorPassingTest.java

示例10: validateListStateDescriptorConfigured

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
private void validateListStateDescriptorConfigured(SingleOutputStreamOperator<?> result) {
	OneInputTransformation<?, ?> transform = (OneInputTransformation<?, ?>) result.getTransformation();
	WindowOperator<?, ?, ?, ?, ?> op = (WindowOperator<?, ?, ?, ?, ?>) transform.getOperator();
	StateDescriptor<?, ?> descr = op.getStateDescriptor();

	assertTrue(descr instanceof ListStateDescriptor);

	ListStateDescriptor<?> listDescr = (ListStateDescriptor<?>) descr;

	// this would be the first statement to fail if state descriptors were not properly initialized
	TypeSerializer<?> serializer = listDescr.getSerializer();
	assertTrue(serializer instanceof ListSerializer);

	TypeSerializer<?> elementSerializer = listDescr.getElementSerializer();
	assertTrue(elementSerializer instanceof KryoSerializer);

	Kryo kryo = ((KryoSerializer<?>) elementSerializer).getKryo();

	assertTrue("serializer registration was not properly passed on",
			kryo.getSerializer(File.class) instanceof JavaSerializer);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:StateDescriptorPassingTest.java

示例11: getDefaultSerializer

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Override
public Serializer getDefaultSerializer(Class type) {
    if (type == null) {
        throw new IllegalArgumentException("type cannot be null.");
    }

    if (!type.isArray() && !ReflectionUtils.checkZeroArgConstructor(type)) {
        if (logger.isWarnEnabled()) {
            logger.warn(type + " has no zero-arg constructor and this will affect the serialization performance");
        }
        return new JavaSerializer();
    }
    return super.getDefaultSerializer(type);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:15,代码来源:CompatibleKryo.java

示例12: deserializationObject

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Serializable> T deserializationObject(byte[] obj,
                                                         Class<T> clazz) {
    Kryo kryo = new Kryo();
    kryo.setReferences(false);
    kryo.register(clazz, new JavaSerializer());

    ByteArrayInputStream bais = new ByteArrayInputStream(
            obj);
    Input input = new Input(bais);
    return (T) kryo.readClassAndObject(input);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:13,代码来源:TestMapDataSerialization.java

示例13: validateStateDescriptorConfigured

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
private void validateStateDescriptorConfigured(SingleOutputStreamOperator<?> result) {
	OneInputTransformation<?, ?> transform = (OneInputTransformation<?, ?>) result.getTransformation();
	WindowOperator<?, ?, ?, ?, ?> op = (WindowOperator<?, ?, ?, ?, ?>) transform.getOperator();
	StateDescriptor<?, ?> descr = op.getStateDescriptor();

	// this would be the first statement to fail if state descriptors were not properly initialized
	TypeSerializer<?> serializer = descr.getSerializer();
	assertTrue(serializer instanceof KryoSerializer);

	Kryo kryo = ((KryoSerializer<?>) serializer).getKryo();

	assertTrue("serializer registration was not properly passed on",
			kryo.getSerializer(File.class) instanceof JavaSerializer);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:StateDescriptorPassingTest.java

示例14: getDefaultSerializer

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Override
public Serializer getDefaultSerializer(Class type) {
    if (type == null) {
        throw new IllegalArgumentException("type cannot be null.");
    }

    if (!type.isArray() && !ReflectionUtils.checkZeroArgConstructor(type)) {
        if (log.isWarnEnabled()) {
            log.warn(type + " has no zero-arg constructor and this will affect the serialization performance");
        }
        return new JavaSerializer();
    }
    return super.getDefaultSerializer(type);
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:15,代码来源:CompatibleKryo.java

示例15: beforeAll

import com.esotericsoftware.kryo.serializers.JavaSerializer; //导入依赖的package包/类
@Override
public boolean beforeAll() {
    kryo = new Kryo();
    kryo.register(POJO.class, new JavaSerializer());
    pojo = new POJO();
    return true;
}
 
开发者ID:olivierperez,项目名称:java-bench,代码行数:8,代码来源:KryoBench.java


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