Search in sources :

Example 31 with DocumentPut

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

the class EntryTestCase method testEquals.

public void testEquals() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg");
    DocumentType bmType = manager.getDocumentType("benchmark");
    DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
    DocumentPut put2 = new DocumentPut(bmType, "userdoc:foo:99999999:2");
    Entry entry1 = Entry.create(put1);
    Entry entry2 = Entry.create(put1);
    assert (entry1.equals(entry2));
    Entry entry3 = Entry.create(put2);
    assert (!entry1.equals(entry3));
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType)

Example 32 with DocumentPut

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

the class EntryTestCase method testHashCode.

public void testHashCode() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg");
    DocumentType bmType = manager.getDocumentType("benchmark");
    DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
    DocumentPut put2 = new DocumentPut(bmType, "userdoc:foo:99999999:2");
    Entry entry1 = Entry.create(put1);
    Entry entry2 = Entry.create(put1);
    assert (entry1.hashCode() == entry2.hashCode());
    Entry entry3 = Entry.create(put2);
    assert (entry1.hashCode() != entry3.hashCode());
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType)

Example 33 with DocumentPut

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

the class DynamicEntry method getTimestamp.

@Override
public long getTimestamp() {
    if (op instanceof DocumentPut) {
        DocumentPut put = (DocumentPut) op;
        final Long lastModified = put.getDocument().getLastModified();
        if (lastModified != null) {
            return lastModified;
        }
    }
    return 0L;
}
Also used : DocumentPut(com.yahoo.document.DocumentPut)

Example 34 with DocumentPut

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

the class DocumentOperationMessageV3 method newPutMessage.

static DocumentOperationMessageV3 newPutMessage(VespaXMLFeedReader.Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new DocumentOperationMessageV3(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) 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) DocumentPut(com.yahoo.document.DocumentPut)

Example 35 with DocumentPut

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

the class Feeder method newPutMessage.

private Tuple2<String, Message> newPutMessage(Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new Tuple2<>(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) 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) DocumentPut(com.yahoo.document.DocumentPut) Utf8String(com.yahoo.text.Utf8String)

Aggregations

DocumentPut (com.yahoo.document.DocumentPut)67 Document (com.yahoo.document.Document)40 DocumentType (com.yahoo.document.DocumentType)35 Test (org.junit.Test)30 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)23 ByteArrayInputStream (java.io.ByteArrayInputStream)21 InputStream (java.io.InputStream)21 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)16 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)16 DocumentOperation (com.yahoo.document.DocumentOperation)13 DocumentId (com.yahoo.document.DocumentId)12 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)11 FieldValue (com.yahoo.document.datatypes.FieldValue)10 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)10 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)10 DocumentRemove (com.yahoo.document.DocumentRemove)8 DocumentUpdate (com.yahoo.document.DocumentUpdate)7 Array (com.yahoo.document.datatypes.Array)7 DocumentProcessor (com.yahoo.docproc.DocumentProcessor)6 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)5