messif.pivotselection
Class OnFlyRandomPivotChooser

java.lang.Object
  extended by messif.pivotselection.AbstractPivotChooser
      extended by messif.pivotselection.RandomPivotChooser
          extended by messif.pivotselection.OnFlyRandomPivotChooser
All Implemented Interfaces:
java.io.Serializable, BucketFilter, BucketFilterAfterAdd

public class OnFlyRandomPivotChooser
extends RandomPivotChooser
implements java.io.Serializable, BucketFilterAfterAdd

OnFlyRandomPivotChooser provides the capability of selecting a random object from the whole bucket. It selects the first pivot on the fly from the objects being inserted into the bucket. Additional pivots are pick among all objects stored in the bucket. Important notice: a new-coming object causes all selected pivots to be deleted! That implies, only one object is selected by this chooser.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class messif.pivotselection.AbstractPivotChooser
counterBucketReadBuckets, counterObjectDistComp, counterPivotDistComp, counterPivotReadBuckets, preselectedPivots, sampleProviders
 
Constructor Summary
OnFlyRandomPivotChooser()
          Creates a new instance of OnFlyRandomPivotChooser
 
Method Summary
 void filterAfterAdd(LocalAbstractObject object, LocalBucket bucket)
          filterObject() Filter method used to pick one pivot at random.
 
Methods inherited from class messif.pivotselection.RandomPivotChooser
selectPivot
 
Methods inherited from class messif.pivotselection.AbstractPivotChooser
addPivot, clear, deregisterSampleProvider, getLastPivot, getNextPivot, getPivot, getPivot, iterator, registerSampleProvider, removeLastPivot, selectPivot, selectPivot, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OnFlyRandomPivotChooser

public OnFlyRandomPivotChooser()
Creates a new instance of OnFlyRandomPivotChooser

Method Detail

filterAfterAdd

public void filterAfterAdd(LocalAbstractObject object,
                           LocalBucket bucket)
filterObject() Filter method used to pick one pivot at random. This method selects one pivot at random using an incremental schema. Whenever a new object arrives we compute a random number within the interval <0,N+1) (where N is the number of object stored in this bucket). If the random number is equal to N we choose the new object as a pivot. These technique is correct and the probability of selecting each object of the bucket is the same and equal to 1/N. (This can be proved using mathematical induction applied to N). Notice that this filter erases all previously selested pivots (e.g. by getPivot(int)).

Specified by:
filterAfterAdd in interface BucketFilterAfterAdd
Parameters:
object - the inserted object
bucket - bucket, where the object is stored