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 Details

    • 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 call ShardingStrategyInitializationContext.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. Never null.
      routingKey - A routing key. Never null.
      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 by toShardIdentifier(String, String).

      Called in particular when searching.

      Parameters:
      routingKeys - A set of routing keys. Never null, never empty.
      Returns:
      All the shard identifiers that can be assigned to the given routing keys.