ELKI - Use List<String> of objects to populate the Database

 ̄綄美尐妖づ 提交于 2020-01-05 18:55:14

问题


Sorry for the naive question, but I got stuck while following all the pieces of tutorials available. So, is there a way to populate a Database db from a simple List rather than loading it reading a file?

Basically what I'm looking for is something similar to:

List objects = ...

Database db = ClassGenericsUtil.parameterizeOrAbort(ArrayDatabase.class, params, objects);

db.initialize();

Thanks in advance.


回答1:


What are the contents of your Strings? Same as understood by the ELKI parsers?

This will likely require some code modifications, because the parsers are designed around Javas InputStream. I don't suggest wrapping a List<String> into an InputStream although that would probably be the least-effort approach.

Why don't you try extending AbstractDatabaseConnection (or implementing DatabaseConnection)? The database connection format, MultipleObjectsBundle is not much more than List<Object> and relation metadata; fairly easy to construct.

Alternatively, you could use your own code to parse the Strings into double[] and then use ArrayAdapterDatabaseConnection; which will wrap the double[] as DoubleVector for you and construct the bundles.



来源:https://stackoverflow.com/questions/19841999/elki-use-liststring-of-objects-to-populate-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!