use of com.yahoo.searchlib.rankingexpression.rule.ReferenceNode in project vespa by vespa-engine.
the class AbstractArrayContext method extractVariables.
private void extractVariables(ExpressionNode node, Set<String> variables) {
if (node instanceof ReferenceNode) {
ReferenceNode fNode = (ReferenceNode) node;
if (fNode.getArguments().expressions().size() > 0)
throw new UnsupportedOperationException("Array lookup is not supported with features having arguments)");
variables.add(fNode.toString());
} else if (node instanceof CompositeNode) {
CompositeNode cNode = (CompositeNode) node;
for (ExpressionNode child : cNode.children()) extractVariables(child, variables);
}
}
use of com.yahoo.searchlib.rankingexpression.rule.ReferenceNode in project vespa by vespa-engine.
the class FeatureList method parse.
/**
* Parses the content of a reader object as a list of feature nodes.
*
* @param reader A reader object that contains an feature list.
* @return A list of those features named in the string.
* @throws ParseException if the string could not be parsed.
*/
private static List<ReferenceNode> parse(Reader reader) throws ParseException {
List<ReferenceNode> lst;
try {
lst = new RankingExpressionParser(reader).featureList();
} catch (TokenMgrError e) {
ParseException t = new ParseException();
throw (ParseException) t.initCause(e);
}
List<ReferenceNode> ret = new ArrayList<ReferenceNode>(lst.size());
for (Object obj : lst) {
if (!(obj instanceof ReferenceNode)) {
throw new IllegalStateException("Feature list contains a " + obj.getClass().getName() + ".");
}
ret.add((ReferenceNode) obj);
}
return ret;
}
Aggregations