org.hibernate.search.store

## Interface ShardIdentifierProvider

- All Known Implementing Classes:
    ShardIdentifierProviderTemplate

      public interface ShardIdentifierProvider

  Implementations provide the identifiers of those shards to be taken into account by the engine when working with specified entities or queries.

  Implementation notes:

  With exception of the `initialize(Properties, BuildContext)` method which is invoked only once at startup, all other methods could be invoked in parallel by independent threads; implementations must thus be thread-safe.

  Instead of implementing this interface directly, implementations should be derived from `ShardIdentifierProviderTemplate` as new methods might be added to this interface in future releases.

  Author:
    Emmanuel Bernard, Hardy Ferentschik, Sanne Grinovero (C) 2013 Red Hat Inc.
  Experimental
    The exact method signatures are likely to change in future.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<String>` | `getAllShardIdentifiers()` Returns the list of all currently known shard identifiers.
    `String` | `getShardIdentifier(Class<?> entityType, Serializable id, String idAsString, Document document)` Determine the shard identifier for the given entity.
    `Set<String>` | `getShardIdentifiersForDeletion(Class<?> entity, Serializable id, String idInString)` Returns the set of shard identifiers for a deletion.
    `Set<String>` | `getShardIdentifiersForQuery(FullTextFilterImplementor[] fullTextFilters)` Returns the set of shard identifiers for a query given the applied filters.
    `void` | `initialize(Properties properties, BuildContext buildContext)` Initialize this provider.

- - ### Method Detail

    - #### initialize

          void initialize(Properties properties,
                          BuildContext buildContext)

      Initialize this provider.
      This method is invoked only once per instance and before any other method is invoked.
      Parameters:
        `properties` - The configuration properties
        `buildContext` - The build context available during bootstrapping

    - #### getShardIdentifier

          String getShardIdentifier(Class<?> entityType,
                                    Serializable id,
                                    String idAsString,
                                    Document document)

      Determine the shard identifier for the given entity.
      Note: Implementations will usually inspect a specific fieldable of the document in order to determine the shard identifier, for example a customer id or a language code.
      Concurrency: this method could be invoked concurrently. That means you could have multiple invocations of `getShardIdentifier(Class, Serializable, String, Document)`, `getShardIdentifiersForQuery(FullTextFilterImplementor[])`, `getAllShardIdentifiers()`.
      Parameters:
        `entityType` - the type of the entity
        `id` - the id of the entity
        `idAsString` - the entity id transformed as string via the appropriate document id bridge
        `document` - the Lucene document for the entity with the given id
      Returns:
        the shard identifier to which the entity specified by the given parameters belongs to.

    - #### getShardIdentifiersForQuery

          Set<String> getShardIdentifiersForQuery(FullTextFilterImplementor[] fullTextFilters)

      Returns the set of shard identifiers for a query given the applied filters. The method allows to limit the shards a given query targets depending on the selected filters.
      Concurrency: this method could be invoked concurrently. That means you could have multiple invocations of `getShardIdentifier(Class, Serializable, String, Document)`, `getShardIdentifiersForQuery(FullTextFilterImplementor[])`, `getAllShardIdentifiers()`.
      Parameters:
        `fullTextFilters` - the filters which are applied to the current query
      Returns:
        the set of shard identifiers this query should target

    - #### getShardIdentifiersForDeletion

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

      Returns the set of shard identifiers for a deletion.
      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

    - #### getAllShardIdentifiers

          Set<String> getAllShardIdentifiers()

      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 `getShardIdentifier(Class, Serializable, String, Document)`, `getShardIdentifiersForQuery(FullTextFilterImplementor[])`, `getAllShardIdentifiers()`.
      Returns:
        the set of all currently known shard identifiers.

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