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


Java ValueStateDescriptor类代码示例

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


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

示例1: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<AbstractStatisticsWrapper<AisMessage>> descriptor =
      new ValueStateDescriptor<AbstractStatisticsWrapper<AisMessage>>("trajectoryStatistics",
          TypeInformation.of(new TypeHint<AbstractStatisticsWrapper<AisMessage>>() {}));

  statisticsOfTrajectory = getRuntimeContext().getState(descriptor);

}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:10,代码来源:AisStreamEnricher.java

示例2: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
/**
 * Override open from RichFunctions set
 * This method allow the retrieval of the state and set it as queryable
 */
@Override
@SuppressWarnings("unchecked")
public void open(Configuration config) {
    ValueStateDescriptor descriptor =
            new ValueStateDescriptor(
                    "consumption",
                    LampConsumption.class); // default value of the state, if nothing was set
    this.consumption = getRuntimeContext().getState(descriptor);
    descriptor.setQueryable("consumption-list-api");
}
 
开发者ID:ProjectEmber,项目名称:project-ember,代码行数:15,代码来源:EmberConsumptionMean.java

示例3: FlinkCombiningStateWithContext

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
FlinkCombiningStateWithContext(
    KeyedStateBackend<ByteBuffer> flinkStateBackend,
    StateTag<CombiningState<InputT, AccumT, OutputT>> address,
    CombineWithContext.CombineFnWithContext<InputT, AccumT, OutputT> combineFn,
    StateNamespace namespace,
    Coder<AccumT> accumCoder,
    FlinkStateInternals<K> flinkStateInternals,
    CombineWithContext.Context context) {

  this.namespace = namespace;
  this.address = address;
  this.combineFn = combineFn;
  this.flinkStateBackend = flinkStateBackend;
  this.flinkStateInternals = flinkStateInternals;
  this.context = context;

  flinkStateDescriptor = new ValueStateDescriptor<>(
      address.getId(), new CoderTypeSerializer<>(accumCoder));
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:FlinkStateInternals.java

示例4: initializeState

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void initializeState(StateInitializationContext context) throws Exception {
	super.initializeState(context);

	if (nfaOperatorState == null) {
		nfaOperatorState = getRuntimeContext().getState(
			new ValueStateDescriptor<>(
					NFA_OPERATOR_STATE_NAME,
					new NFA.NFASerializer<>(inputSerializer)));
	}

	if (elementQueueState == null) {
		elementQueueState = getRuntimeContext().getMapState(
				new MapStateDescriptor<>(
						EVENT_QUEUE_STATE_NAME,
						LongSerializer.INSTANCE,
						new ListSerializer<>(inputSerializer)
				)
		);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:AbstractKeyedCEPPatternOperator.java

示例5: testValueStateNullAsDefaultValue

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
/**
 * Verify that {@link ValueStateDescriptor} allows {@code null} as default.
 */
@Test
public void testValueStateNullAsDefaultValue() throws Exception {
	AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);

	ValueStateDescriptor<String> kvId = new ValueStateDescriptor<>("id", String.class, null);

	ValueState<String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);

	backend.setCurrentKey(1);
	assertNull(state.value());

	state.update("Ciao");
	assertEquals("Ciao", state.value());

	state.clear();
	assertNull(state.value());

	backend.dispose();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:StateBackendTestBase.java

示例6: testValueStateDefaultValue

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
/**
 * Verify that an empty {@code ValueState} will yield the default value.
 */
@Test
public void testValueStateDefaultValue() throws Exception {
	AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);

	ValueStateDescriptor<String> kvId = new ValueStateDescriptor<>("id", String.class, "Hello");

	ValueState<String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);

	backend.setCurrentKey(1);
	assertEquals("Hello", state.value());

	state.update("Ciao");
	assertEquals("Ciao", state.value());

	state.clear();
	assertEquals("Hello", state.value());

	backend.dispose();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:StateBackendTestBase.java

示例7: testCopyDefaultValue

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Test
public void testCopyDefaultValue() throws Exception {
	final AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);

	ValueStateDescriptor<IntValue> kvId = new ValueStateDescriptor<>("id", IntValue.class, new IntValue(-1));

	ValueState<IntValue> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);

	backend.setCurrentKey(1);
	IntValue default1 = state.value();

	backend.setCurrentKey(2);
	IntValue default2 = state.value();

	assertNotNull(default1);
	assertNotNull(default2);
	assertEquals(default1, default2);
	assertFalse(default1 == default2);

	backend.dispose();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:StateBackendTestBase.java

示例8: asQueryableState

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
/**
 * Publishes the keyed stream as a queryable ValueState instance.
 *
 * @param queryableStateName Name under which to the publish the queryable state instance
 * @param stateDescriptor State descriptor to create state instance from
 * @return Queryable state instance
 */
@PublicEvolving
public QueryableStateStream<KEY, T> asQueryableState(
		String queryableStateName,
		ValueStateDescriptor<T> stateDescriptor) {

	transform("Queryable state: " + queryableStateName,
			getType(),
			new QueryableValueStateOperator<>(queryableStateName, stateDescriptor));

	stateDescriptor.initializeSerializerUnlessSet(getExecutionConfig());

	return new QueryableStateStream<>(
			queryableStateName,
			stateDescriptor,
			getKeyType().createSerializer(getExecutionConfig()));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:KeyedStream.java

示例9: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open() throws Exception {
	super.open();

	if (serializedInitialValue == null) {
		throw new RuntimeException("No initial value was serialized for the fold " +
				"operator. Probably the setOutputType method was not called.");
	}

	try (ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue);
		DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais)) {
		initialValue = outTypeSerializer.deserialize(in);
	}

	ValueStateDescriptor<OUT> stateId = new ValueStateDescriptor<>(STATE_NAME, outTypeSerializer);
	values = getPartitionedState(stateId);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:StreamGroupedFold.java

示例10: testValueStateInstantiation

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

示例11: initializeState

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void initializeState(StateInitializationContext context) throws Exception {
    super.initializeState(context);

    if (this.engineState == null) {
        this.engineState = getRuntimeContext().getState(new ValueStateDescriptor<>(ESPER_SERVICE_PROVIDER_STATE, new EsperEngineSerializer()));
    }
}
 
开发者ID:phil3k3,项目名称:flink-esper,代码行数:9,代码来源:SelectEsperStreamOperator.java

示例12: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<PriorityQueue<Tuple3<String, Long, String>>> descriptor =
      new ValueStateDescriptor<>(
      // state name
          "sorted-raw-messages",
          // type information of state
          TypeInformation.of(new TypeHint<PriorityQueue<Tuple3<String, Long, String>>>() {}));
  queueState = getRuntimeContext().getState(descriptor);
}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:11,代码来源:RawMessagesSorter.java

示例13: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<Long> descriptor =
      new ValueStateDescriptor<Long>("lastTimestamp", TypeInformation.of(new TypeHint<Long>() {}));
  lastTimestamp = getRuntimeContext().getState(descriptor);

}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:8,代码来源:StreamPlayer.java

示例14: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open(Configuration config) {
  ValueStateDescriptor<PriorityQueue<AisMessage>> descriptor = new ValueStateDescriptor<>(
  // state name
      "sorted-ais-messages",
      // type information of state
      TypeInformation.of(new TypeHint<PriorityQueue<AisMessage>>() {}));
  queueState = getRuntimeContext().getState(descriptor);
}
 
开发者ID:ehabqadah,项目名称:in-situ-processing-datAcron,代码行数:10,代码来源:AisMessagesStreamSorter.java

示例15: open

import org.apache.flink.api.common.state.ValueStateDescriptor; //导入依赖的package包/类
@Override
public void open(Configuration parameters) throws Exception {
	ValueStateDescriptor<EventStateMachine.State> descriptor = new ValueStateDescriptor<>(
			"state", // the state name
			TypeInformation.of(EventStateMachine.State.class)); // type information
	state = getRuntimeContext().getState(descriptor);
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:8,代码来源:EventStateMachineMapper.java


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