messif.pivotselection
Class TwoDistantIncrementalPivotChooser

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

public class TwoDistantIncrementalPivotChooser
extends AbstractPivotChooser
implements java.io.Serializable, BucketFilterAfterAdd

This class provides a privot chooser that selects maximally two pivots. The chooser is incrementally maintaining two objects that have a maximal distance.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class messif.pivotselection.AbstractPivotChooser
counterBucketReadBuckets, counterObjectDistComp, counterPivotDistComp, counterPivotReadBuckets, preselectedPivots, sampleProviders
 
Constructor Summary
TwoDistantIncrementalPivotChooser()
          Creates a new instance of TwoDistantIncrementalPivotChooser.
 
Method Summary
 void clear()
          Clears the list of preselected pivots and reset the distance between them.
 void filterAfterAdd(LocalAbstractObject object, LocalBucket bucket)
          Method for preselecting pivots as they are added to a bucket.
 LocalAbstractObject getLeftPivot()
          Returns the left (first) pivot.
 float getPivotsDistance()
          Returns the distance of the actually selected pivots or zero if there is not enough objects seen yet.
 LocalAbstractObject getRightPivot()
          Returns the right (second) pivot.
protected  void selectPivot(int count, AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
          Select at least count pitvots and add them by addPivot method.
protected  void updateSelectedPivots(LocalAbstractObject object)
          Updates the selected pivots.
 
Methods inherited from class messif.pivotselection.AbstractPivotChooser
addPivot, 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

TwoDistantIncrementalPivotChooser

public TwoDistantIncrementalPivotChooser()
Creates a new instance of TwoDistantIncrementalPivotChooser.

Method Detail

getLeftPivot

public LocalAbstractObject getLeftPivot()
Returns the left (first) pivot.

Returns:
the left pivot

getRightPivot

public LocalAbstractObject getRightPivot()
Returns the right (second) pivot.

Returns:
the right pivot

getPivotsDistance

public float getPivotsDistance()
Returns the distance of the actually selected pivots or zero if there is not enough objects seen yet.

Returns:
the distance of the actually selected pivots

filterAfterAdd

public void filterAfterAdd(LocalAbstractObject object,
                           LocalBucket bucket)
Method for preselecting pivots as they are added to a bucket.

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

selectPivot

protected void selectPivot(int count,
                           AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
                    throws java.lang.IllegalArgumentException
Select at least count pitvots and add them by addPivot method.

Specified by:
selectPivot in class AbstractPivotChooser
Parameters:
count - Number of pivots to generate
sampleSetIterator - Iterator over the sample set of objects to choose new pivots from
Throws:
java.lang.IllegalArgumentException - if more than two pivots are requested

updateSelectedPivots

protected void updateSelectedPivots(LocalAbstractObject object)
Updates the selected pivots. If the distance between the left or the right pivot is bigger than current pivots' distance, the object replaces the other pivot.

Parameters:
object - the object to check

clear

public void clear()
Clears the list of preselected pivots and reset the distance between them.

Overrides:
clear in class AbstractPivotChooser