use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class StringTestCase method consume.
public Document consume(Document document, DocumentTypeManager docTypeMgr) {
DocumentType type = docTypeMgr.getDocumentType("blog");
Collection<Field> fc = type.getFields();
for (Field f : fc) {
System.out.println("\n\nField Name: " + f.getName());
System.out.println("DataType: " + f.getDataType());
System.out.println("isHeader? " + f.isHeader());
FieldValue val = document.getFieldValue(f);
if (val instanceof StringFieldValue) {
StringFieldValue sfv = (StringFieldValue) val;
System.out.println(f.getName() + " is a StringField. Field Value: " + sfv.getString());
Collection<SpanTree> c = sfv.getSpanTrees();
for (SpanTree tree : c) {
System.out.println(f.getName() + " has annotations");
consumeAnnotations(tree, (SpanList) tree.getRoot());
}
}
}
return document;
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class XmlDocumentWriterTestCase method requireThatPredicateFieldValuesAreSerializedAsString.
@Test
public void requireThatPredicateFieldValuesAreSerializedAsString() {
DocumentType docType = new DocumentType("my_type");
Field field = new Field("my_predicate", DataType.PREDICATE);
docType.addField(field);
Document doc = new Document(docType, "doc:scheme:");
PredicateFieldValue predicate = Mockito.mock(PredicateFieldValue.class);
doc.setFieldValue("my_predicate", predicate);
new XmlDocumentWriter().write(doc);
Mockito.verify(predicate, Mockito.times(1)).printXml(Mockito.any(XmlStream.class));
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class VespaDocumentDeserializer42 method readDocumentType.
public DocumentType readDocumentType() {
Utf8Array docTypeName = parseNullTerminatedString();
// used to hold the version
int ignored = getShort(null);
DocumentType docType = manager.getDocumentType(new DataTypeName(docTypeName));
if (docType == null) {
throw new DeserializationException("No known document type with name " + new Utf8String(docTypeName).toString());
}
return docType;
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class Bug4261985TestCase method testAnnotate.
@Test
public void testAnnotate() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4261985.cfg");
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "doc:this:is:a:test");
doc.setFieldValue("body", new StringFieldValue("bla bla bla bla bla bla bla" + "bla bla bla bla bla bla bla"));
annotate(doc, manager);
GrowableByteBuffer buf = new GrowableByteBuffer();
doc.serialize(buf);
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class Bug4259784TestCase method testSerialize.
@Test
public void testSerialize() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4259784.cfg");
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "doc:this:is:a:test");
doc.setFieldValue("body", new StringFieldValue("bla bla bla bla bla bla bla" + "bla bla bla bla bla bla bla"));
annotate(doc, manager);
GrowableByteBuffer buf = new GrowableByteBuffer();
doc.serialize(buf);
}
Aggregations