## org.apache.hadoop.contrib.index.mapred
Interface IDistributionPolicy

All Known Implementing Classes:
  HashingDistributionPolicy, RoundRobinDistributionPolicy

    public interface IDistributionPolicy

A distribution policy decides, given a document with a document id, which one shard the request should be sent to if the request is an insert, and which shard(s) the request should be sent to if the request is a delete.

Method Summary
`int` `chooseShardForDelete(DocumentID key)` Choose a shard or all shards to send a delete request.
`int` `chooseShardForInsert(DocumentID key)` Choose a shard to send an insert request.
`void` `init(Shard[] shards)` Initialization.

Method Detail

### init

    void init(Shard[] shards)

  Initialization. It must be called before any chooseShard() is called.

  Parameters:
    `shards` -

### chooseShardForInsert

    int chooseShardForInsert(DocumentID key)

  Choose a shard to send an insert request.

  Parameters:
    `key` -
  Returns:
    the index of the chosen shard

### chooseShardForDelete

    int chooseShardForDelete(DocumentID key)

  Choose a shard or all shards to send a delete request. E.g. a round-robin distribution policy would send a delete request to all the shards. -1 represents all the shards.

  Parameters:
    `key` -
  Returns:
    the index of the chosen shard, -1 if all the shards are chosen

Copyright © 2009 The Apache Software Foundation