use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class ImplicitSummaries method addToDestination.
private void addToDestination(String destinationName, SummaryField summaryField, Search search) {
DocumentSummary destination = search.getSummary(destinationName);
if (destination == null) {
destination = new DocumentSummary(destinationName);
search.addSummary(destination);
destination.add(summaryField);
} else {
SummaryField existingField = destination.getSummaryField(summaryField.getName());
SummaryField merged = summaryField.mergeWith(existingField);
destination.add(merged);
}
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class ImplicitSummaries method collectSummaries.
private void collectSummaries(SDField field, Search search, boolean validate) {
SummaryField addedSummaryField = null;
// Implicit
String fieldName = field.getName();
SummaryField fieldSummaryField = field.getSummaryField(fieldName);
if (fieldSummaryField == null && field.doesSummarying()) {
fieldSummaryField = new SummaryField(fieldName, field.getDataType());
fieldSummaryField.setImplicit(true);
addSummaryFieldSources(fieldSummaryField, field);
fieldSummaryField.addDestination("default");
field.addSummaryField(fieldSummaryField);
addedSummaryField = fieldSummaryField;
}
if (fieldSummaryField != null) {
for (String dest : fieldSummaryField.getDestinations()) {
DocumentSummary summary = search.getSummary(dest);
if (summary != null) {
summary.add(fieldSummaryField);
}
}
}
// Attribute prefetch
for (Attribute attribute : field.getAttributes().values()) {
if (attribute.getName().equals(fieldName)) {
if (addedSummaryField != null) {
addedSummaryField.setTransform(SummaryTransform.ATTRIBUTE);
}
if (attribute.isPrefetch()) {
addPrefetchAttribute(attribute, field, search);
}
}
}
// Position attributes
if (field.doesSummarying()) {
for (Attribute attribute : field.getAttributes().values()) {
if (!attribute.isPosition())
continue;
DocumentSummary attributePrefetchSummary = getOrCreateAttributePrefetchSummary(search);
attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getDistanceSummaryFieldName(fieldName)));
attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getPositionSummaryFieldName(fieldName)));
}
}
// Explicits
for (SummaryField summaryField : field.getSummaryFields()) {
// Make sure we fetch from attribute here too
Attribute attribute = field.getAttributes().get(fieldName);
if (attribute != null && summaryField.getTransform() == SummaryTransform.NONE) {
summaryField.setTransform(SummaryTransform.ATTRIBUTE);
}
if (isValid(summaryField, search, validate)) {
addToDestinations(summaryField, search);
}
}
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class SummaryInFieldShortOperation method apply.
public void apply(SDField field) {
SummaryField ret = field.getSummaryField(name);
if (ret == null) {
ret = new SummaryField(name, field.getDataType());
ret.addSource(field.getName());
ret.addDestination("default");
}
ret.setImplicit(false);
ret.setTransform(transform);
for (SummaryField.Source source : sources) {
ret.addSource(source);
}
field.addSummaryField(ret);
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class CreatePositionZCurve method ensureCompatibleSummary.
private void ensureCompatibleSummary(SDField field, String sourceName, String summaryName, DataType summaryType, SummaryTransform summaryTransform, Collection<String> summaryTo, boolean validate) {
SummaryField summary = search.getSummaryField(summaryName);
if (summary == null) {
summary = new SummaryField(summaryName, summaryType, summaryTransform);
summary.addDestination("default");
summary.addDestinations(summaryTo);
field.addSummaryField(summary);
} else if (!summary.getDataType().equals(summaryType)) {
if (validate)
fail(search, field, "Incompatible summary field '" + summaryName + "' type " + summary.getDataType() + " already created.");
} else if (summary.getTransform() == SummaryTransform.NONE) {
summary.setTransform(summaryTransform);
summary.addDestination("default");
summary.addDestinations(summaryTo);
} else if (summary.getTransform() != summaryTransform) {
deployLogger.log(Level.WARNING, "Summary field " + summaryName + " has wrong transform: " + summary.getTransform());
return;
}
SummaryField.Source source = new SummaryField.Source(sourceName);
summary.getSources().clear();
summary.addSource(source);
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class SummaryConsistency method process.
@Override
public void process(boolean validate) {
for (DocumentSummary summary : search.getSummaries().values()) {
if (summary.getName().equals("default"))
continue;
for (SummaryField summaryField : summary.getSummaryFields()) {
assertConsistency(summaryField, search, validate);
makeAttributeTransformIfAppropriate(summaryField, search);
}
}
}
Aggregations