Search in sources :

Example 1 with DocumentType

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);
}
Also used : HashMap(java.util.HashMap) DocumentType(com.yahoo.document.DocumentType)

Example 2 with DocumentType

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!"));
    }
}
Also used : Rot13DocumentProcessor(com.yahoo.application.container.docprocs.Rot13DocumentProcessor) Rot13DocumentProcessor(com.yahoo.application.container.docprocs.Rot13DocumentProcessor) DocumentProcessor(com.yahoo.docproc.DocumentProcessor) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) ApplicationBuilder(com.yahoo.application.ApplicationBuilder) Application(com.yahoo.application.Application) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 3 with DocumentType

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());
}
Also used : Field(com.yahoo.document.Field) FieldSets(com.yahoo.searchdefinition.FieldSets) ReferenceDataType(com.yahoo.document.ReferenceDataType) StructDataType(com.yahoo.document.StructDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 4 with DocumentType

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;
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType)

Example 5 with DocumentType

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");
    }
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document)

Aggregations

DocumentType (com.yahoo.document.DocumentType)98 Test (org.junit.Test)45 Document (com.yahoo.document.Document)41 DocumentPut (com.yahoo.document.DocumentPut)35 Field (com.yahoo.document.Field)24 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)24 DocumentId (com.yahoo.document.DocumentId)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 InputStream (java.io.InputStream)19 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)17 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)17 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)17 DocumentUpdate (com.yahoo.document.DocumentUpdate)15 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)15 StructDataType (com.yahoo.document.StructDataType)14 TensorDataType (com.yahoo.document.TensorDataType)12 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)11 ArrayDataType (com.yahoo.document.ArrayDataType)10 MapDataType (com.yahoo.document.MapDataType)10 ReferenceDataType (com.yahoo.document.ReferenceDataType)10