use of com.yahoo.vespa.documentmodel.SummaryField.Source in project vespa by vespa-engine.
the class SummaryNamesFieldCollisions method process.
@Override
public void process(boolean validate) {
if (!validate)
return;
Map<String, Pair<String, String>> fieldToClassAndSource = new HashMap<>();
for (DocumentSummary summary : search.getSummaries().values()) {
if ("default".equals(summary.getName()))
continue;
for (SummaryField summaryField : summary.getSummaryFields()) {
if (summaryField.isImplicit())
continue;
Pair<String, String> prevClassAndSource = fieldToClassAndSource.get(summaryField.getName());
for (Source source : summaryField.getSources()) {
if (prevClassAndSource != null) {
String prevClass = prevClassAndSource.getFirst();
String prevSource = prevClassAndSource.getSecond();
if (!prevClass.equals(summary.getName())) {
if (!prevSource.equals(source.getName())) {
throw new IllegalArgumentException("For search '" + search.getName() + "', summary class '" + summary.getName() + "'," + " summary field '" + summaryField.getName() + "':" + " Can not use source '" + source.getName() + "' for this summary field, an equally named field in summary class '" + prevClass + "' uses a different source: '" + prevSource + "'.");
}
}
} else {
fieldToClassAndSource.put(summaryField.getName(), new Pair<>(summary.getName(), source.getName()));
}
}
}
}
}
Aggregations