use of com.yahoo.document.CollectionDataType in project vespa by vespa-engine.
the class TextMatch method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
if (field.getMatching().getType() != Matching.Type.TEXT)
continue;
ScriptExpression script = field.getIndexingScript();
if (script == null)
continue;
DataType fieldType = field.getDataType();
if (fieldType instanceof CollectionDataType) {
fieldType = ((CollectionDataType) fieldType).getNestedType();
}
if (fieldType != DataType.STRING)
continue;
Set<String> dynamicSummary = new TreeSet<>();
Set<String> staticSummary = new TreeSet<>();
new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, field, dynamicSummary, staticSummary);
MyVisitor visitor = new MyVisitor(dynamicSummary);
visitor.visit(script);
if (!visitor.requiresTokenize)
continue;
ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field));
field.setIndexingScript((ScriptExpression) converter.convert(script));
}
}
use of com.yahoo.document.CollectionDataType in project vespa by vespa-engine.
the class TensorFieldProcessor method process.
@Override
public void process(boolean validate) {
if (!validate)
return;
for (SDField field : search.allConcreteFields()) {
if (field.getDataType() instanceof TensorDataType) {
validateIndexingScripsForTensorField(field);
validateAttributeSettingForTensorField(field);
} else if (field.getDataType() instanceof CollectionDataType) {
validateDataTypeForCollectionField(field);
}
}
}
use of com.yahoo.document.CollectionDataType in project vespa by vespa-engine.
the class DocumentModelBuilder method resolveTemporariesRecurse.
@SuppressWarnings("deprecation")
private static DataType resolveTemporariesRecurse(DataType type, DataTypeCollection repo, Collection<NewDocumentType> docs) {
if (type instanceof TemporaryStructuredDataType) {
NewDocumentType docType = getDocumentType(docs, type.getId());
if (docType != null) {
type = docType;
return type;
}
DataType real = repo.getDataType(type.getId());
if (real == null) {
throw new NullPointerException("Can not find type '" + type.toString() + "', impossible.");
}
type = real;
} else if (type instanceof StructDataType) {
StructDataType dt = (StructDataType) type;
for (com.yahoo.document.Field field : dt.getFields()) {
if (field.getDataType() != type) {
// XXX deprecated:
field.setDataType(resolveTemporariesRecurse(field.getDataType(), repo, docs));
}
}
} else if (type instanceof MapDataType) {
MapDataType t = (MapDataType) type;
t.setKeyType(resolveTemporariesRecurse(t.getKeyType(), repo, docs));
t.setValueType(resolveTemporariesRecurse(t.getValueType(), repo, docs));
} else if (type instanceof CollectionDataType) {
CollectionDataType t = (CollectionDataType) type;
t.setNestedType(resolveTemporariesRecurse(t.getNestedType(), repo, docs));
} else if (type instanceof ReferenceDataType) {
ReferenceDataType t = (ReferenceDataType) type;
if (t.getTargetType() instanceof TemporaryStructuredDataType) {
DataType targetType = resolveTemporariesRecurse(t.getTargetType(), repo, docs);
t.setTargetType((StructuredDataType) targetType);
}
}
return type;
}
use of com.yahoo.document.CollectionDataType in project vespa by vespa-engine.
the class DocumentModelBuilder method extractNestedTypes.
private static void extractNestedTypes(NewDocumentType dt, DataType type) {
if (type instanceof StructDataType) {
StructDataType tmp = (StructDataType) type;
extractDataTypesFromFields(dt, tmp.getFieldsThisTypeOnly());
} else if (type instanceof DocumentType) {
throw new IllegalArgumentException("Can not handle nested document definitions. In document type '" + dt.getName().toString() + "', we can not define document type '" + type.toString());
} else if (type instanceof CollectionDataType) {
CollectionDataType tmp = (CollectionDataType) type;
extractNestedTypes(dt, tmp.getNestedType());
addType(dt, tmp.getNestedType());
} else if (type instanceof MapDataType) {
MapDataType tmp = (MapDataType) type;
extractNestedTypes(dt, tmp.getKeyType());
extractNestedTypes(dt, tmp.getValueType());
addType(dt, tmp.getKeyType());
addType(dt, tmp.getValueType());
} else if (type instanceof TemporaryAnnotationReferenceDataType) {
throw new IllegalArgumentException(type.toString());
}
}
use of com.yahoo.document.CollectionDataType in project vespa by vespa-engine.
the class DocumentModelBuilder method specialHandleAnnotationReferenceRecurse.
private static DataType specialHandleAnnotationReferenceRecurse(NewDocumentType docType, String fieldName, DataType dataType) {
if (dataType instanceof TemporaryAnnotationReferenceDataType) {
TemporaryAnnotationReferenceDataType refType = (TemporaryAnnotationReferenceDataType) dataType;
if (refType.getId() != 0) {
return null;
}
AnnotationType target = docType.getAnnotationType(refType.getTarget());
if (target == null) {
throw new RetryLaterException("Annotation '" + refType.getTarget() + "' in reference '" + fieldName + "' does not exist.");
}
dataType = new AnnotationReferenceDataType(target);
addType(docType, dataType);
return dataType;
} else if (dataType instanceof MapDataType) {
MapDataType mapType = (MapDataType) dataType;
DataType valueType = specialHandleAnnotationReferenceRecurse(docType, fieldName, mapType.getValueType());
if (valueType == null) {
return null;
}
mapType = mapType.clone();
mapType.setValueType(valueType);
addType(docType, mapType);
return mapType;
} else if (dataType instanceof CollectionDataType) {
CollectionDataType lstType = (CollectionDataType) dataType;
DataType nestedType = specialHandleAnnotationReferenceRecurse(docType, fieldName, lstType.getNestedType());
if (nestedType == null) {
return null;
}
lstType = lstType.clone();
lstType.setNestedType(nestedType);
addType(docType, lstType);
return lstType;
}
return null;
}
Aggregations