SOLR-680 -- StatsComponent -- removing broken median calculation

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@727782 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2008-12-18 18:14:03 +00:00
parent 328cacec62
commit d52572f548
5 changed files with 2 additions and 50 deletions

View File

@ -24,5 +24,4 @@ public interface StatsParams {
public static final String STATS = "stats"; public static final String STATS = "stats";
public static final String STATS_FIELD = STATS + ".field"; public static final String STATS_FIELD = STATS + ".field";
public static final String STATS_FACET = STATS + ".facet"; public static final String STATS_FACET = STATS + ".facet";
public static final String STATS_TWOPASS = STATS + ".twopass";
} }

View File

@ -181,7 +181,6 @@ class StatsValues {
double sumOfSquares; double sumOfSquares;
long count; long count;
long missing; long missing;
Double median = null;
// facetField facetValue // facetField facetValue
Map<String, Map<String,StatsValues>> facets; Map<String, Map<String,StatsValues>> facets;
@ -251,7 +250,6 @@ class StatsValues {
max = Double.MIN_VALUE; max = Double.MIN_VALUE;
sum = count = missing = 0; sum = count = missing = 0;
sumOfSquares = 0; sumOfSquares = 0;
median = null;
facets = null; facets = null;
} }
@ -264,9 +262,6 @@ class StatsValues {
res.add("missing", missing); res.add("missing", missing);
res.add("sumOfSquares", sumOfSquares ); res.add("sumOfSquares", sumOfSquares );
res.add("mean", getAverage()); res.add("mean", getAverage());
if( median != null ) {
res.add( "median", median );
}
res.add( "stddev", getStandardDeviation() ); res.add( "stddev", getStandardDeviation() );
// add the facet stats // add the facet stats
@ -435,34 +430,6 @@ class SimpleStats {
} }
} }
// Find things that require a 2nd pass
if( params.getFieldBool(fieldName, StatsParams.STATS_TWOPASS, false) ) {
if( allstats.count > 1 ) { // must be 2 or more...
iter = docs.iterator();
boolean isEven = ( allstats.count % 2) == 0;
int medianIndex = (int) Math.ceil( allstats.count/2.0 );
for ( i=0; iter.hasNext(); ) {
String raw = all.getTermText(iter.nextDoc());
if( raw != null ) {
if( ++i == medianIndex ) {
double val0 = Double.parseDouble( all.ft.indexedToReadable(raw) );
if( isEven ) {
do {
raw = all.getTermText(iter.nextDoc());
} while( raw == null );
double val1 = Double.parseDouble( all.ft.indexedToReadable(raw) );
allstats.median = (val0+val1)/2.0;
}
else {
allstats.median = val0;
}
break;
}
}
}
} // get median
}
if( finfo.length > 0 ) { if( finfo.length > 0 ) {
allstats.facets = new HashMap<String, Map<String,StatsValues>>(); allstats.facets = new HashMap<String, Map<String,StatsValues>>();
for( FieldFacetStats f : finfo ) { for( FieldFacetStats f : finfo ) {

View File

@ -352,11 +352,10 @@ public class SolrQuery extends ModifiableSolrParams
this.set( StatsParams.STATS, v ); this.set( StatsParams.STATS, v );
} }
public void setGetFieldStatistics( String field, boolean twopass ) public void setGetFieldStatistics( String field )
{ {
this.set( StatsParams.STATS, true ); this.set( StatsParams.STATS, true );
this.add( StatsParams.STATS_FIELD, field ); this.add( StatsParams.STATS_FIELD, field );
this.set( "f."+field+"."+StatsParams.STATS_TWOPASS, twopass+"" );
} }
public void addStatsFieldFacets( String field, String ... facets ) public void addStatsFieldFacets( String field, String ... facets )

View File

@ -41,7 +41,6 @@ public class FieldStatsInfo implements Serializable {
Double mean = null; Double mean = null;
Double sumOfSquares = null; Double sumOfSquares = null;
Double stddev = null; Double stddev = null;
Double median = null;
Map<String,List<FieldStatsInfo>> facets; Map<String,List<FieldStatsInfo>> facets;
@ -74,9 +73,6 @@ public class FieldStatsInfo implements Serializable {
else if( "stddev".equals( entry.getKey() ) ) { else if( "stddev".equals( entry.getKey() ) ) {
stddev = (Double)entry.getValue(); stddev = (Double)entry.getValue();
} }
else if( "median".equals( entry.getKey() ) ) {
median = (Double)entry.getValue();
}
else if( "facets".equals( entry.getKey() ) ) { else if( "facets".equals( entry.getKey() ) ) {
NamedList<Object> fields = (NamedList<Object>)entry.getValue(); NamedList<Object> fields = (NamedList<Object>)entry.getValue();
facets = new HashMap<String, List<FieldStatsInfo>>(); facets = new HashMap<String, List<FieldStatsInfo>>();
@ -119,9 +115,6 @@ public class FieldStatsInfo implements Serializable {
if( mean != null ) { if( mean != null ) {
sb.append( " mean:").append( mean ); sb.append( " mean:").append( mean );
} }
if( median != null ) {
sb.append( " median:").append(median);
}
if( stddev != null ) { if( stddev != null ) {
sb.append( " stddev:").append(stddev); sb.append( " stddev:").append(stddev);
} }
@ -161,10 +154,6 @@ public class FieldStatsInfo implements Serializable {
return stddev; return stddev;
} }
public Double getMedian() {
return median;
}
public Map<String, List<FieldStatsInfo>> getFacets() { public Map<String, List<FieldStatsInfo>> getFacets() {
return facets; return facets;
} }

View File

@ -343,7 +343,7 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
SolrQuery query = new SolrQuery( "*:*" ); SolrQuery query = new SolrQuery( "*:*" );
query.setRows( 0 ); query.setRows( 0 );
query.setGetFieldStatistics( "popularity", true ); query.setGetFieldStatistics( "popularity" );
QueryResponse rsp = server.query( query ); QueryResponse rsp = server.query( query );
FieldStatsInfo stats = rsp.getFieldStatsInfo().get( "popularity" ); FieldStatsInfo stats = rsp.getFieldStatsInfo().get( "popularity" );
@ -353,7 +353,6 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
assertEquals( 94.0, stats.getMax() ); assertEquals( 94.0, stats.getMax() );
assertEquals( new Long(nums.length), stats.getCount() ); assertEquals( new Long(nums.length), stats.getCount() );
assertEquals( new Long(0), stats.getMissing() ); assertEquals( new Long(0), stats.getMissing() );
assertEquals( (nums[4]+nums[5])/2.0, stats.getMedian() );
assertEquals( "26.4", stats.getStddev().toString().substring(0,4) ); assertEquals( "26.4", stats.getStddev().toString().substring(0,4) );
// now lets try again with a new set... (odd median) // now lets try again with a new set... (odd median)
@ -380,7 +379,6 @@ abstract public class SolrExampleTests extends SolrExampleTestBase
assertEquals( 20.0, stats.getMax() ); assertEquals( 20.0, stats.getMax() );
assertEquals( new Long(nums.length), stats.getCount() ); assertEquals( new Long(nums.length), stats.getCount() );
assertEquals( new Long(0), stats.getMissing() ); assertEquals( new Long(0), stats.getMissing() );
assertEquals( 10.0, stats.getMedian() );
// Now try again with faceting // Now try again with faceting
//--------------------------------- //---------------------------------