use of com.yahoo.documentmodel.NewDocumentType 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.documentmodel.NewDocumentType 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.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class DocumentModelBuilder method addDocumentTypes.
private void addDocumentTypes(List<SDDocumentType> docList) {
LinkedList<NewDocumentType> lst = new LinkedList<>();
for (SDDocumentType doc : docList) {
lst.add(convert(doc));
model.getDocumentManager().add(lst.getLast());
}
for (NewDocumentType doc : lst) {
resolveTemporaries(doc.getAllTypes(), lst);
}
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class IndexedSearchClusterChangeValidator method validateDocumentDatabase.
private static List<ConfigChangeAction> validateDocumentDatabase(ContentCluster currentCluster, ContentCluster nextCluster, String docTypeName, DocumentDatabase currentDb, DocumentDatabase nextDb, ValidationOverrides overrides, Instant now) {
NewDocumentType currentDocType = currentCluster.getDocumentDefinitions().get(docTypeName);
NewDocumentType nextDocType = nextCluster.getDocumentDefinitions().get(docTypeName);
List<VespaConfigChangeAction> result = new DocumentDatabaseChangeValidator(currentDb, currentDocType, nextDb, nextDocType).validate(overrides, now);
return modifyActions(result, getSearchNodeServices(nextCluster.getSearch().getIndexed()), docTypeName);
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class TopologicalDocumentTypeSorter method depthFirstTraverse.
private void depthFirstTraverse(NewDocumentType docType) {
// Note that cycles are not allowed and detected earlier in DocumentGraphValidator.
if (sortedTypes.containsKey(docType.getName())) {
return;
}
for (NewDocumentType.Name referenceDocTypeName : docType.getDocumentReferences()) {
NewDocumentType referenceDocType = unsortedTypes.get(referenceDocTypeName.getName());
depthFirstTraverse(referenceDocType);
}
sortedTypes.put(docType.getName(), docType);
}
Aggregations