A question mainly for Thilo. This is my idea for implementing the "default bag index" proposal - that is, when someone calls IndexRepository.addFS(fs) when there are no indexes defined over the type of the fs, a bag index will be created:
public void ll_addFS(int fsRef) { // Determine type of FS. final int typeCode = this.cas.getHeapValue(fsRef); // indicate this type's indexes are being modified // in case an iterator is simultaneously active over this type incrementIllegalIndexUpdateDetector(typeCode); // Get the indexes for the type. final ArrayList indexes = this.indexArray[typeCode]; // Add fsRef to all indexes. final int size = indexes.size(); for (int i = 0; i < size; i++) { ((IndexIteratorCachePair) indexes.get(i)).index.insert(fsRef); } if (size == 0) { //lazily create a default bag index for this type Type type = this.typeSystem.getType(typeCode); String defIndexName = "_" + type.getName() + "_GeneratedIndex"; FSIndexComparator comparator = createComparator(); comparator.setType(type); createIndexNoQuestionsAsked(comparator, defIndexName, FSIndex.BAG_INDEX); assert this.indexArray[typeCode].size() == 1; //add the FS to the bag index ((IndexIteratorCachePair)this.indexArray[typeCode].get(0)).index.insert(fsRef); } } So far this seems to be working. One potential issue is that this would add new indexes after the IndexRepository has been "committed". However, the IndexRepository.commit() method currently only does this: public void commit() { // Will create the default type order if it doesn't exist at this point. getDefaultTypeOrder(); this.locked = true; } So it doesn't seem like there is anything being done on commit that would break if I add new indexes later. What do you think? -Adam