[
https://issues.apache.org/jira/browse/UIMA-6296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17233323#comment-17233323
]
Richard Eckart de Castilho commented on UIMA-6296:
--------------------------------------------------
There is a strange cases an FSIterator moveTo operation which should actually
be a NOP causes the internal state of the iterator to change which in turn may
cause items to be skipped.
{code}
@Test
public void thatSelectCoveredByIteratorWorks() throws Exception {
TypeSystemDescription tsd =
getResourceSpecifierFactory().createTypeSystemDescription();
tsd.addType("test.Type1", "", CAS.TYPE_NAME_ANNOTATION);
tsd.addType("test.Type2", "", "test.Type1");
tsd.addType("test.Type3", "", "test.Type2");
CAS cas = CasCreationUtils.createCas(tsd, null, null, null);
Type type1 = cas.getTypeSystem().getType("test.Type1");
Type type2 = cas.getTypeSystem().getType("test.Type2");
Type type3 = cas.getTypeSystem().getType("test.Type3");
AnnotationFS[] expected = new AnnotationFS[2];
Annotation y = (Annotation) cas.createAnnotation(type3, 42, 59);
addToIndexes(
expected[0] = cas.createAnnotation(type3, 42, 59),
cas.createAnnotation(type1, 37, 61),
cas.createAnnotation(type2, 33, 62),
cas.createAnnotation(type3, 83, 88),
cas.createAnnotation(type1, 95, 106),
cas.createAnnotation(type2, 23, 29),
cas.createAnnotation(type3, 25, 35),
cas.createAnnotation(type1, 95, 115),
cas.createAnnotation(type2, 31, 52),
cas.createAnnotation(type3, 65, 93),
cas.createAnnotation(type1, 58, 77),
cas.createAnnotation(type2, 26, 50),
cas.createAnnotation(type3, 77, 92),
cas.createAnnotation(type1, 69, 77),
expected[1] = cas.createAnnotation(type2, 42, 59));
assertThat(cas.<Annotation>select(type2).coveredBy(y).asList())
.containsExactly((Annotation) expected[0], (Annotation) expected[1]);
FSIterator<Annotation> it =
cas.<Annotation>select(type2).coveredBy(y).fsIterator();
assertThat(it.get())
.as("Initial iterator position")
.isSameAs(expected[0]);
// THIS MOVE_TO OPERATION SHOULD HAVE NO EFFECT BECAUSE THE
// ITERATOR ALREADY POINTS TO expected[0] AS VERIFIED BY THE ASSERT ABOVE
it.moveTo(expected[0]); // <=====
assertThat(it.get()).isSameAs(expected[0]);
// When the moveTo above is there, the following fails. If it is not there,
it works!
it.moveToNext();
assertThat(it.isValid()).isTrue();
assertThat(it.get()).isSameAs(expected[1]);
}
{code}
||Before move||After move||
| !Screenshot 2020-11-17 at 08.06.03.png|width=98%! | !Screenshot 2020-11-17
at 08.05.09.png|width=98%! |
> SelectFS fsIterator may yield different result set than asList
> --------------------------------------------------------------
>
> Key: UIMA-6296
> URL: https://issues.apache.org/jira/browse/UIMA-6296
> Project: UIMA
> Issue Type: Bug
> Components: Core Java Framework
> Reporter: Richard Eckart de Castilho
> Assignee: Richard Eckart de Castilho
> Priority: Major
> Fix For: 3.2.0SDK
>
> Attachments: Screenshot 2020-11-17 at 08.05.09.png, Screenshot
> 2020-11-17 at 08.06.03.png
>
>
> SelectFS fsIterator may yield different result set than asList when
> collecting results through forward or backward iteration through the
> iterator. The randomized tests should be extended to check that fsIterator
> behavior is aligned with asList behavior and with the general annotation
> predicate matrix.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)