Fixed this bug and one related to termenum with no term. These made SegmentMerger fail.
Can you please supply a test case that demonstrate SegmentMerger failing? Your next() in InstantiatedTermEnum() changes the behaviour InstantiatedIndexReader#terms() compared to IndexReader#terms() and makes the index comparation test to to fail:
junit.framework.AssertionFailedError: expected:<a:0> but was:<a:1>
InstantiatedIndex#fieldSettingsByFieldName that getFieldNames(FieldOption) seem to only be updated by InstantiatedIndexWriter and not when populated by InstantiatedIndex(IndexReader).
Can you please supply test cases that demonstrate getFieldNames(FieldOption) works with both index population strategies?
I think you can factor out the FieldSetting class from InstantiatedIndexWriter as it now is used by InstantiatedIndex and InstantiatedIndexReader too.
A few additional updates related to deleted docs in InstantiatedIndexReader
This looks good. I noticed that TestIndicesEquals does not actually delete any documents and make sure the indices still equals. I can fix that.
Also, please try not to reformat the code, it makes it harder to see the important changes.