public FSIndexRepositoryImpl getIndexRepository(CASImpl cas) {
final FSIndexRepositoryImpl ir = new FSIndexRepositoryImpl(cas);
// Get the type order.
ir.setDefaultTypeOrder(LinearTypeOrderBuilderImpl.createTypeOrder(this.typeOrder, cas
.getTypeSystem()));
FSIndexComparator comp;
final int max = this.indexNames.length;
int pos = 0, next, maxComp;
Type type;
Feature feat;
if (this.nameToIndexMap == null) {
this.nameToIndexMap = new int[max];
for (int i = 0; i < max; i++) {
this.nameToIndexMap[i] = i;
}
}
for (int i = 0; i < max; i++) {
comp = ir.createComparator();
// assert(pos == comparatorIndex[i]);
pos = this.comparatorIndex[this.nameToIndexMap[i]];
type = cas.getTypeSystemImpl().ll_getTypeForCode(this.comparators[pos]);
comp.setType(type);
++pos;
next = this.nameToIndexMap[i] + 1;
if (next < max) {
maxComp = this.comparatorIndex[next];
} else {
maxComp = this.comparators.length;
}
TypeSystemImpl tsi = (TypeSystemImpl) cas.getTypeSystem();
while (pos < maxComp) {
// System.out.println("Type system: " +
// cas.getTypeSystem().toString());
if (this.comparators[pos] > 0) {
feat = tsi.ll_getFeatureForCode(this.comparators[pos]);
// assert(feat != null);
// System.out.println("Adding feature: " + feat.getName());
++pos;
comp.addKey(feat, this.comparators[pos]);
// assert(rc >= 0);
} else {
LinearTypeOrder order = ir.getDefaultTypeOrder();
++pos;
comp.addKey(order, this.comparators[pos]);
}
++pos;
}
ir.createIndex(comp, this.indexNames[i], this.indexingStrategy[this.nameToIndexMap[i]]);
}