Search in sources :

Example 21 with DocumentTypeManager

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

the class VespaFeeder method main.

public static void main(String[] args) {
    LogSetup.initVespaLogging("vespa-feeder");
    try {
        Arguments arguments = new Arguments(args, null);
        DocumentTypeManager manager = new DocumentTypeManager();
        DocumentTypeManagerConfigurer.configure(manager, "client").close();
        VespaFeeder feeder = new VespaFeeder(arguments, manager);
        feeder.parseFiles(System.in, System.out);
        System.exit(0);
    } catch (Arguments.HelpShownException e) {
        System.exit(0);
    } catch (IllegalArgumentException e) {
        System.exit(1);
    } catch (FileNotFoundException e) {
        System.err.println("Could not open file " + e.getMessage());
        System.exit(1);
    } catch (FeedErrorException e) {
        System.err.println("\n" + e.getMessage());
        System.exit(1);
    } catch (Exception e) {
        System.err.println("Got exception " + e.getMessage() + ", aborting feed.");
        System.exit(1);
    }
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager)

Example 22 with DocumentTypeManager

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

the class ScriptManagerTestCase method requireThatScriptsAreAppliedToSuperType.

@Test
public void requireThatScriptsAreAppliedToSuperType() throws ParseException {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    DocumentType docType = typeMgr.getDocumentType("newsarticle");
    assertNotNull(docType);
    IlscriptsConfig.Builder config = new IlscriptsConfig.Builder();
    config.ilscript(new IlscriptsConfig.Ilscript.Builder().doctype("newsarticle").content("index"));
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(config), null);
    assertNotNull(scriptMgr.getScript(typeMgr.getDocumentType("newssummary")));
    assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
Also used : IlscriptsConfig(com.yahoo.vespa.configdefinition.IlscriptsConfig) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 23 with DocumentTypeManager

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

the class ScriptManagerTestCase method requireThatUnknownDocumentTypeReturnsNull.

@Test
public void requireThatUnknownDocumentTypeReturnsNull() {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(new IlscriptsConfig.Builder()), null);
    for (Iterator<DocumentType> it = typeMgr.documentTypeIterator(); it.hasNext(); ) {
        assertNull(scriptMgr.getScript(it.next()));
    }
    assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
Also used : IlscriptsConfig(com.yahoo.vespa.configdefinition.IlscriptsConfig) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 24 with DocumentTypeManager

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

the class JsonReaderTestCase method setUp.

@Before
public void setUp() throws Exception {
    parserFactory = new JsonFactory();
    types = new DocumentTypeManager();
    {
        DocumentType x = new DocumentType("smoke");
        x.addField(new Field("something", DataType.STRING));
        x.addField(new Field("nalle", DataType.STRING));
        x.addField(new Field("int1", DataType.INT));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("mirrors");
        StructDataType woo = new StructDataType("woo");
        woo.addField(new Field("sandra", DataType.STRING));
        woo.addField(new Field("cloud", DataType.STRING));
        x.addField(new Field("skuggsjaa", woo));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testarray");
        DataType d = new ArrayDataType(DataType.STRING);
        x.addField(new Field("actualarray", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testset");
        DataType d = new WeightedSetDataType(DataType.STRING, true, true);
        x.addField(new Field("actualset", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testmap");
        DataType d = new MapDataType(DataType.STRING, DataType.STRING);
        x.addField(new Field("actualmap", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testraw");
        DataType d = DataType.RAW;
        x.addField(new Field("actualraw", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testMapStringToArrayOfInt");
        DataType value = new ArrayDataType(DataType.INT);
        DataType d = new MapDataType(DataType.STRING, value);
        x.addField(new Field("actualMapStringToArrayOfInt", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testsinglepos");
        DataType d = PositionDataType.INSTANCE;
        x.addField(new Field("singlepos", d));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testtensor");
        x.addField(new Field("mappedtensorfield", new TensorDataType(new TensorType.Builder().mapped("x").mapped("y").build())));
        x.addField(new Field("indexedtensorfield", new TensorDataType(new TensorType.Builder().indexed("x").indexed("y").build())));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testpredicate");
        x.addField(new Field("boolean", DataType.PREDICATE));
        types.registerDocumentType(x);
    }
    {
        DocumentType x = new DocumentType("testint");
        x.addField(new Field("integerfield", DataType.INT));
        types.registerDocumentType(x);
    }
}
Also used : Field(com.yahoo.document.Field) TensorDataType(com.yahoo.document.TensorDataType) StructDataType(com.yahoo.document.StructDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) JsonFactory(com.fasterxml.jackson.core.JsonFactory) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) DataType(com.yahoo.document.DataType) MapDataType(com.yahoo.document.MapDataType) TensorDataType(com.yahoo.document.TensorDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) ArrayDataType(com.yahoo.document.ArrayDataType) StructDataType(com.yahoo.document.StructDataType) PositionDataType(com.yahoo.document.PositionDataType) MapDataType(com.yahoo.document.MapDataType) ArrayDataType(com.yahoo.document.ArrayDataType) TensorType(com.yahoo.tensor.TensorType) Before(org.junit.Before)

Example 25 with DocumentTypeManager

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

the class PositionParserTestCase method requireThatPositionStringsCanBeParsed.

@Test
public void requireThatPositionStringsCanBeParsed() throws Exception {
    DocumentTypeManager mgr = new DocumentTypeManager();
    mgr.register(PositionDataType.INSTANCE);
    DocumentType docType = new DocumentType("my_doc");
    docType.addField("my_pos", PositionDataType.INSTANCE);
    mgr.registerDocumentType(docType);
    VespaXMLFeedReader parser = new VespaXMLFeedReader("src/test/vespaxmlparser/test_position.xml", mgr);
    Iterator<VespaXMLFeedReader.Operation> it = parser.readAll().iterator();
    assertTrue(it.hasNext());
    assertDocument(PositionDataType.valueOf(1, 2), it.next());
    assertTrue(it.hasNext());
    assertDocument(PositionDataType.fromString("E3;N4"), it.next());
    assertTrue(it.hasNext());
    assertDocument(PositionDataType.fromString("5;6"), it.next());
    assertTrue(it.hasNext());
    assertDocument(PositionDataType.fromString("7;8"), it.next());
    assertFalse(it.hasNext());
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Aggregations

DocumentTypeManager (com.yahoo.document.DocumentTypeManager)35 Test (org.junit.Test)18 DocumentType (com.yahoo.document.DocumentType)17 Document (com.yahoo.document.Document)12 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)7 Field (com.yahoo.document.Field)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DeserializationException (com.yahoo.document.serialization.DeserializationException)5 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)5 DocumentPut (com.yahoo.document.DocumentPut)4 IlscriptsConfig (com.yahoo.vespa.configdefinition.IlscriptsConfig)4 StructDataType (com.yahoo.document.StructDataType)3 Before (org.junit.Before)3 DocumentUpdate (com.yahoo.document.DocumentUpdate)2 DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)2 Array (com.yahoo.document.datatypes.Array)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)2 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)2 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)2