Search in sources :

Example 26 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class ImplicitStructTypesTestCase method testRequireThatImplicitStructsAreCreated.

@Test
public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertStruct(docType, PositionDataType.INSTANCE);
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 27 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType 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 28 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class DocumentModelBuilder method sortDocumentTypes.

private List<SDDocumentType> sortDocumentTypes(List<SDDocumentType> docList) {
    Set<String> doneNames = new HashSet<>();
    doneNames.add(SDDocumentType.VESPA_DOCUMENT.getName());
    List<SDDocumentType> doneList = new LinkedList<>();
    List<SDDocumentType> prevList = null;
    List<SDDocumentType> nextList = docList;
    while (prevList == null || nextList.size() < prevList.size()) {
        prevList = nextList;
        nextList = new LinkedList<>();
        for (SDDocumentType doc : prevList) {
            boolean isDone = true;
            for (SDDocumentType inherited : doc.getInheritedTypes()) {
                if (!doneNames.contains(inherited.getName())) {
                    isDone = false;
                    break;
                }
            }
            if (isDone) {
                doneNames.add(doc.getName());
                doneList.add(doc);
            } else {
                nextList.add(doc);
            }
        }
    }
    if (!nextList.isEmpty()) {
        throw new IllegalArgumentException("Could not resolve inheritance of document types " + toString(prevList) + ".");
    }
    return doneList;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 29 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SDDocumentTypeOrderer method process.

private void process(SDDocumentType type) {
    List<DataTypeName> toReplace = new ArrayList<>();
    for (SDDocumentType sdoc : type.getInheritedTypes()) {
        if (sdoc instanceof TemporarySDDocumentType) {
            toReplace.add(sdoc.getDocumentName());
        }
    }
    for (DataTypeName name : toReplace) {
        SDDocumentType inherited = createdSDTypes.get(name);
        if (inherited == null) {
            throw new IllegalStateException("Document type '" + name + "' not found.");
        }
        process(inherited);
        type.inherit(inherited);
    }
    visit(type);
}
Also used : TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType)

Example 30 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SearchOrderer method allInheritedDependenciesEmitted.

private boolean allInheritedDependenciesEmitted(List<Search> alreadyOrdered, SDDocumentType document) {
    for (SDDocumentType sdoc : document.getInheritedTypes()) {
        DataTypeName inheritedName = sdoc.getDocumentName();
        if ("document".equals(inheritedName.getName())) {
            continue;
        }
        Search inheritedSearch = documentNameToSearch.get(inheritedName);
        if (!alreadyOrdered.contains(inheritedSearch)) {
            return false;
        }
    }
    return true;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) DataTypeName(com.yahoo.document.DataTypeName)

Aggregations

SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)48 Test (org.junit.Test)28 SDField (com.yahoo.searchdefinition.document.SDField)23 Search (com.yahoo.searchdefinition.Search)21 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4 ArrayList (java.util.ArrayList)4 DataTypeName (com.yahoo.document.DataTypeName)3 TemporarySDDocumentType (com.yahoo.searchdefinition.document.TemporarySDDocumentType)3 HashMap (java.util.HashMap)3 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 DocumentReferences (com.yahoo.searchdefinition.DocumentReferences)2 RankProfile (com.yahoo.searchdefinition.RankProfile)2 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 DataType (com.yahoo.document.DataType)1