org.apache.flink.runtime.state.internal.InternalMergingState Java Examples
The following examples show how to use
org.apache.flink.runtime.state.internal.InternalMergingState.
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-CEPplus with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { if (mergedWindows != null && mergedWindows.size() > 0) { try { S rawState = getKeyedStateBackend().getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }
Example #2
Source File: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { try { S rawState = stateBackend.getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } }
Example #3
Source File: WindowOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState( StateDescriptor<S, ?> stateDescriptor) { if (mergedWindows != null && mergedWindows.size() > 0) { try { State state = WindowOperator.this.getOrCreateKeyedState( windowSerializer, stateDescriptor); if (state instanceof InternalMergingState) { ((InternalMergingState<K, W, ?, ?, ?>) state).mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }
Example #4
Source File: WindowOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { if (mergedWindows != null && mergedWindows.size() > 0) { try { S rawState = getKeyedStateBackend().getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }
Example #5
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { try { S rawState = stateBackend.getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } }
Example #6
Source File: WindowOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState( StateDescriptor<S, ?> stateDescriptor) { if (mergedWindows != null && mergedWindows.size() > 0) { try { State state = WindowOperator.this.getOrCreateKeyedState( windowSerializer, stateDescriptor); if (state instanceof InternalMergingState) { ((InternalMergingState<K, W, ?, ?, ?>) state).mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }
Example #7
Source File: WindowOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { if (mergedWindows != null && mergedWindows.size() > 0) { try { S rawState = getKeyedStateBackend().getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }
Example #8
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 6 votes |
@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { try { S rawState = stateBackend.getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } }
Example #9
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void open() throws Exception { super.open(); this.numLateRecordsDropped = metrics.counter(LATE_ELEMENTS_DROPPED_METRIC_NAME); timestampedCollector = new TimestampedCollector<>(output); internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); triggerContext = new Context(null, null); processContext = new WindowContext(null); windowAssignerContext = new WindowAssigner.WindowAssignerContext() { @Override public long getCurrentProcessingTime() { return internalTimerService.currentProcessingTime(); } }; // create (or restore) the state that hold the actual window contents // NOTE - the state may be null in the case of the overriding evicting window operator if (windowStateDescriptor != null) { windowState = (InternalAppendingState<K, W, IN, ACC, ACC>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor); } // create the typed and helper states for merging windows if (windowAssigner instanceof MergingWindowAssigner) { // store a typed reference for the state of merging windows - sanity check if (windowState instanceof InternalMergingState) { windowMergingState = (InternalMergingState<K, W, IN, ACC, ACC>) windowState; } // TODO this sanity check should be here, but is prevented by an incorrect test (pending validation) // TODO see WindowOperatorTest.testCleanupTimerWithEmptyFoldingStateForSessionWindows() // TODO activate the sanity check once resolved // else if (windowState != null) { // throw new IllegalStateException( // "The window uses a merging assigner, but the window state is not mergeable."); // } @SuppressWarnings("unchecked") final Class<Tuple2<W, W>> typedTuple = (Class<Tuple2<W, W>>) (Class<?>) Tuple2.class; final TupleSerializer<Tuple2<W, W>> tupleSerializer = new TupleSerializer<>( typedTuple, new TypeSerializer[] {windowSerializer, windowSerializer}); final ListStateDescriptor<Tuple2<W, W>> mergingSetsStateDescriptor = new ListStateDescriptor<>("merging-window-set", tupleSerializer); // get the state that stores the merging sets mergingSetsState = (InternalListState<K, VoidNamespace, Tuple2<W, W>>) getOrCreateKeyedState(VoidNamespaceSerializer.INSTANCE, mergingSetsStateDescriptor); mergingSetsState.setCurrentNamespace(VoidNamespace.INSTANCE); } }
Example #10
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void open() throws Exception { super.open(); this.numLateRecordsDropped = metrics.counter(LATE_ELEMENTS_DROPPED_METRIC_NAME); timestampedCollector = new TimestampedCollector<>(output); internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); triggerContext = new Context(null, null); processContext = new WindowContext(null); windowAssignerContext = new WindowAssigner.WindowAssignerContext() { @Override public long getCurrentProcessingTime() { return internalTimerService.currentProcessingTime(); } }; // create (or restore) the state that hold the actual window contents // NOTE - the state may be null in the case of the overriding evicting window operator if (windowStateDescriptor != null) { windowState = (InternalAppendingState<K, W, IN, ACC, ACC>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor); } // create the typed and helper states for merging windows if (windowAssigner instanceof MergingWindowAssigner) { // store a typed reference for the state of merging windows - sanity check if (windowState instanceof InternalMergingState) { windowMergingState = (InternalMergingState<K, W, IN, ACC, ACC>) windowState; } // TODO this sanity check should be here, but is prevented by an incorrect test (pending validation) // TODO see WindowOperatorTest.testCleanupTimerWithEmptyFoldingStateForSessionWindows() // TODO activate the sanity check once resolved // else if (windowState != null) { // throw new IllegalStateException( // "The window uses a merging assigner, but the window state is not mergeable."); // } @SuppressWarnings("unchecked") final Class<Tuple2<W, W>> typedTuple = (Class<Tuple2<W, W>>) (Class<?>) Tuple2.class; final TupleSerializer<Tuple2<W, W>> tupleSerializer = new TupleSerializer<>( typedTuple, new TypeSerializer[] {windowSerializer, windowSerializer}); final ListStateDescriptor<Tuple2<W, W>> mergingSetsStateDescriptor = new ListStateDescriptor<>("merging-window-set", tupleSerializer); // get the state that stores the merging sets mergingSetsState = (InternalListState<K, VoidNamespace, Tuple2<W, W>>) getOrCreateKeyedState(VoidNamespaceSerializer.INSTANCE, mergingSetsStateDescriptor); mergingSetsState.setCurrentNamespace(VoidNamespace.INSTANCE); } }
Example #11
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void open() throws Exception { super.open(); this.numLateRecordsDropped = metrics.counter(LATE_ELEMENTS_DROPPED_METRIC_NAME); timestampedCollector = new TimestampedCollector<>(output); internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); triggerContext = new Context(null, null); processContext = new WindowContext(null); windowAssignerContext = new WindowAssigner.WindowAssignerContext() { @Override public long getCurrentProcessingTime() { return internalTimerService.currentProcessingTime(); } }; // create (or restore) the state that hold the actual window contents // NOTE - the state may be null in the case of the overriding evicting window operator if (windowStateDescriptor != null) { windowState = (InternalAppendingState<K, W, IN, ACC, ACC>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor); } // create the typed and helper states for merging windows if (windowAssigner instanceof MergingWindowAssigner) { // store a typed reference for the state of merging windows - sanity check if (windowState instanceof InternalMergingState) { windowMergingState = (InternalMergingState<K, W, IN, ACC, ACC>) windowState; } // TODO this sanity check should be here, but is prevented by an incorrect test (pending validation) // TODO see WindowOperatorTest.testCleanupTimerWithEmptyFoldingStateForSessionWindows() // TODO activate the sanity check once resolved // else if (windowState != null) { // throw new IllegalStateException( // "The window uses a merging assigner, but the window state is not mergeable."); // } @SuppressWarnings("unchecked") final Class<Tuple2<W, W>> typedTuple = (Class<Tuple2<W, W>>) (Class<?>) Tuple2.class; final TupleSerializer<Tuple2<W, W>> tupleSerializer = new TupleSerializer<>( typedTuple, new TypeSerializer[] {windowSerializer, windowSerializer}); final ListStateDescriptor<Tuple2<W, W>> mergingSetsStateDescriptor = new ListStateDescriptor<>("merging-window-set", tupleSerializer); // get the state that stores the merging sets mergingSetsState = (InternalListState<K, VoidNamespace, Tuple2<W, W>>) getOrCreateKeyedState(VoidNamespaceSerializer.INSTANCE, mergingSetsStateDescriptor); mergingSetsState.setCurrentNamespace(VoidNamespace.INSTANCE); } }