Search in sources :

Example 1 with TemporarySDDocumentType

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

the class SDDocumentTypeOrderer method process.

private void process(SDDocumentType type) {
    List<DataTypeName> toReplace = new ArrayList<>();
    for (SDDocumentType sdoc : type.getInheritedTypes()) {
        if (sdoc instanceof TemporarySDDocumentType) {
            toReplace.add(sdoc.getDocumentName());
        }
    }
    for (DataTypeName name : toReplace) {
        SDDocumentType inherited = createdSDTypes.get(name);
        if (inherited == null) {
            throw new IllegalStateException("Document type '" + name + "' not found.");
        }
        process(inherited);
        type.inherit(inherited);
    }
    visit(type);
}
Also used : TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType)

Example 2 with TemporarySDDocumentType

use of com.yahoo.searchdefinition.document.TemporarySDDocumentType 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)

Aggregations

SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)2 TemporarySDDocumentType (com.yahoo.searchdefinition.document.TemporarySDDocumentType)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 DataTypeName (com.yahoo.document.DataTypeName)1 SDField (com.yahoo.searchdefinition.document.SDField)1 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1