org.hibernate.search.store

## Class ShardIdentifierProviderTemplate

- java.lang.Object
- - org.hibernate.search.store.ShardIdentifierProviderTemplate

- All Implemented Interfaces:
    ShardIdentifierProvider

      public abstract class ShardIdentifierProviderTemplate
      extends Object
      implements ShardIdentifierProvider

  Recommended parent class to create custom `ShardIdentifierProvider` implementations. Sub-classes must provide a no-arg constructor.
  Author:
    Sanne Grinovero
  Experimental
    The exact method signatures are likely to change in future.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ShardIdentifierProviderTemplate()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addShard(String shardName)`
    `Set<String>` | `getAllShardIdentifiers()` Returns the list of all currently known shard identifiers.
    `Set<String>` | `getShardIdentifiersForDeletion(Class<?> entity, Serializable id, String idInString)` Override this method if the mapping to a specific shard can be inferred just from the pair (id, type).
    `Set<String>` | `getShardIdentifiersForQuery(FullTextFilterImplementor[] fullTextFilters)` Potentially suited to be overridden if you are able to narrow down the shard selection based on the active FullTextFilters.
    `void` | `initialize(Properties properties, BuildContext buildContext)` Initialize this provider.
    `protected abstract Set<String>` | `loadInitialShardNames(Properties properties, BuildContext buildContext)`

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

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

    - ### Methods inherited from interface org.hibernate.search.store.ShardIdentifierProvider

      `getShardIdentifier`

- - ### Constructor Detail

    - #### ShardIdentifierProviderTemplate

          public ShardIdentifierProviderTemplate()

  - ### Method Detail

    - #### initialize

          public final void initialize(Properties properties,
                                       BuildContext buildContext)

      Description copied from interface: `ShardIdentifierProvider`
      Initialize this provider.
      This method is invoked only once per instance and before any other method is invoked.
      Specified by:
        `initialize` in interface `ShardIdentifierProvider`
      Parameters:
        `properties` - The configuration properties
        `buildContext` - The build context available during bootstrapping

    - #### loadInitialShardNames

          protected abstract Set<String> loadInitialShardNames(Properties properties,
                                                               BuildContext buildContext)

    - #### addShard

          protected final void addShard(String shardName)

    - #### getAllShardIdentifiers

          public final Set<String> getAllShardIdentifiers()

      Description copied from interface: `ShardIdentifierProvider`
      Returns the list of all currently known shard identifiers.
      Note: The list can vary between calls!
      Concurrency: this method could be invoked concurrently. That means you could have multiple invocations of `ShardIdentifierProvider.getShardIdentifier(Class, Serializable, String, Document)`, `ShardIdentifierProvider.getShardIdentifiersForQuery(FullTextFilterImplementor[])`, `ShardIdentifierProvider.getAllShardIdentifiers()`.
      Specified by:
        `getAllShardIdentifiers` in interface `ShardIdentifierProvider`
      Returns:
        the set of all currently known shard identifiers.

    - #### getShardIdentifiersForQuery

          public Set<String> getShardIdentifiersForQuery(FullTextFilterImplementor[] fullTextFilters)

      Potentially suited to be overridden if you are able to narrow down the shard selection based on the active FullTextFilters.
      Specified by:
        `getShardIdentifiersForQuery` in interface `ShardIdentifierProvider`
      Parameters:
        `fullTextFilters` - the filters which are applied to the current query
      Returns:
        the set of shard identifiers this query should target

    - #### getShardIdentifiersForDeletion

          public Set<String> getShardIdentifiersForDeletion(Class<?> entity,
                                                            Serializable id,
                                                            String idInString)

      Override this method if the mapping to a specific shard can be inferred just from the pair (id, type). The default implementation will perform delete and purge operations on all known indexes.
      Specified by:
        `getShardIdentifiersForDeletion` in interface `ShardIdentifierProvider`
      Parameters:
        `entity` - the type of the deleted entity
        `id` - the id or null
        `idInString` - the transformed id or null
      Returns:
        the target IndexManager for the deletion operation

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved