Search in sources :

Example 26 with DocumentUpdate

use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.

the class DocumentOperationMessageV3 method newUpdateMessage.

static DocumentOperationMessageV3 newUpdateMessage(VespaXMLFeedReader.Operation op, String operationId) {
    DocumentUpdate update = op.getDocumentUpdate();
    update.setCondition(op.getCondition());
    Message msg = new UpdateDocumentMessage(update);
    String id = (operationId == null) ? update.getId().toString() : operationId;
    return new DocumentOperationMessageV3(id, msg);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 27 with DocumentUpdate

use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.

the class Feeder method newUpdateMessage.

private Tuple2<String, Message> newUpdateMessage(Operation op, String operationId) {
    DocumentUpdate update = op.getDocumentUpdate();
    update.setCondition(op.getCondition());
    Message msg = new UpdateDocumentMessage(update);
    String id = (operationId == null) ? update.getId().toString() : operationId;
    return new Tuple2<>(id, msg);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) Utf8String(com.yahoo.text.Utf8String) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 28 with DocumentUpdate

use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.

the class VespaFeederTestCase method feedFile.

@Test
public void feedFile() throws Exception {
    FeedFixture f = new FeedFixture();
    Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --priority LOW_1".split(" "), f.sessionFactory);
    new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
    assertEquals(3, f.sessionFactory.messages.size());
    assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getPriority());
    assertEquals("doc:test:foo", ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getDocumentPut().getDocument().getId().toString());
    DocumentUpdate update = ((UpdateDocumentMessage) f.sessionFactory.messages.get(1)).getDocumentUpdate();
    assertEquals("doc:test:foo", update.getId().toString());
    assertFalse(update.getCreateIfNonExistent());
    assertEquals("doc:test:foo", ((RemoveDocumentMessage) f.sessionFactory.messages.get(2)).getDocumentId().toString());
    assertTrue(f.outputStream.toString().contains("Messages sent to vespa"));
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) Test(org.junit.Test)

Example 29 with DocumentUpdate

use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.

the class IndexingProcessorTestCase method requireThatEmptyDocumentUpdateOutputDoesNotThrow.

@Test
public void requireThatEmptyDocumentUpdateOutputDoesNotThrow() {
    DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
    DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
    Processing proc = new Processing();
    proc.getDocumentOperations().add(input);
    indexer.process(proc);
    assertEquals(0, proc.getDocumentOperations().size());
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) Processing(com.yahoo.docproc.Processing) Test(org.junit.Test)

Example 30 with DocumentUpdate

use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.

the class IndexingProcessorTestCase method requireThatIndexerProcessesUpdates.

@Test
public void requireThatIndexerProcessesUpdates() {
    DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
    DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
    input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("isbn"), new StringFieldValue("isbnmarker")));
    input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("artist"), new StringFieldValue("69")));
    DocumentOperation output = process(input);
    assertTrue(output instanceof DocumentUpdate);
    DocumentUpdate docUpdate = (DocumentUpdate) output;
    assertEquals(3, docUpdate.getFieldUpdates().size());
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(0);
        assertEquals("song", fieldUpdate.getField().getName());
        assertEquals(1, fieldUpdate.getValueUpdates().size());
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
        fieldUpdate = docUpdate.getFieldUpdate(1);
        assertEquals("title", fieldUpdate.getField().getName());
        assertEquals(1, fieldUpdate.getValueUpdates().size());
        valueUpdate = fieldUpdate.getValueUpdate(0);
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
    }
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(1);
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertEquals("title", fieldUpdate.getField().getName());
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
    }
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(2);
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertEquals("isbn", fieldUpdate.getField().getName());
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
    }
}
Also used : ValueUpdate(com.yahoo.document.update.ValueUpdate) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) DocumentOperation(com.yahoo.document.DocumentOperation) DocumentUpdate(com.yahoo.document.DocumentUpdate) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldUpdate(com.yahoo.document.update.FieldUpdate) DocumentType(com.yahoo.document.DocumentType) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) Test(org.junit.Test)

Aggregations

DocumentUpdate (com.yahoo.document.DocumentUpdate)43 Test (org.junit.Test)24 FieldUpdate (com.yahoo.document.update.FieldUpdate)16 DocumentType (com.yahoo.document.DocumentType)15 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)12 AssignValueUpdate (com.yahoo.document.update.AssignValueUpdate)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 InputStream (java.io.InputStream)9 Document (com.yahoo.document.Document)8 DocumentOperation (com.yahoo.document.DocumentOperation)8 DocumentPut (com.yahoo.document.DocumentPut)7 DocumentRemove (com.yahoo.document.DocumentRemove)6 DocumentId (com.yahoo.document.DocumentId)5 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)5 AddValueUpdate (com.yahoo.document.update.AddValueUpdate)5 ArithmeticValueUpdate (com.yahoo.document.update.ArithmeticValueUpdate)5 ClearValueUpdate (com.yahoo.document.update.ClearValueUpdate)5 MapValueUpdate (com.yahoo.document.update.MapValueUpdate)5 ValueUpdate (com.yahoo.document.update.ValueUpdate)5 HashMap (java.util.HashMap)5