Class HeapKeyedStateBackend<K>

    • Method Detail

      • create

        @Nonnull
        public <T extends HeapPriorityQueueElement & PriorityComparable<? super T> & Keyed<?>> KeyGroupedInternalPriorityQueue<T> create​(@Nonnull
                                                                                                                                         String stateName,
                                                                                                                                         @Nonnull
                                                                                                                                         org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)
        Description copied from interface: PriorityQueueSetFactory
        Type Parameters:
        T - type of the stored elements.
        Parameters:
        stateName - unique name for associated with this queue.
        byteOrderedElementSerializer - a serializer that with a format that is lexicographically ordered in alignment with elementPriorityComparator.
        Returns:
        the queue with the specified unique name.
      • create

        public <T extends HeapPriorityQueueElement & PriorityComparable<? super T> & Keyed<?>> KeyGroupedInternalPriorityQueue<T> create​(@Nonnull
                                                                                                                                         String stateName,
                                                                                                                                         @Nonnull
                                                                                                                                         org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer,
                                                                                                                                         boolean allowFutureMetadataUpdates)
        Description copied from interface: PriorityQueueSetFactory
        Type Parameters:
        T - type of the stored elements.
        Parameters:
        stateName - unique name for associated with this queue.
        byteOrderedElementSerializer - a serializer that with a format that is lexicographically ordered in alignment with elementPriorityComparator.
        allowFutureMetadataUpdates - whether allow metadata to update in the future or not.
        Returns:
        the queue with the specified unique name.
      • getKeys

        public <N> Stream<K> getKeys​(String state,
                                     N namespace)
        Parameters:
        state - State variable for which existing keys will be returned.
        namespace - Namespace for which existing keys will be returned.
        Returns:
        A stream of all keys for the given state and namespace. Modifications to the state during iterating over it keys are not supported.
      • getKeysAndNamespaces

        public <N> Stream<org.apache.flink.api.java.tuple.Tuple2<K,​N>> getKeysAndNamespaces​(String state)
        Parameters:
        state - State variable for which existing keys will be returned.
        Returns:
        A stream of all keys for the given state and namespace. Modifications to the state during iterating over it keys are not supported. Implementations go not make any ordering guarantees about the returned tupes. Two records with the same key or namespace may not be returned near each other in the stream.
      • createOrUpdateInternalState

        @Nonnull
        public <N,​SV,​SEV,​S extends org.apache.flink.api.common.state.State,​IS extends S> IS createOrUpdateInternalState​(@Nonnull
                                                                                                                                                org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                                                                @Nonnull
                                                                                                                                                org.apache.flink.api.common.state.StateDescriptor<S,​SV> stateDesc,
                                                                                                                                                @Nonnull
                                                                                                                                                StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory)
                                                                                                                                         throws Exception
        Description copied from interface: KeyedStateFactory
        Creates or updates internal state and returns a new InternalKvState.
        Type Parameters:
        N - The type of the namespace.
        SV - The type of the stored state value.
        SEV - The type of the stored state value or entry for collection types (list or map).
        S - The type of the public API state.
        IS - The type of internal state.
        Parameters:
        namespaceSerializer - TypeSerializer for the state namespace.
        stateDesc - The StateDescriptor that contains the name of the state.
        snapshotTransformFactory - factory of state snapshot transformer.
        Throws:
        Exception
      • createOrUpdateInternalState

        @Nonnull
        public <N,​SV,​SEV,​S extends org.apache.flink.api.common.state.State,​IS extends S> IS createOrUpdateInternalState​(@Nonnull
                                                                                                                                                org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                                                                @Nonnull
                                                                                                                                                org.apache.flink.api.common.state.StateDescriptor<S,​SV> stateDesc,
                                                                                                                                                @Nonnull
                                                                                                                                                StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory,
                                                                                                                                                boolean allowFutureMetadataUpdates)
                                                                                                                                         throws Exception
        Description copied from interface: KeyedStateFactory
        Creates or updates internal state and returns a new InternalKvState.
        Type Parameters:
        N - The type of the namespace.
        SV - The type of the stored state value.
        SEV - The type of the stored state value or entry for collection types (list or map).
        S - The type of the public API state.
        IS - The type of internal state.
        Parameters:
        namespaceSerializer - TypeSerializer for the state namespace.
        stateDesc - The StateDescriptor that contains the name of the state.
        snapshotTransformFactory - factory of state snapshot transformer.
        allowFutureMetadataUpdates - whether allow metadata to update in the future or not.
        Throws:
        Exception
      • snapshot

        @Nonnull
        public RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot​(long checkpointId,
                                                                         long timestamp,
                                                                         @Nonnull
                                                                         CheckpointStreamFactory streamFactory,
                                                                         @Nonnull
                                                                         CheckpointOptions checkpointOptions)
                                                                  throws Exception
        Description copied from interface: Snapshotable
        Operation that writes a snapshot into a stream that is provided by the given CheckpointStreamFactory and returns a @RunnableFuture that gives a state handle to the snapshot. It is up to the implementation if the operation is performed synchronous or asynchronous. In the later case, the returned Runnable must be executed first before obtaining the handle.
        Parameters:
        checkpointId - The ID of the checkpoint.
        timestamp - The timestamp of the checkpoint.
        streamFactory - The factory that we can use for writing our state to streams.
        checkpointOptions - Options for how to perform this checkpoint.
        Returns:
        A runnable future that will yield a StateObject.
        Throws:
        Exception
      • notifyCheckpointComplete

        public void notifyCheckpointComplete​(long checkpointId)
      • notifyCheckpointAborted

        public void notifyCheckpointAborted​(long checkpointId)
      • numKeyValueStateEntries

        @VisibleForTesting
        public int numKeyValueStateEntries()
        Returns the total number of state entries across all keys/namespaces.
      • numKeyValueStateEntries

        @VisibleForTesting
        public int numKeyValueStateEntries​(Object namespace)
        Returns the total number of state entries across all keys for the given namespace.
      • getLocalRecoveryConfig

        @VisibleForTesting
        public LocalRecoveryConfig getLocalRecoveryConfig()