[
https://issues.apache.org/jira/browse/UIMA-6296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17229518#comment-17229518
]
Richard Eckart de Castilho commented on UIMA-6296:
--------------------------------------------------
What according to the old test check that I commented out should happen is that
instead of
returning all annotations following the startFS is that the first annotation of
the
selection type that occurs *before* the startFS is also included in the result.
{code}
Sentence s2 = new Sentence(jCas, 4, 5);
Token[] t = addToIndexes(
new Token(jCas, 0, 1),
new Token(jCas, 2, 3),
new Token(jCas, 4, 5),
new Token(jCas, 6, 7),
new Token(jCas, 8, 9));
assertThat(jCas.select(Token.class).following(s2).shifted(-1).asList())
.containsExactly(t[2], t[3], t[4]);
{code}
This might look useful e.g. to select left/right windows of the startFS, but it
is a
nightmare implementation-wise because the selection boundaries are no longer
determined by
the bounds of the startFS. It starts becoming sensitive to the index order.
For an index-order-sensitive window-like selection, using startAt with shift
and limit is
the appropriate approach:
{code}
jCas.select(Token.class).startAt(s2).shifted(-1).limit(3)
{code}
What does happen now is that the negative shift makes the underlying iterator
invalid
because it causes it to move outside its boundary (i.e. into the startFS).
Also, a warning is logged
that using a negative shift with preceeding/following is likely a mistake and
start startAt should
be used instead.
> 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
>
>
> 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)