sorter
Class Comparator

java.lang.Object
  extended by sorter.Comparator

public class Comparator
extends java.lang.Object

Uses several instances of SplitSort, one for each axis considered, to sort media.

The aim of this class is to manage a SplitSort instance for each axis considered and to ask for all comparisons necessary at a time, i.e to "group" them in order to limit the number of jobs uploaded as well as allowing a treatment of the results requiring a lot of data to be processed at the same time.

A lot of its methods are simply calls to their equivalent for each SplitSort instance in the Comparator.sorters attribute.

Author:
Leo Perrin (perrin.leo@gmail.com)

Field Summary
private  java.util.Map<java.lang.String,SplitSort> sorters
          This map must have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ].
private  MySQLbase sqlBase
          The MySQLbase database from which comparisons will be retrieved.
 
Constructor Summary
Comparator(java.util.Map<java.lang.String,SplitSort> sorter)
          Creates a Comparator instance using the SplitSorts contained in the sorter map.
Comparator(java.util.Map<java.lang.String,SplitSort> sorter, MySQLbase bdd)
          Creates a Comparator instance using the SplitSorts contained in the sorter map and links it with a MySQLbase instance.
 
Method Summary
 void demandNewComparisons(java.util.List<java.lang.Integer> greater, java.util.List<java.lang.Integer> smaller, java.util.List<java.lang.String> axes)
          Asks for unknown comparisons by modifying the value of its parameters greater, smaller and axes.
 void display()
          Displays the current state of the sort using SplitSort.display().
 void endIteration()
          Performs the last part of a quicksort iteration.
 java.util.Map<java.lang.String,java.util.List<java.lang.Integer[]>> getCurrentState()
          Returns the current state of the sort, i.e a Map indexed by the axes and containing the sorted attribute of each SplitSort contained in sorters.
 java.util.Map<java.lang.String,SplitSort> getSplitSorts()
          Returns the sorters attribute.
 java.lang.Boolean notFinished()
          Returns true while the sorting is not over.
 void sortIteration()
          Performs the first part of a quicksort iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sorters

private java.util.Map<java.lang.String,SplitSort> sorters
This map must have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ].


sqlBase

private MySQLbase sqlBase
The MySQLbase database from which comparisons will be retrieved.

Constructor Detail

Comparator

public Comparator(java.util.Map<java.lang.String,SplitSort> sorter,
                  MySQLbase bdd)
Creates a Comparator instance using the SplitSorts contained in the sorter map and links it with a MySQLbase instance.

Both of the attributes of this class are set when this constructor is called.

Parameters:
sorter - This map should have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ].
bdd - The database that will be used as the "sqlBase" attribute.

Comparator

public Comparator(java.util.Map<java.lang.String,SplitSort> sorter)
Creates a Comparator instance using the SplitSorts contained in the sorter map.

This constructor sets the value the sorter attribute, but not that of the MySQLbase ! Be careful therefore not to do anything requiring it with such an instance.

Parameters:
sorter - This map should have the following structure : [ key = axis considered, element = instance of SplitSort in charge of sorting media along this axis ].
Method Detail

notFinished

public java.lang.Boolean notFinished()
Returns true while the sorting is not over.

It equals false only if SplitSort.notFinished( ) is false for all the SplitSorts in sorters, in which case quicksort iterations must stop.

Returns:
true if the sort must continue, false otherwise (case in which it is over).

sortIteration

public void sortIteration()
Performs the first part of a quicksort iteration.

All of the SplitSort instances contained in "sorters" are asked to perform the first step of a quicksort iteration.


endIteration

public void endIteration()
Performs the last part of a quicksort iteration.

All of the SplitSort instances contained in sorters are asked to perform the last step of a quicksort iteration.


demandNewComparisons

public void demandNewComparisons(java.util.List<java.lang.Integer> greater,
                                 java.util.List<java.lang.Integer> smaller,
                                 java.util.List<java.lang.String> axes)
Asks for unknown comparisons by modifying the value of its parameters greater, smaller and axes.

Returns in the parameters greater and smaller the identifiers of the elements that require a comparison and are alleged to be respectively greater and smaller and, in axes, the axes along which the comparison must be performed.

Parameters:
greater - All the media to be compared to the pivots in the several pending quicksorts.
smaller - The pivots corresponding to the several pending quicksorts.
axes - The axes along which comparisons must be performed.

display

public void display()
Displays the current state of the sort using SplitSort.display().


getSplitSorts

public java.util.Map<java.lang.String,SplitSort> getSplitSorts()
Returns the sorters attribute.

Returns:
A Map containing the SplitSort instance used as well as the axis associated with each one of them.

getCurrentState

public java.util.Map<java.lang.String,java.util.List<java.lang.Integer[]>> getCurrentState()
Returns the current state of the sort, i.e a Map indexed by the axes and containing the sorted attribute of each SplitSort contained in sorters.

Returns:
A map containing the current state of the sort.