Search in sources :

Example 16 with NewDocumentType

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;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field) TemporaryStructuredDataType(com.yahoo.document.TemporaryStructuredDataType) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType) StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) StructuredDataType(com.yahoo.document.StructuredDataType) TemporaryStructuredDataType(com.yahoo.document.TemporaryStructuredDataType) DataType(com.yahoo.document.DataType) StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) MapDataType(com.yahoo.document.MapDataType) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) MapDataType(com.yahoo.document.MapDataType)

Example 17 with NewDocumentType

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());
    }
}
Also used : StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) VespaDocumentType(com.yahoo.documentmodel.VespaDocumentType) MapDataType(com.yahoo.document.MapDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)

Example 18 with NewDocumentType

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);
    }
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) LinkedList(java.util.LinkedList)

Example 19 with NewDocumentType

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);
}
Also used : DocumentDatabaseChangeValidator(com.yahoo.vespa.model.application.validation.change.search.DocumentDatabaseChangeValidator) NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 20 with NewDocumentType

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);
}
Also used : NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Aggregations

NewDocumentType (com.yahoo.documentmodel.NewDocumentType)23 Test (org.junit.Test)7 StructDataType (com.yahoo.document.StructDataType)4 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)4 ReferenceDataType (com.yahoo.document.ReferenceDataType)3 AnnotationType (com.yahoo.document.annotation.AnnotationType)3 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)3 MockRoot (com.yahoo.config.model.test.MockRoot)2 CollectionDataType (com.yahoo.document.CollectionDataType)2 DocumentType (com.yahoo.document.DocumentType)2 Field (com.yahoo.document.Field)2 MapDataType (com.yahoo.document.MapDataType)2 VespaDocumentType (com.yahoo.documentmodel.VespaDocumentType)2 TemporaryAnnotationReferenceDataType (com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)2 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)2 HashSet (java.util.HashSet)2 DeployState (com.yahoo.config.model.deploy.DeployState)1 com.yahoo.document (com.yahoo.document)1 DataType (com.yahoo.document.DataType)1 StructuredDataType (com.yahoo.document.StructuredDataType)1