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