org.apache.storm.redis.state

## Class RedisKeyValueStateIterator<K,V>

- java.lang.Object
- - org.apache.storm.state.BaseStateIterator<K,V,byte[],byte[]>
  - - org.apache.storm.state.BaseBinaryStateIterator<K,V>
    - - org.apache.storm.redis.state.RedisKeyValueStateIterator<K,V>

- All Implemented Interfaces:
    Iterator<Map.Entry<K,V>>

      public class RedisKeyValueStateIterator<K,V>
      extends BaseBinaryStateIterator<K,V>

  An iterator over `RedisKeyValueState`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RedisKeyValueStateIterator(byte[] namespace, RedisCommandsInstanceContainer container, Iterator<Map.Entry<byte[],byte[]>> pendingPrepareIterator, Iterator<Map.Entry<byte[],byte[]>> pendingCommitIterator, int chunkSize, Serializer<K> keySerializer, Serializer<V> valueSerializer)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected K` | `decodeKey(byte[] key)` Decode key to convert byte array to state key type.
    `protected V` | `decodeValue(byte[] value)` Decode value to convert byte array to state value type.
    `protected boolean` | `isEndOfDataFromStorage()` Check whether end of data is reached from storage state KVs.
    `protected boolean` | `isTombstoneValue(byte[] value)` Check whether the value is tombstone (deletion mark) value.
    `protected Iterator<Map.Entry<byte[],byte[]>>` | `loadChunkFromStateStorage()` Load some part of state KVs from storage and returns iterator of cached data from storage.

    - ### Methods inherited from class org.apache.storm.state.BaseStateIterator

      `hasNext, next, remove`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

- - ### Constructor Detail

    - #### RedisKeyValueStateIterator

          public RedisKeyValueStateIterator(byte[] namespace,
                                            RedisCommandsInstanceContainer container,
                                            Iterator<Map.Entry<byte[],byte[]>> pendingPrepareIterator,
                                            Iterator<Map.Entry<byte[],byte[]>> pendingCommitIterator,
                                            int chunkSize,
                                            Serializer<K> keySerializer,
                                            Serializer<V> valueSerializer)

      Constructor.

      Parameters:
        `namespace` - The namespace of State
        `container` - The instance of RedisCommandsInstanceContainer
        `pendingPrepareIterator` - The iterator of pendingPrepare
        `pendingCommitIterator` - The iterator of pendingCommit
        `chunkSize` - The size of chunk to get entries from Redis
        `keySerializer` - The serializer of key
        `valueSerializer` - The serializer of value

  - ### Method Detail

    - #### loadChunkFromStateStorage

          protected Iterator<Map.Entry<byte[],byte[]>> loadChunkFromStateStorage()

      Description copied from class: `BaseBinaryStateIterator`

      Load some part of state KVs from storage and returns iterator of cached data from storage.

      Specified by:
        `loadChunkFromStateStorage` in class `BaseBinaryStateIterator<K,V>`
      Returns:
        Iterator of loaded state KVs

    - #### isEndOfDataFromStorage

          protected boolean isEndOfDataFromStorage()

      Description copied from class: `BaseBinaryStateIterator`

      Check whether end of data is reached from storage state KVs.

      Specified by:
        `isEndOfDataFromStorage` in class `BaseBinaryStateIterator<K,V>`
      Returns:
        whether end of data is reached from storage state KVs

    - #### decodeKey

          protected K decodeKey(byte[] key)

      Description copied from class: `BaseBinaryStateIterator`

      Decode key to convert byte array to state key type.

      Specified by:
        `decodeKey` in class `BaseBinaryStateIterator<K,V>`
      Parameters:
        `key` - byte array encoded key
      Returns:
        Decoded value of key

    - #### decodeValue

          protected V decodeValue(byte[] value)

      Description copied from class: `BaseBinaryStateIterator`

      Decode value to convert byte array to state value type.

      Specified by:
        `decodeValue` in class `BaseBinaryStateIterator<K,V>`
      Parameters:
        `value` - byte array encoded value
      Returns:
        Decoded value of value

    - #### isTombstoneValue

          protected boolean isTombstoneValue(byte[] value)

      Description copied from class: `BaseBinaryStateIterator`

      Check whether the value is tombstone (deletion mark) value.

      Specified by:
        `isTombstoneValue` in class `BaseBinaryStateIterator<K,V>`
      Parameters:
        `value` - the value to check
      Returns:
        true if the value is tombstone, false otherwise

Copyright © 2021 The Apache Software Foundation. All rights reserved.