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.

Method Summary
 Set<String> getAllShardIdentifiers()
          Returns the list of all currently known shard identifiers.
 String getShardIdentifier(Class<?> entityType, Serializable id, String idAsString, org.apache.lucene.document.Document document)
          Determine the shard identifier for the given entity.
 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,
                          org.apache.lucene.document.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

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–2013 Hibernate. All rights reserved.