use of de.lmu.ifi.dbs.elki.database.relation.ModifiableRelation in project elki by elki-project.
the class HashmapDatabase method insert.
@Override
public DBIDs insert(ObjectBundle objpackages) {
if (objpackages.dataLength() == 0) {
return DBIDUtil.EMPTYDBIDS;
}
// insert into db
ArrayModifiableDBIDs newids = DBIDUtil.newArray(objpackages.dataLength());
Relation<?>[] targets = alignColumns(objpackages);
DBIDVar var = DBIDUtil.newVar();
for (int j = 0; j < objpackages.dataLength(); j++) {
// insert object
if (!objpackages.assignDBID(j, var)) {
var.set(DBIDUtil.generateSingleDBID());
}
if (ids.contains(var)) {
throw new AbortException("Duplicate DBID conflict.");
}
ids.add(var);
for (int i = 0; i < targets.length; i++) {
if (!(targets[i] instanceof ModifiableRelation)) {
throw new AbortException("Non-modifiable relations have been added to the database.");
}
@SuppressWarnings("unchecked") final ModifiableRelation<Object> relation = (ModifiableRelation<Object>) targets[i];
relation.insert(var, objpackages.data(j, i));
}
newids.add(var);
}
// fire insertion event
eventManager.fireObjectsInserted(newids);
return newids;
}
Aggregations