-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
when use scripted_metric i always get null_pointer_exception, because MethodField class contain the function getParamsAsMap , return a HashMap which store the key and value, but in the AggMaker class when use scriptedMetric to analyze the scripted_metirc, the code iterate the scriptedMetricParams, but i see the params in the map.entrySet() is:
combine_script=, reduce_script=, init_script=, @reduce_a=, alias=, map_script=
and the code segment :
if(param.getKey().startsWith("@")){
if(param.getKey().startsWith("@reduce_")){
reduceScriptAdditionalParams.put(param.getKey().replace("@reduce_",""),param.getValue());
}
else{
scriptAdditionalParams.put(param.getKey().replace("@",""),param.getValue());
}
continue;
}
if(reduceScriptAdditionalParams.size() == 0) reduceScriptAdditionalParams = null;
has an error, if the first key is not start with @ then the reduceScriptAdditionalParams.size() is zero and we set the reduceScriptAdditionalParams to be null, when the second key is coming, the size function will throw null pointer exception.
i think the code segment :
if(reduceScriptAdditionalParams.size() == 0) reduceScriptAdditionalParams = null;
need be out of the scriptedMetricParams loop, this change will not impact the script param of null