Search in sources :

Example 1 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentModelBuilder method convert.

private NewDocumentType convert(SDDocumentType sdoc) {
    Map<AnnotationType, String> annotationInheritance = new HashMap<>();
    Map<StructDataType, String> structInheritance = new HashMap<>();
    NewDocumentType dt = new NewDocumentType(new NewDocumentType.Name(sdoc.getName()), sdoc.getDocumentType().getHeaderType(), sdoc.getDocumentType().getBodyType(), sdoc.getFieldSets(), convertDocumentReferencesToNames(sdoc.getDocumentReferences()));
    for (SDDocumentType n : sdoc.getInheritedTypes()) {
        NewDocumentType.Name name = new NewDocumentType.Name(n.getName());
        NewDocumentType inherited = model.getDocumentManager().getDocumentType(name);
        if (inherited != null) {
            dt.inherit(inherited);
        }
    }
    for (SDDocumentType type : sdoc.getTypes()) {
        if (type.isStruct()) {
            handleStruct(dt, type);
        } else {
            throw new IllegalArgumentException("Data type '" + sdoc.getName() + "' is not a struct => tostring='" + sdoc.toString() + "'.");
        }
    }
    for (AnnotationType annotation : sdoc.getAnnotations()) {
        dt.add(annotation);
    }
    for (AnnotationType annotation : sdoc.getAnnotations()) {
        SDAnnotationType sa = (SDAnnotationType) annotation;
        if (annotation.getInheritedTypes().isEmpty() && (sa.getInherits() != null)) {
            annotationInheritance.put(annotation, sa.getInherits());
        }
        if (annotation.getDataType() == null) {
            if (sa.getSdDocType() != null) {
                StructDataType s = handleStruct(dt, sa.getSdDocType());
                annotation.setDataType(s);
                if ((sa.getInherits() != null)) {
                    structInheritance.put(s, "annotation." + sa.getInherits());
                }
            } else if (sa.getInherits() != null) {
                StructDataType s = new StructDataType("annotation." + annotation.getName());
                if (anyParentsHavePayLoad(sa, sdoc)) {
                    annotation.setDataType(s);
                    addType(dt, s);
                }
                structInheritance.put(s, "annotation." + sa.getInherits());
            }
        }
    }
    for (Map.Entry<AnnotationType, String> e : annotationInheritance.entrySet()) {
        e.getKey().inherit(dt.getAnnotationType(e.getValue()));
    }
    for (Map.Entry<StructDataType, String> e : structInheritance.entrySet()) {
        StructDataType s = (StructDataType) dt.getDataType(e.getValue());
        if (s != null) {
            e.getKey().inherit(s);
        }
    }
    handleStruct(dt, sdoc.getDocumentType().getHeaderType());
    handleStruct(dt, sdoc.getDocumentType().getBodyType());
    extractDataTypesFromFields(dt, sdoc.fieldSet());
    return dt;
}
Also used : SDAnnotationType(com.yahoo.searchdefinition.document.annotation.SDAnnotationType) HashMap(java.util.HashMap) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) SDAnnotationType(com.yahoo.searchdefinition.document.annotation.SDAnnotationType) AnnotationType(com.yahoo.document.annotation.AnnotationType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) StructDataType(com.yahoo.document.StructDataType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentManager method produce.

public DocumentmanagerConfig.Builder produce(DocumentModel model, DocumentmanagerConfig.Builder documentConfigBuilder) {
    documentConfigBuilder.enablecompression(false);
    Set<DataType> handled = new HashSet<>();
    for (NewDocumentType documentType : model.getDocumentManager().getTypes()) {
        buildConfig(documentType, documentConfigBuilder, handled);
        buildConfig(documentType.getAnnotations(), documentConfigBuilder);
        if (documentType != VespaDocumentType.INSTANCE) {
            DocumentmanagerConfig.Datatype.Builder dataTypeBuilder = new DocumentmanagerConfig.Datatype.Builder();
            documentConfigBuilder.datatype(dataTypeBuilder);
            buildConfig(documentType, dataTypeBuilder);
        }
    }
    return documentConfigBuilder;
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) HashSet(java.util.HashSet)

Example 3 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentTypes method produceInheritOrder.

private void produceInheritOrder(NewDocumentType documentType, DocumenttypesConfig.Builder builder, Map<NewDocumentType.Name, NewDocumentType> produced) {
    if (!produced.containsKey(documentType.getFullName())) {
        for (NewDocumentType inherited : documentType.getInherited()) {
            produceInheritOrder(inherited, builder, produced);
        }
        buildConfig(documentType, builder);
        produced.put(documentType.getFullName(), documentType);
    }
}
Also used : NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 4 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentTypes method buildConfig.

private void buildConfig(NewDocumentType documentType, DocumenttypesConfig.Builder builder) {
    if (documentType == VespaDocumentType.INSTANCE) {
        return;
    }
    DocumenttypesConfig.Documenttype.Builder db = new DocumenttypesConfig.Documenttype.Builder();
    db.id(documentType.getId()).name(documentType.getName()).headerstruct(documentType.getHeader().getId()).bodystruct(documentType.getBody().getId());
    Set<Integer> built = new HashSet<>();
    for (NewDocumentType inherited : documentType.getInherited()) {
        db.inherits(new DocumenttypesConfig.Documenttype.Inherits.Builder().id(inherited.getId()));
        markAsBuilt(built, inherited.getAllTypes());
    }
    for (DataType dt : documentType.getTypes()) {
        buildConfig(dt, db, built);
    }
    for (AnnotationType annotation : documentType.getAnnotations()) {
        DocumenttypesConfig.Documenttype.Annotationtype.Builder atb = new DocumenttypesConfig.Documenttype.Annotationtype.Builder();
        db.annotationtype(atb);
        buildConfig(annotation, atb);
    }
    buildConfig(documentType.getFieldSets(), db);
    builder.documenttype(db);
}
Also used : AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Example 5 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class ContentSearchCluster method getConfig.

@Override
public void getConfig(ProtonConfig.Builder builder) {
    double visibilityDelay = hasIndexedCluster() ? getIndexed().getVisibilityDelay() : 0.0;
    for (NewDocumentType type : TopologicalDocumentTypeSorter.sort(documentDefinitions.values())) {
        ProtonConfig.Documentdb.Builder ddbB = new ProtonConfig.Documentdb.Builder();
        String docTypeName = type.getFullName().getName();
        boolean globalDocType = isGloballyDistributed(type);
        ddbB.inputdoctypename(docTypeName).configid(getConfigId()).visibilitydelay(visibilityDelay).global(globalDocType);
        Optional<StreamingSearchCluster> ssc = findStreamingCluster(docTypeName);
        if (ssc.isPresent()) {
            ddbB.inputdoctypename(type.getFullName().getName()).configid(ssc.get().getDocumentDBConfigId());
        } else if (hasIndexedCluster()) {
            getIndexed().fillDocumentDBConfig(type.getFullName().getName(), ddbB);
        }
        if (globalDocType) {
            ddbB.visibilitydelay(0.0);
        }
        builder.documentdb(ddbB);
    }
    int numDocumentDbs = builder.documentdb.size();
    builder.initialize(new ProtonConfig.Initialize.Builder().threads(numDocumentDbs + 1));
    if (resourceLimits.isPresent()) {
        resourceLimits.get().getConfig(builder);
    }
    if (tuning != null) {
        tuning.getConfig(builder);
    }
    if (redundancy != null) {
        redundancy.getConfig(builder);
    }
}
Also used : ProtonConfig(com.yahoo.vespa.config.search.core.ProtonConfig) UserConfigBuilder(com.yahoo.vespa.model.builder.UserConfigBuilder) DomResourceLimitsBuilder(com.yahoo.vespa.model.content.cluster.DomResourceLimitsBuilder) VespaDomBuilder(com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder) DomSearchTuningBuilder(com.yahoo.vespa.model.builder.xml.dom.DomSearchTuningBuilder) 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