Search in sources :

Example 86 with StringFieldValue

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

the class DocumentTestCase method validateCppDoc.

public void validateCppDoc(Document doc) throws IOException {
    validateCppDocNotMap(doc);
    MapFieldValue map = (MapFieldValue) doc.getFieldValue("mapfield");
    assertEquals(map.get(new StringFieldValue("foo1")), new StringFieldValue("bar1"));
    assertEquals(map.get(new StringFieldValue("foo2")), new StringFieldValue("bar2"));
}
Also used : MapFieldValue(com.yahoo.document.datatypes.MapFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Example 87 with StringFieldValue

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

the class Bug4475379TestCase method testClone.

@Test
public void testClone() {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
    DocumentType type = manager.getDocumentType("blog");
    Document doc = new Document(type, "doc:this:is:a:test");
    doc.setFieldValue("body", new StringFieldValue(""));
    annotate(manager, doc);
    Document anotherDoc = doc.clone();
    assertThat(doc, equalTo(anotherDoc));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 88 with StringFieldValue

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

the class Bug6425939TestCase method canDeserializeAnnotationsOnZeroLengthStrings.

@Test
public void canDeserializeAnnotationsOnZeroLengthStrings() {
    StringFieldValue emptyString = new StringFieldValue("");
    emptyString.setSpanTree(createSpanTree());
    GrowableByteBuffer buffer = new GrowableByteBuffer(1024);
    DocumentSerializer serializer = DocumentSerializerFactory.create42(buffer);
    Field strField = new Field("flarn", DataType.STRING);
    serializer.write(strField, emptyString);
    buffer.flip();
    // Should not throw exception if bug 6425939 is fixed:
    DocumentDeserializer deserializer = DocumentDeserializerFactory.create42(man, buffer);
    StringFieldValue deserializedString = new StringFieldValue();
    deserializer.read(strField, deserializedString);
    assertEquals("", deserializedString.getString());
    SpanTree readTree = deserializedString.getSpanTree("SpanTree1");
    assertNotNull(readTree);
}
Also used : Field(com.yahoo.document.Field) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) GrowableByteBuffer(com.yahoo.io.GrowableByteBuffer) Test(org.junit.Test)

Example 89 with StringFieldValue

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

the class SpanListAdvTestCase method getAnnotationsForNode.

public void getAnnotationsForNode(SpanNode node) {
    Iterator<Annotation> iter = tree.iterator(node);
    boolean annotationPresent = false;
    while (iter.hasNext()) {
        annotationPresent = true;
        Annotation xx = iter.next();
        AnnotationType t = xx.getType();
        StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
        if (debug)
            System.out.println("Annotation: " + xx);
        if (fValue == null) {
            if (debug)
                System.out.println("Field Value is null");
            return;
        } else {
            if (debug)
                System.out.println("Field Value: " + fValue.getString());
        }
    }
    if (!annotationPresent) {
        if (debug)
            System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
    }
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Example 90 with StringFieldValue

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

the class SpanNodeAdvTestCase method getAnnotationsForNode.

public void getAnnotationsForNode(SpanNode node) {
    Iterator<Annotation> iter = tree.iterator(node);
    boolean annotationPresent = false;
    while (iter.hasNext()) {
        annotationPresent = true;
        Annotation xx = iter.next();
        AnnotationType t = xx.getType();
        StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
        if (debug)
            System.out.println("Annotation: " + xx);
        if (fValue == null) {
            if (debug)
                System.out.println("Field Value is null");
            return;
        } else {
            if (debug)
                System.out.println("Field Value: " + fValue.getString());
        }
    }
    if (!annotationPresent) {
        if (debug)
            System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
    }
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Aggregations

StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)210 Test (org.junit.Test)136 FieldValue (com.yahoo.document.datatypes.FieldValue)49 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)40 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)37 Document (com.yahoo.document.Document)30 Array (com.yahoo.document.datatypes.Array)25 DocumentType (com.yahoo.document.DocumentType)21 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)21 Struct (com.yahoo.document.datatypes.Struct)21 DocumentPut (com.yahoo.document.DocumentPut)20 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)20 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)18 SpanTree (com.yahoo.document.annotation.SpanTree)15 FieldUpdate (com.yahoo.document.update.FieldUpdate)15 DocumentUpdate (com.yahoo.document.DocumentUpdate)12 Field (com.yahoo.document.Field)12 Annotation (com.yahoo.document.annotation.Annotation)12 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)12 HashMap (java.util.HashMap)12