IndexIteratorCachePair iicp;
IntPointerIterator it;
ArrayList<IndexIteratorCachePair> iv, cv;
// We may need to profile this. If this is a bottleneck, use a different
// implementation.
SortedIntSet set;
int jMax, indStrat;
// Iterate over indexes with something in there
for (int i = 0; i < this.usedIndexes.size(); i++) {
iv = this.indexArray[this.usedIndexes.get(i)];
// Iterate over the indexes for the type.
jMax = iv.size();
// Create a vector of IICPs. If there is at least one sorted or bag
// index, pick one arbitrarily and add its FSs (since it contains all
// FSs that all other indexes for the same type contain). If there are
// only set indexes, create a set of the FSs in those indexes, since they
// may all contain different elements (different FSs that have the same "key"
// are duplicates for one index, but may not be duplicates for a different one).
cv = new ArrayList<IndexIteratorCachePair>();
for (int j = 0; j < jMax; j++) {
iicp = iv.get(j);
indStrat = iicp.index.getIndexingStrategy();
if (indStrat == FSIndex.SET_INDEX) {
cv.add(iicp);
} else {
cv.clear(); // only need to save this one
cv.add(iicp);
break;
}
}
if (cv.size() > 0) {
// Note: This next loop removes duplicates (and also sorts
// the fs addrs associated with one type)
// Duplicates arise from having mulitple sets combined, and
// also if a non-set index had the same identical FS added
// multiple times.
set = new SortedIntSet();
for (int k = 0; k < cv.size(); k++) {
it = cv.get(k).index.refIterator();
while (it.isValid()) {
set.add(it.get());
it.inc();
}
}
v.add(set.getArray(), 0, set.size()); // bulk add of all elements
// for (int k = 0; k < set.size(); k++) {
// v.add(set.get(k));
// }
}
}