org.apache.flink.api.common.state.AppendingState Java Examples
The following examples show how to use
org.apache.flink.api.common.state.AppendingState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
/** * Drops all state for the given window and calls * {@link Trigger#clear(Window, Trigger.TriggerContext)}. * * <p>The caller must ensure that the * correct key is set in the state backend and the triggerContext object. */ private void clearAllState( W window, AppendingState<IN, ACC> windowState, MergingWindowSet<W> mergingWindows) throws Exception { windowState.clear(); triggerContext.clear(); processContext.window = window; processContext.clear(); if (mergingWindows != null) { mergingWindows.retireWindow(window); mergingWindows.persist(); } }
Example #2
Source File: RegularWindowOperatorContractTest.java From flink with Apache License 2.0 | 5 votes |
/** * Special method for creating a {@link WindowOperator} with a custom {@link StateDescriptor} * for the window contents state. */ private <W extends Window, ACC, OUT> KeyedOneInputStreamOperatorTestHarness<Integer, Integer, OUT> createWindowOperator( WindowAssigner<Integer, W> assigner, Trigger<Integer, W> trigger, long allowedLatenss, StateDescriptor<? extends AppendingState<Integer, ACC>, ?> stateDescriptor, InternalWindowFunction<ACC, OUT, Integer, W> windowFunction) throws Exception { KeySelector<Integer, Integer> keySelector = new KeySelector<Integer, Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getKey(Integer value) throws Exception { return value; } }; @SuppressWarnings("unchecked") WindowOperator<Integer, Integer, ACC, OUT, W> operator = new WindowOperator<>( assigner, assigner.getWindowSerializer(new ExecutionConfig()), keySelector, IntSerializer.INSTANCE, stateDescriptor, windowFunction, trigger, allowedLatenss, null /* late output tag */); return new KeyedOneInputStreamOperatorTestHarness<>( operator, keySelector, BasicTypeInfo.INT_TYPE_INFO); }
Example #3
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
/** * Drops all state for the given window and calls * {@link Trigger#clear(Window, Trigger.TriggerContext)}. * * <p>The caller must ensure that the * correct key is set in the state backend and the triggerContext object. */ private void clearAllState( W window, AppendingState<IN, ACC> windowState, MergingWindowSet<W> mergingWindows) throws Exception { windowState.clear(); triggerContext.clear(); processContext.window = window; processContext.clear(); if (mergingWindows != null) { mergingWindows.retireWindow(window); mergingWindows.persist(); } }
Example #4
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new {@code WindowOperator} based on the given policies and user functions. */ public WindowOperator( WindowAssigner<? super IN, W> windowAssigner, TypeSerializer<W> windowSerializer, KeySelector<IN, K> keySelector, TypeSerializer<K> keySerializer, StateDescriptor<? extends AppendingState<IN, ACC>, ?> windowStateDescriptor, InternalWindowFunction<ACC, OUT, K, W> windowFunction, Trigger<? super IN, ? super W> trigger, long allowedLateness, OutputTag<IN> lateDataOutputTag) { super(windowFunction); checkArgument(!(windowAssigner instanceof BaseAlignedWindowAssigner), "The " + windowAssigner.getClass().getSimpleName() + " cannot be used with a WindowOperator. " + "This assigner is only used with the AccumulatingProcessingTimeWindowOperator and " + "the AggregatingProcessingTimeWindowOperator"); checkArgument(allowedLateness >= 0); checkArgument(windowStateDescriptor == null || windowStateDescriptor.isSerializerInitialized(), "window state serializer is not properly initialized"); this.windowAssigner = checkNotNull(windowAssigner); this.windowSerializer = checkNotNull(windowSerializer); this.keySelector = checkNotNull(keySelector); this.keySerializer = checkNotNull(keySerializer); this.windowStateDescriptor = windowStateDescriptor; this.trigger = checkNotNull(trigger); this.allowedLateness = allowedLateness; this.lateDataOutputTag = lateDataOutputTag; setChainingStrategy(ChainingStrategy.ALWAYS); }
Example #5
Source File: RegularWindowOperatorContractTest.java From flink with Apache License 2.0 | 5 votes |
/** * Special method for creating a {@link WindowOperator} with a custom {@link StateDescriptor} * for the window contents state. */ private <W extends Window, ACC, OUT> KeyedOneInputStreamOperatorTestHarness<Integer, Integer, OUT> createWindowOperator( WindowAssigner<Integer, W> assigner, Trigger<Integer, W> trigger, long allowedLatenss, StateDescriptor<? extends AppendingState<Integer, ACC>, ?> stateDescriptor, InternalWindowFunction<ACC, OUT, Integer, W> windowFunction) throws Exception { KeySelector<Integer, Integer> keySelector = new KeySelector<Integer, Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getKey(Integer value) throws Exception { return value; } }; @SuppressWarnings("unchecked") WindowOperator<Integer, Integer, ACC, OUT, W> operator = new WindowOperator<>( assigner, assigner.getWindowSerializer(new ExecutionConfig()), keySelector, IntSerializer.INSTANCE, stateDescriptor, windowFunction, trigger, allowedLatenss, null /* late output tag */); return new KeyedOneInputStreamOperatorTestHarness<>( operator, keySelector, BasicTypeInfo.INT_TYPE_INFO); }
Example #6
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new {@code WindowOperator} based on the given policies and user functions. */ public WindowOperator( WindowAssigner<? super IN, W> windowAssigner, TypeSerializer<W> windowSerializer, KeySelector<IN, K> keySelector, TypeSerializer<K> keySerializer, StateDescriptor<? extends AppendingState<IN, ACC>, ?> windowStateDescriptor, InternalWindowFunction<ACC, OUT, K, W> windowFunction, Trigger<? super IN, ? super W> trigger, long allowedLateness, OutputTag<IN> lateDataOutputTag) { super(windowFunction); checkArgument(!(windowAssigner instanceof BaseAlignedWindowAssigner), "The " + windowAssigner.getClass().getSimpleName() + " cannot be used with a WindowOperator. " + "This assigner is only used with the AccumulatingProcessingTimeWindowOperator and " + "the AggregatingProcessingTimeWindowOperator"); checkArgument(allowedLateness >= 0); checkArgument(windowStateDescriptor == null || windowStateDescriptor.isSerializerInitialized(), "window state serializer is not properly initialized"); this.windowAssigner = checkNotNull(windowAssigner); this.windowSerializer = checkNotNull(windowSerializer); this.keySelector = checkNotNull(keySelector); this.keySerializer = checkNotNull(keySerializer); this.windowStateDescriptor = windowStateDescriptor; this.trigger = checkNotNull(trigger); this.allowedLateness = allowedLateness; this.lateDataOutputTag = lateDataOutputTag; setChainingStrategy(ChainingStrategy.ALWAYS); }
Example #7
Source File: RegularWindowOperatorContractTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Special method for creating a {@link WindowOperator} with a custom {@link StateDescriptor} * for the window contents state. */ private <W extends Window, ACC, OUT> KeyedOneInputStreamOperatorTestHarness<Integer, Integer, OUT> createWindowOperator( WindowAssigner<Integer, W> assigner, Trigger<Integer, W> trigger, long allowedLatenss, StateDescriptor<? extends AppendingState<Integer, ACC>, ?> stateDescriptor, InternalWindowFunction<ACC, OUT, Integer, W> windowFunction) throws Exception { KeySelector<Integer, Integer> keySelector = new KeySelector<Integer, Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getKey(Integer value) throws Exception { return value; } }; @SuppressWarnings("unchecked") WindowOperator<Integer, Integer, ACC, OUT, W> operator = new WindowOperator<>( assigner, assigner.getWindowSerializer(new ExecutionConfig()), keySelector, IntSerializer.INSTANCE, stateDescriptor, windowFunction, trigger, allowedLatenss, null /* late output tag */); return new KeyedOneInputStreamOperatorTestHarness<>( operator, keySelector, BasicTypeInfo.INT_TYPE_INFO); }
Example #8
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Drops all state for the given window and calls * {@link Trigger#clear(Window, Trigger.TriggerContext)}. * * <p>The caller must ensure that the * correct key is set in the state backend and the triggerContext object. */ private void clearAllState( W window, AppendingState<IN, ACC> windowState, MergingWindowSet<W> mergingWindows) throws Exception { windowState.clear(); triggerContext.clear(); processContext.window = window; processContext.clear(); if (mergingWindows != null) { mergingWindows.retireWindow(window); mergingWindows.persist(); } }
Example #9
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates a new {@code WindowOperator} based on the given policies and user functions. */ public WindowOperator( WindowAssigner<? super IN, W> windowAssigner, TypeSerializer<W> windowSerializer, KeySelector<IN, K> keySelector, TypeSerializer<K> keySerializer, StateDescriptor<? extends AppendingState<IN, ACC>, ?> windowStateDescriptor, InternalWindowFunction<ACC, OUT, K, W> windowFunction, Trigger<? super IN, ? super W> trigger, long allowedLateness, OutputTag<IN> lateDataOutputTag) { super(windowFunction); checkArgument(!(windowAssigner instanceof BaseAlignedWindowAssigner), "The " + windowAssigner.getClass().getSimpleName() + " cannot be used with a WindowOperator. " + "This assigner is only used with the AccumulatingProcessingTimeWindowOperator and " + "the AggregatingProcessingTimeWindowOperator"); checkArgument(allowedLateness >= 0); checkArgument(windowStateDescriptor == null || windowStateDescriptor.isSerializerInitialized(), "window state serializer is not properly initialized"); this.windowAssigner = checkNotNull(windowAssigner); this.windowSerializer = checkNotNull(windowSerializer); this.keySelector = checkNotNull(keySelector); this.keySerializer = checkNotNull(keySerializer); this.windowStateDescriptor = windowStateDescriptor; this.trigger = checkNotNull(trigger); this.allowedLateness = allowedLateness; this.lateDataOutputTag = lateDataOutputTag; setChainingStrategy(ChainingStrategy.ALWAYS); }
Example #10
Source File: QueryableAppendingStateOperator.java From flink with Apache License 2.0 | 4 votes |
public QueryableAppendingStateOperator( String registrationName, StateDescriptor<? extends AppendingState<IN, ?>, ?> stateDescriptor) { super(registrationName, stateDescriptor); }
Example #11
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override @VisibleForTesting @SuppressWarnings("unchecked, rawtypes") public StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?> getStateDescriptor() { return (StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?>) evictingWindowStateDescriptor; }
Example #12
Source File: QueryableAppendingStateOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public QueryableAppendingStateOperator( String registrationName, StateDescriptor<? extends AppendingState<IN, ?>, ?> stateDescriptor) { super(registrationName, stateDescriptor); }
Example #13
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@VisibleForTesting public StateDescriptor<? extends AppendingState<IN, ACC>, ?> getStateDescriptor() { return windowStateDescriptor; }
Example #14
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@VisibleForTesting public StateDescriptor<? extends AppendingState<IN, ACC>, ?> getStateDescriptor() { return windowStateDescriptor; }
Example #15
Source File: QueryableAppendingStateOperator.java From flink with Apache License 2.0 | 4 votes |
public QueryableAppendingStateOperator( String registrationName, StateDescriptor<? extends AppendingState<IN, ?>, ?> stateDescriptor) { super(registrationName, stateDescriptor); }
Example #16
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override @VisibleForTesting @SuppressWarnings("unchecked, rawtypes") public StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?> getStateDescriptor() { return (StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?>) evictingWindowStateDescriptor; }
Example #17
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@VisibleForTesting public StateDescriptor<? extends AppendingState<IN, ACC>, ?> getStateDescriptor() { return windowStateDescriptor; }
Example #18
Source File: EvictingWindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override @VisibleForTesting @SuppressWarnings("unchecked, rawtypes") public StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?> getStateDescriptor() { return (StateDescriptor<? extends AppendingState<IN, Iterable<IN>>, ?>) evictingWindowStateDescriptor; }