I ran this in debug mode and found: 1) the testcase creates a type "TestType" with a supertype CAS.TYPE_NAME_ANNOTATION_BASE.
The supertype has no "build-in" defined index (unlike if the supertype was CAS.TYPE_NAME_ANNOTATION). So, adding it to indexes adds this to a "bag" index. 2) The getAllIndexedFS just reads out the bag index (which is implemented via a hash map in v3), so you get the FSs in random order. 3) changing the supertype to CAS.TYPE_NAME_ANNOTATION makes the test succeed. 4) in v2, the default bag index (which is the impl style that gets used for this) is implemented as either a bit-set kind of thing, or as a IntVector of ints (representing the FSs). So the ordering will definitely be different in v3 vs v2. I think the v3 impl as a simple HashSet should not be changed, for performance reasons, so this difference is to be expected. Thanks for hunting it down! If you want a test case for v3 that works, just change the supertype to CAS.TYPE_NAME_ANNOTATION. -Marshall On 11/25/2018 4:05 PM, Richard Eckart de Castilho wrote: > On 19. Nov 2018, at 21:31, Marshall Schor <[email protected]> wrote: >> Can you say where the feature structure order changed in comparison to v2? >> I'm >> trying to keep things as much as reasonably possible the same, except if >> there >> is some kind of performance implication, etc. > The following code seems to work consistently for UIMA v2, but fails sooner or > later for UIMA v3. > > ---- > > @Test > public void thatIterationOrderOfAnnotationBaseFSesIsCorrect() throws > Exception > { > for (int e = 0; e < 1000; e++) { > TypeSystemDescription tsd = new TypeSystemDescription_impl(); > TypeDescription td = tsd.addType("TestType", "", > CAS.TYPE_NAME_ANNOTATION_BASE); > td.addFeature("value", "", CAS.TYPE_NAME_INTEGER); > > CAS cas = CasCreationUtils.createCas(tsd, null, null); > Type type = cas.getTypeSystem().getType("TestType"); > Feature feat = type.getFeatureByBaseName("value"); > > for (int i = 0; i < 1000; i ++) { > FeatureStructure fs = cas.createFS(type); > fs.setIntValue(feat, i); > cas.addFsToIndexes(fs); > } > > int next = 0; > FSIterator<FeatureStructure> i = > cas.getIndexRepository().getAllIndexedFS(type); > while (i.hasNext()) { > FeatureStructure fs = i.next(); > assertEquals(next, fs.getIntValue(feat)); > next ++; > } > } > } > > ---- > > Cheers, > > -- Richard
