use of com.google.refine.browsing.util.ExpressionBasedRowEvaluable in project OpenRefine by OpenRefine.
the class GetColumnsInfoCommand method getBinIndex.
private NumericBinIndex getBinIndex(Project project, Column column) {
String expression = "value";
String key = "numeric-bin:" + expression;
Evaluable eval = null;
try {
eval = MetaParser.parse(expression);
} catch (ParsingException e) {
// this should never happen
}
NumericBinIndex index = (NumericBinIndex) column.getPrecompute(key);
if (index == null) {
index = new NumericBinRowIndex(project, new ExpressionBasedRowEvaluable(column.getName(), column.getCellIndex(), eval));
column.setPrecompute(key, index);
}
return index;
}
use of com.google.refine.browsing.util.ExpressionBasedRowEvaluable in project OpenRefine by OpenRefine.
the class ScatterplotFacet method getBinIndex.
public static NumericBinIndex getBinIndex(Project project, Column column, Evaluable eval, String expression, String mode) {
String key = "numeric-bin:" + mode + ":" + expression;
if (eval == null) {
try {
eval = MetaParser.parse(expression);
} catch (ParsingException e) {
logger.warn("Error parsing expression", e);
}
}
NumericBinIndex index = (NumericBinIndex) column.getPrecompute(key);
if (index == null) {
index = "row-based".equals(mode) ? new NumericBinRowIndex(project, new ExpressionBasedRowEvaluable(column.getName(), column.getCellIndex(), eval)) : new NumericBinRecordIndex(project, new ExpressionBasedRowEvaluable(column.getName(), column.getCellIndex(), eval));
column.setPrecompute(key, index);
}
return index;
}
Aggregations