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);
}
}
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")));
}
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")));
}
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);
}
}
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());
}
Aggregations