Search in sources :

Example 6 with DocumentmanagerConfig

use of com.yahoo.document.config.DocumentmanagerConfig in project vespa by vespa-engine.

the class DocumentTypeManagerConfigurer method addAnnotationTypeInheritance.

private static void addAnnotationTypeInheritance(DocumentmanagerConfig config, DocumentTypeManager manager) {
    for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) {
        if (annType.inherits().size() > 0) {
            AnnotationType inheritedType = manager.getAnnotationTypeRegistry().getType(annType.inherits(0).id());
            AnnotationType type = manager.getAnnotationTypeRegistry().getType(annType.id());
            type.inherit(inheritedType);
        }
    }
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Example 7 with DocumentmanagerConfig

use of com.yahoo.document.config.DocumentmanagerConfig in project vespa by vespa-engine.

the class SplitterJoinerTestCase method testSplitJoin.

@Test
public void testSplitJoin() {
    ConfigGetter<SplitterJoinerDocumentProcessorConfig> getter = new ConfigGetter<>(SplitterJoinerDocumentProcessorConfig.class);
    ConfigGetter<DocumentmanagerConfig> docManGetter = new ConfigGetter<>(DocumentmanagerConfig.class);
    SplitterJoinerDocumentProcessorConfig cfg = getter.getConfig("file:src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg");
    DocumentmanagerConfig docManCfg = docManGetter.getConfig("file:src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg");
    SplitterDocumentProcessor splitter = new SplitterDocumentProcessor(cfg, docManCfg);
    DocumentTypeManager manager = splitter.manager;
    /**
     ** Create documents: ***
     */
    Document inner1 = new Document(manager.getDocumentType("docindoc"), "doc:inner:number:one");
    inner1.setFieldValue("name", new StringFieldValue("Donald Duck"));
    inner1.setFieldValue("content", new StringFieldValue("Lives in Duckburg"));
    Document inner2 = new Document(manager.getDocumentType("docindoc"), "doc:inner:number:two");
    inner2.setFieldValue("name", new StringFieldValue("Uncle Scrooge"));
    inner2.setFieldValue("content", new StringFieldValue("Lives in Duckburg, too."));
    Array<Document> innerArray = (Array<Document>) manager.getDocumentType("outerdoc").getField("innerdocuments").getDataType().createFieldValue();
    innerArray.add(inner1);
    innerArray.add(inner2);
    Document outer = new Document(manager.getDocumentType("outerdoc"), "doc:outer:the:only:one");
    outer.setFieldValue("innerdocuments", innerArray);
    /**
     ** End create documents ***
     */
    Processing p = Processing.of(new DocumentPut(outer));
    splitter.process(p);
    assertEquals(2, p.getDocumentOperations().size());
    assertThat(((DocumentPut) (p.getDocumentOperations().get(0))).getDocument(), sameInstance(inner1));
    assertThat(((DocumentPut) (p.getDocumentOperations().get(1))).getDocument(), sameInstance(inner2));
    assertThat(((DocumentPut) (p.getVariable(cfg.contextFieldName()))).getDocument(), sameInstance(outer));
    assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray));
    assertTrue(innerArray.isEmpty());
    JoinerDocumentProcessor joiner = new JoinerDocumentProcessor(cfg, docManCfg);
    joiner.process(p);
    assertThat(p.getDocumentOperations().size(), equalTo(1));
    assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument(), sameInstance(outer));
    assertThat(p.getVariable(cfg.contextFieldName()), nullValue());
    assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray));
    assertThat(innerArray.size(), equalTo(2));
    assertThat(innerArray.get(0), sameInstance(inner1));
    assertThat(innerArray.get(1), sameInstance(inner2));
}
Also used : ConfigGetter(com.yahoo.config.subscription.ConfigGetter) DocumentPut(com.yahoo.document.DocumentPut) SplitterJoinerDocumentProcessorConfig(com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig) Document(com.yahoo.document.Document) Processing(com.yahoo.docproc.Processing) Array(com.yahoo.document.datatypes.Array) DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Test(org.junit.Test)

Example 8 with DocumentmanagerConfig

use of com.yahoo.document.config.DocumentmanagerConfig in project vespa by vespa-engine.

the class DeriverTestCase method testDeriveDocManager.

@Test
public void testDeriveDocManager() {
    DocumentTypeManager dtm = new DocumentTypeManager(new DocumentmanagerConfig(Deriver.getDocumentManagerConfig(new ArrayList<String>() {

        {
            add("src/test/derived/deriver/child.sd");
            add("src/test/derived/deriver/parent.sd");
            add("src/test/derived/deriver/grandparent.sd");
        }
    })));
    assertEquals(dtm.getDocumentType("child").getField("a").getDataType(), DataType.STRING);
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Test(org.junit.Test)

Example 9 with DocumentmanagerConfig

use of com.yahoo.document.config.DocumentmanagerConfig in project vespa by vespa-engine.

the class DocprocBuilderTest method setupCluster.

@Before
public void setupCluster() {
    ContainerModel model = new ContainerModelBuilder(false, Networking.disable).build(DeployState.createTestState(), null, root, servicesXml());
    cluster = model.getCluster();
    cluster.getDocproc().getChains().addServersAndClientsForChains();
    root.freezeModelTopology();
    containerMbusConfig = root.getConfig(ContainerMbusConfig.class, cluster.getContainers().get(0).getConfigId());
    componentsConfig = root.getConfig(ComponentsConfig.class, cluster.getConfigId());
    chainsConfig = root.getConfig(ChainsConfig.class, cluster.getConfigId() + "/component/com.yahoo.docproc.jdisc.DocumentProcessingHandler");
    documentmanagerConfig = root.getConfig(DocumentmanagerConfig.class, cluster.getConfigId());
    bundlesConfig = root.getConfig(BundlesConfig.class, cluster.getConfigId());
    schemamappingConfig = root.getConfig(SchemamappingConfig.class, cluster.getContainers().get(0).getConfigId());
    qrStartConfig = root.getConfig(QrStartConfig.class, cluster.getConfigId());
    docprocConfig = root.getConfig(DocprocConfig.class, cluster.getConfigId());
}
Also used : ComponentsConfig(com.yahoo.container.ComponentsConfig) BundlesConfig(com.yahoo.container.BundlesConfig) DocprocConfig(com.yahoo.config.docproc.DocprocConfig) SchemamappingConfig(com.yahoo.config.docproc.SchemamappingConfig) DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) ChainsConfig(com.yahoo.container.core.ChainsConfig) QrStartConfig(com.yahoo.search.config.QrStartConfig) ContainerMbusConfig(com.yahoo.container.jdisc.ContainerMbusConfig) ContainerModel(com.yahoo.vespa.model.container.ContainerModel) Before(org.junit.Before)

Example 10 with DocumentmanagerConfig

use of com.yahoo.document.config.DocumentmanagerConfig in project vespa by vespa-engine.

the class DocumentModelBuilderTestCase method testDocumentManagerSimple.

@Test
public void testDocumentManagerSimple() throws IOException, ParseException {
    DocumentModel model = createAndTestModel("src/test/configmodel/types/types.sd");
    DocumentmanagerConfig.Builder documentmanagerCfg = new DocumentManager().produce(model, new DocumentmanagerConfig.Builder());
    assertConfigFile("src/test/configmodel/types/documentmanager.cfg", new DocumentmanagerConfig(documentmanagerCfg).toString());
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DocumentManager(com.yahoo.vespa.configmodel.producers.DocumentManager) Test(org.junit.Test)

Aggregations

DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)14 Test (org.junit.Test)7 AnnotationType (com.yahoo.document.annotation.AnnotationType)4 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)3 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)3 DocumentManager (com.yahoo.vespa.configmodel.producers.DocumentManager)3 Splitter (com.google.common.base.Splitter)1 DocprocConfig (com.yahoo.config.docproc.DocprocConfig)1 SchemamappingConfig (com.yahoo.config.docproc.SchemamappingConfig)1 SplitterJoinerDocumentProcessorConfig (com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig)1 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)1 BundlesConfig (com.yahoo.container.BundlesConfig)1 ComponentsConfig (com.yahoo.container.ComponentsConfig)1 ChainsConfig (com.yahoo.container.core.ChainsConfig)1 ContainerMbusConfig (com.yahoo.container.jdisc.ContainerMbusConfig)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)1 AccessLog (com.yahoo.container.logging.AccessLog)1 Processing (com.yahoo.docproc.Processing)1