org.apache.hadoop.contrib.index.example
Class HashingDistributionPolicy

java.lang.Object
  extended by org.apache.hadoop.contrib.index.example.HashingDistributionPolicy
All Implemented Interfaces:
IDistributionPolicy

public class HashingDistributionPolicy
extends Object
implements IDistributionPolicy

Choose a shard for each insert or delete based on document id hashing. Do NOT use this distribution policy when the number of shards changes.


Constructor Summary
HashingDistributionPolicy()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashingDistributionPolicy

public HashingDistributionPolicy()
Method Detail

init

public void init(Shard[] shards)
Description copied from interface: IDistributionPolicy
Initialization. It must be called before any chooseShard() is called.

Specified by:
init in interface IDistributionPolicy

chooseShardForInsert

public int chooseShardForInsert(DocumentID key)
Description copied from interface: IDistributionPolicy
Choose a shard to send an insert request.

Specified by:
chooseShardForInsert in interface IDistributionPolicy
Returns:
the index of the chosen shard

chooseShardForDelete

public int chooseShardForDelete(DocumentID key)
Description copied from interface: IDistributionPolicy
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.

Specified by:
chooseShardForDelete in interface IDistributionPolicy
Returns:
the index of the chosen shard, -1 if all the shards are chosen


Copyright © 2009 The Apache Software Foundation