Search in sources :

Example 1 with DataTypeName

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
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Iterator(java.util.Iterator) DataTypeName(com.yahoo.document.DataTypeName) Test(org.junit.Test)

Example 2 with DataTypeName

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;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) DataTypeName(com.yahoo.document.DataTypeName)

Example 3 with DataTypeName

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));
}
Also used : TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ArrayList(java.util.ArrayList) DataTypeName(com.yahoo.document.DataTypeName) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) Test(org.junit.Test)

Example 4 with DataTypeName

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;
}
Also used : Utf8String(com.yahoo.text.Utf8String) DocumentType(com.yahoo.document.DocumentType) DataTypeName(com.yahoo.document.DataTypeName) Utf8Array(com.yahoo.text.Utf8Array)

Aggregations

DataTypeName (com.yahoo.document.DataTypeName)4 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)3 SDField (com.yahoo.searchdefinition.document.SDField)2 Test (org.junit.Test)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 DocumentType (com.yahoo.document.DocumentType)1 Search (com.yahoo.searchdefinition.Search)1 TemporarySDDocumentType (com.yahoo.searchdefinition.document.TemporarySDDocumentType)1 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)1 Utf8Array (com.yahoo.text.Utf8Array)1 Utf8String (com.yahoo.text.Utf8String)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1