use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class ContentCluster method getConfig.
@Override
public void getConfig(BucketspacesConfig.Builder builder) {
for (NewDocumentType docType : getDocumentDefinitions().values()) {
BucketspacesConfig.Documenttype.Builder docTypeBuilder = new BucketspacesConfig.Documenttype.Builder();
docTypeBuilder.name(docType.getName());
String bucketSpace = ((enableMultipleBucketSpaces && isGloballyDistributed(docType)) ? GLOBAL_BUCKET_SPACE : DEFAULT_BUCKET_SPACE);
docTypeBuilder.bucketspace(bucketSpace);
builder.documenttype(docTypeBuilder);
}
builder.enable_multiple_bucket_spaces(enableMultipleBucketSpaces);
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class SearchDefinitionBuilder method build.
public Map<String, NewDocumentType> build(DocumentTypeRepo repo, ModelElement elem) {
Map<String, NewDocumentType> docTypes = new TreeMap<>();
if (elem != null) {
for (ModelElement e : elem.subElements("document")) {
// Schema-guaranteed presence
String name = e.getStringAttribute("type");
NewDocumentType documentType = repo.getDocumentType(name);
if (documentType != null) {
docTypes.put(documentType.getName(), documentType);
} else {
throw new RuntimeException("Document type '" + name + "' not found in application package");
}
}
}
return docTypes;
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class DocumentTypeChangeValidatorTest method createDocumentTypeWithReferenceField.
private static NewDocumentType createDocumentTypeWithReferenceField(String nameReferencedDocumentType) {
StructDataType headerfields = new StructDataType("headerfields");
headerfields.addField(new Field("ref", new ReferenceDataType(new DocumentType(nameReferencedDocumentType), 0)));
return new NewDocumentType(new NewDocumentType.Name("mydoc"), headerfields, new StructDataType("bodyfields"), new FieldSets(), Collections.emptySet());
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class DocumentModelBuilderReferenceTypeTestCase method reference_data_type_has_a_concrete_target_type.
@Test
public void reference_data_type_has_a_concrete_target_type() throws ParseException {
DocumentModel model = new TestDocumentModelBuilder().addCampaign().build(joinLines("search ad {", " document ad {", " field campaign_ref type reference<campaign> { indexing: attribute }", " }", "}"));
NewDocumentType campaignType = model.getDocumentManager().getDocumentType("campaign");
NewDocumentType adType = model.getDocumentManager().getDocumentType("ad");
ReferenceDataType campaignRefType = (ReferenceDataType) adType.getField("campaign_ref").getDataType();
assertEquals(campaignRefType.getTargetType(), campaignType);
}
use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.
the class GlobalDistributionValidatorTest method validation_succeeds_if_referenced_document_is_global.
@Test
public void validation_succeeds_if_referenced_document_is_global() {
NewDocumentType parent = createDocumentType("parent");
Fixture fixture = new Fixture().addGlobalDocument(parent).addNonGlobalDocument(createDocumentType("child", parent));
Redundancy redundancy = createRedundancyWithGlobalDistribution();
validate(fixture, redundancy);
}
Aggregations