mirror of https://github.com/apache/lucene.git
SOLR-5488: Fix up test failures for analytics component. Some cleanups suggested by IntelliJ's analysis
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1545514 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ee21f3b465
commit
bc38be3e07
|
@ -160,21 +160,17 @@ public class ExpressionFactory {
|
|||
int start = 0;
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
char[] chars = expression.toCharArray();
|
||||
boolean escapedCharacter = false;
|
||||
for (int count = 0; count < expression.length(); count++) {
|
||||
char c = chars[count];
|
||||
if (c==',' && stack == 0 && !escapedCharacter) {
|
||||
if (c==',' && stack == 0) {
|
||||
arguments.add(expression.substring(start, count).replace("\\(","(").replace("\\)",")").replace("\\,",",").trim());
|
||||
start = count+1;
|
||||
} else if (c == '(' && !escapedCharacter) {
|
||||
} else if (c == '(') {
|
||||
stack ++;
|
||||
} else if (c == ')' && !escapedCharacter) {
|
||||
} else if (c == ')') {
|
||||
stack --;
|
||||
} else if (c == '\\') {
|
||||
escapedCharacter=true;
|
||||
}
|
||||
if (escapedCharacter) {
|
||||
escapedCharacter=false;
|
||||
; // Do nothing.
|
||||
}
|
||||
}
|
||||
if (stack==0) {
|
||||
|
|
|
@ -421,7 +421,7 @@ public class StatsCollectorSupplierFactory {
|
|||
return null;
|
||||
}
|
||||
Object defaultObject;
|
||||
Class<? extends ValueSource> type = delegateSource.getClass();
|
||||
|
||||
ValueSource src = delegateSource;
|
||||
if (delegateSource instanceof FilterFieldSource) {
|
||||
src = ((FilterFieldSource)delegateSource).getRootSource();
|
||||
|
@ -432,6 +432,12 @@ public class StatsCollectorSupplierFactory {
|
|||
} catch (NumberFormatException e) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,"The filter value "+arguments[1]+" cannot be converted into an integer.",e);
|
||||
}
|
||||
} else if ( src instanceof DateFieldSource || src instanceof MultiDateFunction) {
|
||||
try {
|
||||
defaultObject = TrieDateField.parseDate(arguments[1]);
|
||||
} catch (ParseException e) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,"The filter value "+arguments[1]+" cannot be converted into a date.",e);
|
||||
}
|
||||
} else if ( src instanceof LongFieldSource ) {
|
||||
try {
|
||||
defaultObject = new Long(arguments[1]);
|
||||
|
@ -451,12 +457,6 @@ public class StatsCollectorSupplierFactory {
|
|||
} catch (NumberFormatException e) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,"The filter value "+arguments[1]+" cannot be converted into a double.",e);
|
||||
}
|
||||
} else if ( src instanceof DateFieldSource || src instanceof MultiDateFunction) {
|
||||
try {
|
||||
defaultObject = TrieDateField.parseDate(arguments[1]);
|
||||
} catch (ParseException e) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,"The filter value "+arguments[1]+" cannot be converted into a date.",e);
|
||||
}
|
||||
} else {
|
||||
defaultObject = arguments[1];
|
||||
}
|
||||
|
|
|
@ -1186,11 +1186,12 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
|
||||
private boolean checkStddevs(ArrayList<Double> list1, ArrayList<Double> list2) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i<list1.size() && b; i++) {
|
||||
b = b && (Math.abs(list1.get(i)-list2.get(i))<.00000000001);
|
||||
for (int i = 0; i<list1.size(); i++) {
|
||||
if ((Math.abs(list1.get(i)-list2.get(i))<.00000000001) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue