com.h3c.util.persistence.cassandra.index

## Class StringShardStrategy

- java.lang.Object
- - com.h3c.util.persistence.cassandra.index.StringShardStrategy

- All Implemented Interfaces:
    ShardStrategy<String,String>

      public class StringShardStrategy
      extends Object
      implements ShardStrategy<String,String>

  Shard strategy to distribute `String` type column names into several row keys based on the first char (lower-case converted) of the `String` value.

  Examples:

  Prefix | Column Name | Sharded Row Key
  --- | --- | ---
  my_prefix | Hello World | my_prefix_h
  my_prefix | hello world | my_prefix_h
  Null | Hello World | h
  Empty | Hello World | h

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringShardStrategy()` Creates a shard strategy.
    `StringShardStrategy(String rowKeyPrefix)` Creates a shard strategy.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getRowKey(String columnName)` Gets the row key to be used for the given column name.

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

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

- - ### Constructor Detail

    - #### StringShardStrategy

          public StringShardStrategy()

      Creates a shard strategy.

    - #### StringShardStrategy

          public StringShardStrategy(String rowKeyPrefix)

      Creates a shard strategy.
      Parameters:
        `rowKeyPrefix` - row key prefix.

  - ### Method Detail

    - #### getRowKey

          public String getRowKey(String columnName)

      Description copied from interface: `ShardStrategy`
      Gets the row key to be used for the given column name.
      Specified by:
        `getRowKey` in interface `ShardStrategy<String,String>`
      Parameters:
        `columnName` - column name to fins a sharded key for. This could be part of the column name if the shard strategy is applied to a single component of a composite column name.
      Returns:
        a sharded key for the given column name.

Copyright © 2014. All Rights Reserved.