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);
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations