use of de.lmu.ifi.dbs.elki.datasource.parser.SimpleTransactionParser in project elki by elki-project.
the class AbstractFrequentItemsetAlgorithmTest method loadTransactions.
/**
* Load a transaction database.
*
* @param filename Filename
* @param expectedSize Expected size
* @return Database
*/
public static <T> Database loadTransactions(String filename, int expectedSize) {
// Allow loading test data from resources.
try (InputStream is = open(filename)) {
// Instantiate filters manually. TODO: redesign
List<ObjectFilter> filterlist = new ArrayList<>();
filterlist.add(new FixedDBIDsFilter(1));
// Setup parser and data loading
SimpleTransactionParser parser = new SimpleTransactionParser(CSVReaderFormat.DEFAULT_FORMAT);
InputStreamDatabaseConnection dbc = new InputStreamDatabaseConnection(is, filterlist, parser);
// We want to allow the use of indexes via "params"
Database db = //
new ELKIBuilder<>(StaticArrayDatabase.class).with(AbstractDatabase.Parameterizer.DATABASE_CONNECTION_ID, dbc).build();
db.initialize();
Relation<?> rel = db.getRelation(TypeUtil.ANY);
if (expectedSize > 0) {
assertEquals("Database size does not match.", expectedSize, rel.size());
}
return db;
} catch (IOException e) {
fail("Test data " + filename + " not found.");
// Not reached.
return null;
}
}
Aggregations