net.sf.farrago.catalog
Class FarragoColumnHistogram.HistogramRange

java.lang.Object
  extended by net.sf.farrago.catalog.FarragoColumnHistogram.HistogramRange
Enclosing class:
FarragoColumnHistogram

private class FarragoColumnHistogram.HistogramRange
extends Object

Histogram range represents a set of bars in a histogram


Field Summary
private  List<FemColumnHistogramBar> bars
           
private  boolean empty
           
private  int firstBar
           
private  SargInterval interval
           
private  int lastBar
           
private  int minBar
           
 
Constructor Summary
protected FarragoColumnHistogram.HistogramRange(List<FemColumnHistogramBar> bars, SargInterval interval, int minBar)
          Initializes a range of histogram bars spanning a search interval
 
Method Summary
protected  void evaluate()
          Searches through the histogram to find the first and last bars the interval may cover in the histogram.
private  int findEndBar(int min, SargEndpoint point)
          Finds the first histogram bar which does not contain the specified point.
private  int findStartBar(int min, SargEndpoint point)
          Finds the first histogram bar which may contain the specified starting search point, or points greater than the search point.
protected  int getFirstBar()
          Returns the zero based index of the first bar in the range, or -1 if the range is empty.
protected  int getLastBar()
          Returns the zero based index of the last bar in the range, or -1 if the range is empty.
protected  boolean isEmpty()
          Returns whether the range is empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bars

private List<FemColumnHistogramBar> bars

interval

private SargInterval interval

minBar

private int minBar

empty

private boolean empty

firstBar

private int firstBar

lastBar

private int lastBar
Constructor Detail

FarragoColumnHistogram.HistogramRange

protected FarragoColumnHistogram.HistogramRange(List<FemColumnHistogramBar> bars,
                                                SargInterval interval,
                                                int minBar)
Initializes a range of histogram bars spanning a search interval

Parameters:
bars - histogram bars to search
interval - the search interval
minBar - the first bar to search
Method Detail

evaluate

protected void evaluate()
Searches through the histogram to find the first and last bars the interval may cover in the histogram. This range may be empty.


isEmpty

protected boolean isEmpty()
Returns whether the range is empty


getFirstBar

protected int getFirstBar()
Returns the zero based index of the first bar in the range, or -1 if the range is empty.


getLastBar

protected int getLastBar()
Returns the zero based index of the last bar in the range, or -1 if the range is empty.


findStartBar

private int findStartBar(int min,
                         SargEndpoint point)
Finds the first histogram bar which may contain the specified starting search point, or points greater than the search point. We can rule out histogram bars which end before the search point. However, we can never rule out the last histogram bar, because it has no definite end.

Parameters:
min - index of first histogram bar to search
point - start point to search for
Returns:
index of first bar not containing point

findEndBar

private int findEndBar(int min,
                       SargEndpoint point)
Finds the first histogram bar which does not contain the specified point. A bar which does not contain the end point will have a starting value greater than the point.

If all bars may contain the search point, returns the index of the last bar + 1.

Parameters:
min - index of first histogram bar to search
point - point to search for
Returns:
index of first bar not containing point