Interface ShardingStrategy
public interface ShardingStrategy
A strategy for translating routing keys into actual shard identifiers
With 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
Modifier and TypeMethodDescriptionvoid
Initializes the sharding strategy.toShardIdentifier
(String documentId, String routingKey) Returns the shard identifier corresponding to the given document ID and routing key.toShardIdentifiers
(Set<String> routingKeys) Returns all the shard identifiers that can be assigned to the given routing keys bytoShardIdentifier(String, String)
.
-
Method Details
-
initialize
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
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
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.
-