use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class DocumentProcessing method retrieveDocumentTypes.
private static Map<String, DocumentType> retrieveDocumentTypes(DocumentTypeManager documentTypeManager) {
Map<String, DocumentType> documentTypes = new HashMap<>();
for (Iterator<DocumentType> i = documentTypeManager.documentTypeIterator(); i.hasNext(); ) {
DocumentType type = i.next();
documentTypes.put(type.getName(), type);
}
return Collections.unmodifiableMap(documentTypes);
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JDiscContainerDocprocTest method requireThatLaterDocumentProcessingWorks.
@Test
public void requireThatLaterDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder().servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName())).networking(Networking.disable).documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
DocumentType type = docProc.getDocumentTypes().get("music");
ChainRegistry<DocumentProcessor> chains = docProc.getChains();
assertTrue(chains.allComponentsById().containsKey(new ComponentId(CHAIN_NAME)));
Document doc = new Document(type, "doc:this:is:a:great:album");
doc.setFieldValue("title", "Great Album!");
com.yahoo.docproc.Processing processing;
DocumentProcessor.Progress progress;
DocumentPut put = new DocumentPut(doc);
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
assertThat(progress, instanceOf(DocumentProcessor.LaterProgress.class));
assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
assertThat(progress, instanceOf(DocumentProcessor.LaterProgress.class));
assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
assertThat(doc.getFieldValue("title").toString(), equalTo("Terng Nyohz!"));
}
}
use of com.yahoo.document.DocumentType 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.document.DocumentType in project vespa by vespa-engine.
the class FeedTesterV3 method createDoctypeManager.
DocumentTypeManager createDoctypeManager() {
DocumentTypeManager docTypeManager = new DocumentTypeManager();
DocumentType documentType = new DocumentType("testdocument");
documentType.addField("title", DataType.STRING);
documentType.addField("body", DataType.STRING);
docTypeManager.registerDocumentType(documentType);
return docTypeManager;
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class MockReader method read.
@Override
public void read(Operation operation) throws Exception {
if (finished) {
return;
}
byte whatToDo = stream.getNextOperation();
DocumentId id = new DocumentId("id:banana:banana::doc1");
DocumentType docType = new DocumentType("banana");
switch(whatToDo) {
case 0:
finished = true;
break;
case 1:
Document doc = new Document(docType, id);
operation.setDocument(doc);
break;
case 2:
operation.setRemove(id);
break;
case 3:
operation.setDocumentUpdate(new DocumentUpdate(docType, id));
break;
case 4:
throw new RuntimeException("boom");
}
}
Aggregations