lbuf = new ArrayList<>();
for(Object obj : objects.getColumn(i)) {
if(obj != null) {
LabelList ll = (LabelList) obj;
int off = externalIdIndex >= 0 ? externalIdIndex : (ll.size() - externalIdIndex);
eidcol.add(new ExternalID(ll.get(off)));
lbuf.clear();
for(int j = 0; j < ll.size(); j++) {
if(j == off) {
continue;
}
lbuf.add(ll.get(j));
}
lblcol.add(LabelList.make(lbuf));
if(ll.size() > 0) {
keeplabelcol = true;
}
}
else {
eidcol.add(null);
lblcol.add(null);
}
}
bundle.appendColumn(TypeUtil.EXTERNALID, eidcol);
// Only add the label column when it's not empty.
if(keeplabelcol) {
bundle.appendColumn(meta, lblcol);
}
}
return bundle;
}
/**
* Parameterization class.
*
* @author Erich Schubert
*
* @apiviz.exclude
*/
public static class Parameterizer extends AbstractParameterizer {
/**
* Parameter that specifies the index of the label to be used as external
* Id, starting at 0. Negative numbers are counted from the end.
*
* Key: {@code -dbc.externalIdIndex}
*
*/
public static final OptionID EXTERNALID_INDEX_ID = new OptionID("dbc.externalIdIndex", "The index of the label to be used as external Id. The first label is 0; negative indexes are relative to the end.");
int externalIdIndex = -1;
@Override
protected void makeOptions(Parameterization config) {
super.makeOptions(config);
final IntParameter externalIdIndexParam = new IntParameter(EXTERNALID_INDEX_ID);
if(config.grab(externalIdIndexParam)) {
externalIdIndex = externalIdIndexParam.intValue();
}
}
@Override
protected ExternalIDFilter makeInstance() {
return new ExternalIDFilter(externalIdIndex);
}
}
}