use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class PredicateProcessor method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
if (field.getDataType() == DataType.PREDICATE) {
if (validate && field.doesIndexing()) {
fail(search, field, "Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded.");
}
if (field.doesAttributing()) {
Attribute attribute = field.getAttributes().get(field.getName());
for (Index index : field.getIndices().values()) {
BooleanIndexDefinition booleanDefinition = index.getBooleanIndexDefiniton();
if (validate && (booleanDefinition == null || !booleanDefinition.hasArity())) {
fail(search, field, "Missing arity value in predicate field.");
}
if (validate && (booleanDefinition.getArity() < 2)) {
fail(search, field, "Invalid arity value in predicate field, must be greater than 1.");
}
double threshold = booleanDefinition.getDensePostingListThreshold();
if (validate && (threshold <= 0 || threshold > 1)) {
fail(search, field, "Invalid dense-posting-list-threshold value in predicate field. " + "Value must be in range (0..1].");
}
attribute.setArity(booleanDefinition.getArity());
attribute.setLowerBound(booleanDefinition.getLowerBound());
attribute.setUpperBound(booleanDefinition.getUpperBound());
attribute.setDensePostingListThreshold(threshold);
addPredicateOptimizationIlScript(field, booleanDefinition);
}
DocumentSummary summary = search.getSummary("attributeprefetch");
if (summary != null) {
summary.remove(attribute.getName());
}
for (SummaryField summaryField : search.getSummaryFields(field).values()) {
summaryField.setTransform(SummaryTransform.NONE);
}
}
} else if (validate && field.getDataType().getPrimitiveType() == DataType.PREDICATE) {
fail(search, field, "Collections of predicates are not allowed.");
} else if (validate && field.getDataType() == DataType.RAW && field.doesIndexing()) {
fail(search, field, "Indexing of RAW fields is not supported.");
} else if (validate) {
// if field is not a predicate, disallow predicate-related index parameters
for (Index index : field.getIndices().values()) {
if (index.getBooleanIndexDefiniton() != null) {
BooleanIndexDefinition def = index.getBooleanIndexDefiniton();
if (def.hasArity()) {
fail(search, field, "Arity parameter is used only for predicate type fields.");
} else if (def.hasLowerBound() || def.hasUpperBound()) {
fail(search, field, "Parameters lower-bound and upper-bound are used only for predicate type fields.");
} else if (def.hasDensePostingListThreshold()) {
fail(search, field, "Parameter dense-posting-list-threshold is used only for predicate type fields.");
}
}
}
}
}
}
use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class ImplicitSummaries method process.
@Override
public void process(boolean validate) {
DocumentSummary defaultSummary = search.getSummary("default");
if (defaultSummary == null) {
defaultSummary = new DocumentSummary("default");
search.addSummary(defaultSummary);
}
for (SDField field : search.allConcreteFields()) {
collectSummaries(field, search, validate);
}
for (DocumentSummary documentSummary : search.getSummaries().values()) {
documentSummary.purgeImplicits();
}
}
use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class ImplicitSummaries method addPrefetchAttribute.
private void addPrefetchAttribute(Attribute attribute, SDField field, Search search) {
if (attribute.getPrefetchValue() == null) {
// Prefetch by default - unless any summary makes this dynamic
// Check if there is an implicit dynamic definition
SummaryField fieldSummaryField = field.getSummaryField(attribute.getName());
if (fieldSummaryField != null && fieldSummaryField.getTransform().isDynamic())
return;
// Check if an explicit class makes it dynamic (first is enough, as all must be the same, checked later)
SummaryField explicitSummaryField = search.getExplicitSummaryField(attribute.getName());
if (explicitSummaryField != null && explicitSummaryField.getTransform().isDynamic())
return;
}
DocumentSummary summary = getOrCreateAttributePrefetchSummary(search);
SummaryField attributeSummaryField = new SummaryField(attribute.getName(), attribute.getDataType());
attributeSummaryField.addSource(attribute.getName());
attributeSummaryField.addDestination("attributeprefetch");
attributeSummaryField.setTransform(SummaryTransform.ATTRIBUTE);
summary.add(attributeSummaryField);
}
use of com.yahoo.vespa.documentmodel.DocumentSummary 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()));
}
}
}
}
}
use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class ImplicitSummaryFields method process.
@Override
public void process(boolean validate) {
for (DocumentSummary docsum : search.getSummaries().values()) {
addField(docsum, new SummaryField("rankfeatures", DataType.STRING, SummaryTransform.RANKFEATURES), validate);
addField(docsum, new SummaryField("summaryfeatures", DataType.STRING, SummaryTransform.SUMMARYFEATURES), validate);
}
}
Aggregations