Interface ShardingStrategy
-
public interface ShardingStrategyA strategy for translating routing keys into actual shard identifiersWith the exception of the
initialize(ShardingStrategyInitializationContext)method which is invoked only once at startup, all methods could be invoked in parallel by independent threads. Implementations must thus be thread-safe.Ported from Search 5:
org.hibernate.search.store.ShardIdentifierProvider.- Author:
- Emmanuel Bernard, Hardy Ferentschik, Sanne Grinovero (C) 2013 Red Hat Inc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidinitialize(ShardingStrategyInitializationContext context)Initializes the sharding strategy.StringtoShardIdentifier(String documentId, String routingKey)Returns the shard identifier corresponding to the given document ID and routing key.Set<String>toShardIdentifiers(Set<String> routingKeys)Returns all the shard identifiers that can be assigned to the given routing keys bytoShardIdentifier(String, String).
-
-
-
Method Detail
-
initialize
void initialize(ShardingStrategyInitializationContext context)
Initializes the sharding strategy.- Parameters:
context- The initialization context, giving access to configuration and environment. The sharding strategy is expected to callShardingStrategyInitializationContext.shardIdentifiers(Set).
-
toShardIdentifier
String toShardIdentifier(String documentId, String routingKey)
Returns the shard identifier corresponding to the given document ID and routing key.Called in particular when indexing documents.
- Parameters:
documentId- A document identifier. Nevernull.routingKey- A routing key. Nevernull.- Returns:
- A shard identifiers corresponding to the given document ID and routing key. Never
null.
-
toShardIdentifiers
Set<String> toShardIdentifiers(Set<String> routingKeys)
Returns all the shard identifiers that can be assigned to the given routing keys bytoShardIdentifier(String, String).Called in particular when searching.
- Parameters:
routingKeys- A set of routing keys. Nevernull, never empty.- Returns:
- All the shard identifiers that can be assigned to the given routing keys.
-
-