use of com.yahoo.document.DataTypeName in project vespa by vespa-engine.
the class SDDocumentTypeTestCase method testInheritance.
@Test
public void testInheritance() {
SDDocumentType child = new SDDocumentType("child");
Iterator<SDDocumentType> inherited = child.getInheritedTypes().iterator();
assertTrue(inherited.hasNext());
assertEquals(inherited.next().getDocumentName(), VespaDocumentType.NAME);
assertFalse(inherited.hasNext());
child.addField("childfield", DataType.INT);
SDField overridden = child.addField("overridden", DataType.STRING);
SDDocumentType parent1 = new SDDocumentType("parent1");
SDField overridden2 = parent1.addField("overridden", DataType.STRING);
parent1.addField("parent1field", DataType.STRING);
child.inherit(parent1);
SDDocumentType parent2 = new SDDocumentType("parent2");
parent2.addField("parent2field", DataType.STRING);
child.inherit(parent2);
SDDocumentType root = new SDDocumentType("root");
root.addField("rootfield", DataType.STRING);
parent1.inherit(root);
parent2.inherit(root);
inherited = child.getInheritedTypes().iterator();
assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName());
assertEquals(new DataTypeName("parent1"), inherited.next().getDocumentName());
assertEquals(new DataTypeName("parent2"), inherited.next().getDocumentName());
assertTrue(!inherited.hasNext());
inherited = parent1.getInheritedTypes().iterator();
assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName());
assertEquals(new DataTypeName("root"), inherited.next().getDocumentName());
assertTrue(!inherited.hasNext());
inherited = parent2.getInheritedTypes().iterator();
assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName());
assertEquals(new DataTypeName("root"), inherited.next().getDocumentName());
assertTrue(!inherited.hasNext());
inherited = root.getInheritedTypes().iterator();
assertTrue(inherited.hasNext());
assertEquals(inherited.next().getDocumentName(), VespaDocumentType.NAME);
assertFalse(inherited.hasNext());
Iterator fields = child.fieldSet().iterator();
SDField field;
field = (SDField) fields.next();
assertEquals("rootfield", field.getName());
field = (SDField) fields.next();
assertEquals("overridden", field.getName());
field = (SDField) fields.next();
assertEquals("parent1field", field.getName());
field = (SDField) fields.next();
assertEquals("parent2field", field.getName());
field = (SDField) fields.next();
assertEquals("childfield", field.getName());
// TODO: Test uninheriting
}
use of com.yahoo.document.DataTypeName in project vespa by vespa-engine.
the class SearchOrderer method allInheritedDependenciesEmitted.
private boolean allInheritedDependenciesEmitted(List<Search> alreadyOrdered, SDDocumentType document) {
for (SDDocumentType sdoc : document.getInheritedTypes()) {
DataTypeName inheritedName = sdoc.getDocumentName();
if ("document".equals(inheritedName.getName())) {
continue;
}
Search inheritedSearch = documentNameToSearch.get(inheritedName);
if (!alreadyOrdered.contains(inheritedSearch)) {
return false;
}
}
return true;
}
use of com.yahoo.document.DataTypeName in project vespa by vespa-engine.
the class SDDocumentTypeOrdererTestCase method testOrder.
@Test
public void testOrder() {
List<SDDocumentType> types = new ArrayList<>();
SDDocumentType a = new SDDocumentType("a");
SDDocumentType b = new SDDocumentType("b");
SDDocumentType c = new SDDocumentType("c");
SDDocumentType d = new SDDocumentType("d");
SDDocumentType e = new SDDocumentType("e");
SDDocumentType f = new SDDocumentType("f");
SDDocumentType g = new SDDocumentType("g");
b.inherit(new TemporarySDDocumentType(new DataTypeName("a")));
c.inherit(new TemporarySDDocumentType(new DataTypeName("b")));
d.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
g.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
g.inherit(new TemporarySDDocumentType(new DataTypeName("c")));
SDField aFieldTypeB = new TemporarySDField("atypeb", DataType.STRING);
a.addField(aFieldTypeB);
SDField bFieldTypeC = new TemporarySDField("btypec", DataType.STRING);
b.addField(bFieldTypeC);
SDField cFieldTypeG = new TemporarySDField("ctypeg", DataType.STRING);
c.addField(cFieldTypeG);
SDField gFieldTypeF = new TemporarySDField("gtypef", DataType.STRING);
g.addField(gFieldTypeF);
SDField fFieldTypeC = new TemporarySDField("ftypec", DataType.STRING);
f.addField(fFieldTypeC);
SDField dFieldTypeE = new TemporarySDField("dtypee", DataType.STRING);
d.addField(dFieldTypeE);
types.add(a);
types.add(b);
types.add(c);
types.add(d);
types.add(e);
types.add(f);
types.add(g);
SDDocumentTypeOrderer app = new SDDocumentTypeOrderer(types, new BaseDeployLogger());
app.process();
assertEquals(7, app.processingOrder.size());
assertEquals(a, app.processingOrder.get(0));
assertEquals(b, app.processingOrder.get(1));
assertEquals(c, app.processingOrder.get(2));
assertEquals(e, app.processingOrder.get(3));
assertEquals(d, app.processingOrder.get(4));
assertEquals(f, app.processingOrder.get(5));
assertEquals(g, app.processingOrder.get(6));
}
use of com.yahoo.document.DataTypeName 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;
}
Aggregations