org.apache.storm.cassandra.trident.state

## Class MapStateFactoryBuilder<T>

- java.lang.Object
- - org.apache.storm.cassandra.trident.state.MapStateFactoryBuilder<T>

-     public class MapStateFactoryBuilder<T>
      extends Object

  A helper for building a MapState backed by Cassandra. It internalizes some common implementation choices to simplify usage.

  In the simplest use case, a map state can be constructed with:

  StateFactory mapState = MapStateFactoryBuilder.opaque() .withTable(“mykeyspace”, “year_month_state”) .withKeys(“year”, “month”) .withJSONBinaryState(“state”) .build();

  for a cassandra table with: mykeyspace.year_month_state { year: int, month: int, state: blob }

  This will use the storm JSON serializers to convert the state to and from binary format. Other binary serializers can be used with the `withBinaryState(String, Serializer)` method.

  Storing state in explicit fields (e.g. in a field “sum” of type int) is possible by instead calling `withStateMapper(StateMapper)`. For instance, you can use `NonTransactionalTupleStateMapper`, `TransactionalTupleStateMapper` or `OpaqueTupleStateMapper` if your state values are tuples.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapStateFactoryBuilder()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `StateFactory` | `build()`
    `static <U> MapStateFactoryBuilder<U>` | `nontransactional(Map<String,Object> cassandraConf)`
    `static <U> MapStateFactoryBuilder<OpaqueValue<U>>` | `opaque(Map<String,Object> cassandraConf)`
    `static <U> MapStateFactoryBuilder<TransactionalValue<U>>` | `transactional(Map<String,Object> cassandraConf)`
    `MapStateFactoryBuilder<T>` | `withBinaryState(String stateField, Serializer<T> serializer)`
    `MapStateFactoryBuilder<T>` | `withCache(int cacheSize)`
    `protected MapStateFactoryBuilder<T>` | `withCassandraConfig(Map<String,Object> cassandraConf)`
    `MapStateFactoryBuilder<T>` | `withJSONBinaryState(String stateField)`
    `MapStateFactoryBuilder<T>` | `withKeys(String... keys)`
    `MapStateFactoryBuilder<T>` | `withMaxParallelism(Integer maxParallelism)`
    `MapStateFactoryBuilder<T>` | `withStateMapper(StateMapper<T> stateMapper)`
    `protected MapStateFactoryBuilder<T>` | `withStateType(StateType stateType)`
    `MapStateFactoryBuilder<T>` | `withTable(String keyspace, String table)`

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

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

- - ### Constructor Detail

    - #### MapStateFactoryBuilder

          public MapStateFactoryBuilder()

  - ### Method Detail

    - #### opaque

          public static <U> MapStateFactoryBuilder<OpaqueValue<U>> opaque(Map<String,Object> cassandraConf)

    - #### transactional

          public static <U> MapStateFactoryBuilder<TransactionalValue<U>> transactional(Map<String,Object> cassandraConf)

    - #### nontransactional

          public static <U> MapStateFactoryBuilder<U> nontransactional(Map<String,Object> cassandraConf)

    - #### withTable

          public MapStateFactoryBuilder<T> withTable(String keyspace,
                                                     String table)

    - #### withKeys

          public MapStateFactoryBuilder<T> withKeys(String... keys)

    - #### withMaxParallelism

          public MapStateFactoryBuilder<T> withMaxParallelism(Integer maxParallelism)

    - #### withJSONBinaryState

          public MapStateFactoryBuilder<T> withJSONBinaryState(String stateField)

    - #### withStateMapper

          public MapStateFactoryBuilder<T> withStateMapper(StateMapper<T> stateMapper)

    - #### withBinaryState

          public MapStateFactoryBuilder<T> withBinaryState(String stateField,
                                                           Serializer<T> serializer)

    - #### withStateType

          protected MapStateFactoryBuilder<T> withStateType(StateType stateType)

    - #### withCassandraConfig

          protected MapStateFactoryBuilder<T> withCassandraConfig(Map<String,Object> cassandraConf)

    - #### withCache

          public MapStateFactoryBuilder<T> withCache(int cacheSize)

    - #### build

          public StateFactory build()

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