Search in sources :

Example 1 with Source

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()));
                }
            }
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) HashMap(java.util.HashMap) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) Source(com.yahoo.vespa.documentmodel.SummaryField.Source) Pair(com.yahoo.collections.Pair)

Aggregations

Pair (com.yahoo.collections.Pair)1 DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)1 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)1 Source (com.yahoo.vespa.documentmodel.SummaryField.Source)1 HashMap (java.util.HashMap)1