Search in sources :

Example 6 with DocumentUpdate

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

the class DocumentScriptTestCase method processPathUpdate.

private static ValueUpdate<?> processPathUpdate(FieldValue fieldValue) {
    DocumentType docType = new DocumentType("myDocumentType");
    docType.addField("myField", fieldValue.getDataType());
    DocumentUpdate update = new DocumentUpdate(docType, "doc:scheme:");
    update.addFieldPathUpdate(new AssignFieldPathUpdate(docType, "myField", fieldValue));
    update = newScript(docType).execute(ADAPTER_FACTORY, update);
    return update.getFieldUpdate("myField").getValueUpdate(0);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate)

Example 7 with DocumentUpdate

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

the class JsonFeedReader method read.

@Override
public void read(Operation operation) throws Exception {
    DocumentOperation documentOperation = reader.next();
    if (documentOperation == null) {
        stream.close();
        operation.setInvalid();
        return;
    }
    if (documentOperation instanceof DocumentUpdate) {
        operation.setDocumentUpdate((DocumentUpdate) documentOperation);
    } else if (documentOperation instanceof DocumentRemove) {
        operation.setRemove(documentOperation.getId());
    } else if (documentOperation instanceof DocumentPut) {
        operation.setDocument(((DocumentPut) documentOperation).getDocument());
    } else {
        throw new IllegalStateException("Got unknown class from JSON reader: " + documentOperation.getClass().getName());
    }
    operation.setCondition(documentOperation.getCondition());
}
Also used : DocumentOperation(com.yahoo.document.DocumentOperation) DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentRemove(com.yahoo.document.DocumentRemove) DocumentPut(com.yahoo.document.DocumentPut)

Example 8 with DocumentUpdate

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

the class VespaFeederTestCase method requireThatCreateIfNonExistentArgumentIsUsed.

@Test
public void requireThatCreateIfNonExistentArgumentIsUsed() throws Exception {
    FeedFixture f = new FeedFixture();
    Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --create-if-non-existent".split(" "), f.sessionFactory);
    new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
    assertEquals(3, f.sessionFactory.messages.size());
    DocumentUpdate update = ((UpdateDocumentMessage) f.sessionFactory.messages.get(1)).getDocumentUpdate();
    assertTrue(update.getCreateIfNonExistent());
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) Test(org.junit.Test)

Example 9 with DocumentUpdate

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

the class VespaFeederTestCase method assertJsonFeedState.

protected void assertJsonFeedState(FeedFixture feedFixture) {
    assertEquals(3, feedFixture.sessionFactory.messages.size());
    assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage) feedFixture.sessionFactory.messages.get(0)).getPriority());
    assertEquals("id:test:news::foo", ((PutDocumentMessage) feedFixture.sessionFactory.messages.get(0)).getDocumentPut().getDocument().getId().toString());
    DocumentUpdate update = ((UpdateDocumentMessage) feedFixture.sessionFactory.messages.get(1)).getDocumentUpdate();
    assertEquals("id:test:news::foo", update.getId().toString());
    assertFalse(update.getCreateIfNonExistent());
    assertEquals("id:test:news::foo", ((RemoveDocumentMessage) feedFixture.sessionFactory.messages.get(2)).getDocumentId().toString());
    assertTrue(feedFixture.outputStream.toString().contains("Messages sent to vespa"));
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate)

Example 10 with DocumentUpdate

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

the class IndexingProcessorTestCase method requireThatIndexerForwardsUpdatesOfUnknownType.

@Test
public void requireThatIndexerForwardsUpdatesOfUnknownType() {
    DocumentUpdate input = new DocumentUpdate(new DocumentType("unknown"), "doc:scheme:");
    DocumentOperation output = process(input);
    assertSame(input, output);
}
Also used : DocumentOperation(com.yahoo.document.DocumentOperation) DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) 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