On 11/22/2014 4:13 PM, Richard Eckart de Castilho wrote: > Hi Marshall, > > I have a unit test that fails on uimaj-core 2.7.0-SNAPSHOT but not on > uimaj-core 2.6.0. > Apparently, some features structures no longer appear multiple times in the > index > if they are added multiple times. Yes, this is changed with Jira https://issues.apache.org/jira/browse/UIMA-3399
>From the upcoming Release Notes: The meaning of "bag" and "sorted" index has been made consistent with how these are handled when sending CASes to remote services. This means that adding the same identical FS to the indexes, multiple times, will not add duplicate index entries. And, removing a FS from an index is guaranteed that that particular FS will no longer be in any index. (Before, if you had added a particular FS to a sorted or bag index, multiple times, the remove behavior would remove just one of the instances). Deserialization of CASes sent to remote services has never added Feature Structures to the index multiple times, so this change makes that behavior consistent. For more details, see https://issues.apache.org/jira/browse/UIMA-3399. Because some users may prefer the previous behavior that permitted duplicates of identical Feature Structures in the sorted and bag indexes. this change can be disabled, by running the JVM with the defined property "uima.allow_duplicate_add_to_indices".</p> Thanks for testing! -M > > I'm not sure if this was an intentional change or not, so I didn't open an > issue yet. > However, here is a minimalized and purified version of my test. With > 2.7.0-SNAPSHOT, > the second assert fails because count() returns 1. > > @Test > public void tooManyAnnotationsTest() > throws Exception > { > CAS cas = CasCreationUtils.createCas((TypeSystemDescription) null, > null, null); > AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); > assertEquals(1, count(cas, documentAnnotation.getType())); > > // Add a second time to the indexes > cas.addFsToIndexes(documentAnnotation); > assertEquals(2, count(cas, documentAnnotation.getType())); > } > > private int count(CAS aCas, Type aType) { > FSIterator<FeatureStructure> i = > aCas.getIndexRepository().getAllIndexedFS(aType); > int n = 0; > while (i.hasNext()) { > n++; > i.next(); > } > return n; > } > > Cheers, > > -- Richard > > >
