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


Java StateDescriptor.getSerializer方法代码示例

本文整理汇总了Java中org.apache.flink.api.common.state.StateDescriptor.getSerializer方法的典型用法代码示例。如果您正苦于以下问题:Java StateDescriptor.getSerializer方法的具体用法?Java StateDescriptor.getSerializer怎么用?Java StateDescriptor.getSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.api.common.state.StateDescriptor的用法示例。


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

示例1: testValueStateInstantiation

import org.apache.flink.api.common.state.StateDescriptor; //导入方法依赖的package包/类
@Test
public void testValueStateInstantiation() throws Exception {

	final ExecutionConfig config = new ExecutionConfig();
	config.registerKryoType(Path.class);

	final AtomicReference<Object> descriptorCapture = new AtomicReference<>();

	StreamingRuntimeContext context = new StreamingRuntimeContext(
			createDescriptorCapturingMockOp(descriptorCapture, config),
			createMockEnvironment(),
			Collections.<String, Accumulator<?, ?>>emptyMap());

	ValueStateDescriptor<TaskInfo> descr = new ValueStateDescriptor<>("name", TaskInfo.class);
	context.getState(descr);

	StateDescriptor<?, ?> descrIntercepted = (StateDescriptor<?, ?>) descriptorCapture.get();
	TypeSerializer<?> serializer = descrIntercepted.getSerializer();

	// check that the Path class is really registered, i.e., the execution config was applied
	assertTrue(serializer instanceof KryoSerializer);
	assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:StreamingRuntimeContextTest.java

示例2: validateStateDescriptorConfigured

import org.apache.flink.api.common.state.StateDescriptor; //导入方法依赖的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

示例3: testReducingStateInstantiation

import org.apache.flink.api.common.state.StateDescriptor; //导入方法依赖的package包/类
@Test
public void testReducingStateInstantiation() throws Exception {

	final ExecutionConfig config = new ExecutionConfig();
	config.registerKryoType(Path.class);

	final AtomicReference<Object> descriptorCapture = new AtomicReference<>();

	StreamingRuntimeContext context = new StreamingRuntimeContext(
			createDescriptorCapturingMockOp(descriptorCapture, config),
			createMockEnvironment(),
			Collections.<String, Accumulator<?, ?>>emptyMap());

	@SuppressWarnings("unchecked")
	ReduceFunction<TaskInfo> reducer = (ReduceFunction<TaskInfo>) mock(ReduceFunction.class);

	ReducingStateDescriptor<TaskInfo> descr =
			new ReducingStateDescriptor<>("name", reducer, TaskInfo.class);

	context.getReducingState(descr);

	StateDescriptor<?, ?> descrIntercepted = (StateDescriptor<?, ?>) descriptorCapture.get();
	TypeSerializer<?> serializer = descrIntercepted.getSerializer();

	// check that the Path class is really registered, i.e., the execution config was applied
	assertTrue(serializer instanceof KryoSerializer);
	assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:29,代码来源:StreamingRuntimeContextTest.java

示例4: getKvState

import org.apache.flink.api.common.state.StateDescriptor; //导入方法依赖的package包/类
/**
 * Returns a future holding the request result.
 *
 * <p>If the server does not serve a KvState instance with the given ID,
 * the Future will be failed with a {@link UnknownKvStateID}.
 *
 * <p>If the KvState instance does not hold any data for the given key
 * and namespace, the Future will be failed with a {@link UnknownKeyOrNamespace}.
 *
 * <p>All other failures are forwarded to the Future.
 *
 * @param jobId                     JobID of the job the queryable state belongs to.
 * @param queryableStateName        Name under which the state is queryable.
 * @param key			            The key that the state we request is associated with.
 * @param namespace					The namespace of the state.
 * @param keyTypeInfo				The {@link TypeInformation} of the keys.
 * @param namespaceTypeInfo			The {@link TypeInformation} of the namespace.
 * @param stateDescriptor			The {@link StateDescriptor} of the state we want to query.
 * @return Future holding the result.
 */
@PublicEvolving
public <K, V, N> Future<V> getKvState(
		final JobID jobId,
		final String queryableStateName,
		final K key,
		final N namespace,
		final TypeInformation<K> keyTypeInfo,
		final TypeInformation<N> namespaceTypeInfo,
		final StateDescriptor<?, V> stateDescriptor) {

	Preconditions.checkNotNull(stateDescriptor);

	// initialize the value serializer based on the execution config.
	stateDescriptor.initializeSerializerUnlessSet(executionConfig);
	TypeSerializer<V> stateSerializer = stateDescriptor.getSerializer();

	return getKvState(jobId, queryableStateName, key,
			namespace, keyTypeInfo, namespaceTypeInfo, stateSerializer);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:40,代码来源:QueryableStateClient.java


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