Search in sources :

Example 21 with DocumentId

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

the class FailingDocumentProcessingTestCase method assertProcessingWorks.

protected void assertProcessingWorks(DocprocService service) {
    // Create documents
    DocumentType type = new DocumentType("test");
    type.addField("test", DataType.STRING);
    DocumentPut put1 = new DocumentPut(type, new DocumentId("doc:failing:test:1"));
    DocumentPut put2 = new DocumentPut(type, new DocumentId("doc:failing:test:2"));
    DocumentPut put3 = new DocumentPut(type, new DocumentId("doc:failing:test:3"));
    // Process them
    service.process(put1);
    service.process(put2);
    service.process(put3);
    while (service.doWork()) {
    }
    // Verify
    assertEquals(new StringFieldValue("done 3"), put1.getDocument().getFieldValue("test"));
    // Due to exception in 2
    assertEquals(new StringFieldValue("done 2"), put2.getDocument().getFieldValue("test"));
    assertEquals(new StringFieldValue("done 3"), put3.getDocument().getFieldValue("test"));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentPut(com.yahoo.document.DocumentPut) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType)

Example 22 with DocumentId

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

the class FailingPermanentlyDocumentProcessingTestCase method assertProcessingWorks.

protected void assertProcessingWorks(DocprocService service) {
    // Create documents
    DocumentType type = new DocumentType("test");
    type.addField("test", DataType.STRING);
    DocumentPut put1 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:1"));
    DocumentPut put2 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:2"));
    DocumentPut put3 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:3"));
    // Process them
    service.process(put1);
    service.process(put2);
    service.process(put3);
    while (service.doWork()) {
    }
    // Verify
    assertEquals(new StringFieldValue("done 3"), put1.getDocument().getFieldValue("test"));
    // Due to PERMANENT_FAILURE in 2
    assertEquals(new StringFieldValue("done 2"), put2.getDocument().getFieldValue("test"));
    // service is disabled now
    assertNull(put3.getDocument().getFieldValue("test"));
    assertFalse(service.isInService());
    service.setInService(true);
    while (service.doWork()) {
    }
    assertEquals(new StringFieldValue("done 3"), put3.getDocument().getFieldValue("test"));
    assertTrue(service.isInService());
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentPut(com.yahoo.document.DocumentPut) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType)

Example 23 with DocumentId

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

the class JsonWriterTestCase method removeTest.

@Test
public void removeTest() {
    final DocumentId documentId = new DocumentId("id:unittest:smoke::whee");
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("[" + Utf8.toString(JsonWriter.documentRemove(documentId)) + "]"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentOperation actualRemoveAsBaseType = r.next();
    assertSame(DocumentRemove.class, actualRemoveAsBaseType.getClass());
    assertEquals(actualRemoveAsBaseType.getId(), documentId);
}
Also used : DocumentOperation(com.yahoo.document.DocumentOperation) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Example 24 with DocumentId

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

the class ReferenceFieldValueTestCase method reference_can_be_constructed_with_id.

@Test
public void reference_can_be_constructed_with_id() {
    DocumentId id = docId("id:ns:foo::itsa-me");
    ReferenceFieldValue value = new ReferenceFieldValue(referenceTypeFoo(), id);
    assertTrue(value.getDocumentId().isPresent());
    assertEquals(id, value.getDocumentId().get());
}
Also used : DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Example 25 with DocumentId

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

the class VdsStreamingSearcher method verifyDocId.

static boolean verifyDocId(String id, Query query, boolean skippedEarlierResult) {
    String expUserId = query.properties().getString(streamingUserid);
    String expGroupName = query.properties().getString(streamingGroupname);
    LogLevel logLevel = LogLevel.ERROR;
    if (skippedEarlierResult) {
        logLevel = LogLevel.DEBUG;
    }
    DocumentId docId;
    try {
        docId = new DocumentId(id);
    } catch (IllegalArgumentException iae) {
        log.log(logLevel, "Bad result for " + query + ": " + iae.getMessage());
        return false;
    }
    if (expUserId != null) {
        long userId;
        if (docId.getScheme().hasNumber()) {
            userId = docId.getScheme().getNumber();
        } else {
            log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.userdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
            return false;
        }
        if (new BigInteger(expUserId).longValue() != userId) {
            log.log(logLevel, "Got result with wrong user ID (expected " + expUserId + ") in document ID (" + id + ") for " + query);
            return false;
        }
    } else if (expGroupName != null) {
        String groupName;
        if (docId.getScheme().hasGroup()) {
            groupName = docId.getScheme().getGroup();
        } else {
            log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.groupdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
            return false;
        }
        if (!expGroupName.equals(groupName)) {
            log.log(logLevel, "Got result with wrong group name (expected " + expGroupName + ") in document ID (" + id + ") for " + query);
            return false;
        }
    }
    return true;
}
Also used : DocumentId(com.yahoo.document.DocumentId) BigInteger(java.math.BigInteger) IdString(com.yahoo.document.idstring.IdString) LogLevel(com.yahoo.log.LogLevel)

Aggregations

DocumentId (com.yahoo.document.DocumentId)61 Test (org.junit.Test)28 DocumentType (com.yahoo.document.DocumentType)20 Document (com.yahoo.document.Document)16 DocumentPut (com.yahoo.document.DocumentPut)12 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)9 BucketId (com.yahoo.document.BucketId)7 DocumentRemove (com.yahoo.document.DocumentRemove)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 BucketIdFactory (com.yahoo.document.BucketIdFactory)4 FieldUpdate (com.yahoo.document.update.FieldUpdate)4 DocumentOperation (com.yahoo.document.DocumentOperation)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 Hit (com.yahoo.search.result.Hit)3 HashMap (java.util.HashMap)3 TestDocumentProcessor1 (com.yahoo.docproc.DocumentProcessingAbstractTestCase.TestDocumentProcessor1)2 Field (com.yahoo.document.Field)2 GlobalId (com.yahoo.document.GlobalId)2 StructDataType (com.yahoo.document.StructDataType)2 Struct (com.yahoo.document.datatypes.Struct)2