anchors.add(a.getBegin());
anchors.add(a.getEnd());
}
if (anchors.size() == 1) {
Integer first = anchors.pollFirst();
RutaBasic newTMB = new RutaBasic(getJCas(), first, first);
newTMB.setLowMemoryProfile(lowMemoryProfile);
beginAnchors.put(first, newTMB);
endAnchors.put(first, newTMB);
cas.addFsToIndexes(newTMB);
} else {
while (true) {
Integer first = anchors.pollFirst();
if (first == null || anchors.isEmpty()) {
break;
}
Integer second = anchors.first();
RutaBasic newTMB = new RutaBasic(getJCas(), first, second);
newTMB.setLowMemoryProfile(lowMemoryProfile);
beginAnchors.put(first, newTMB);
endAnchors.put(second, newTMB);
cas.addFsToIndexes(newTMB);
}
}
for (AnnotationFS a : allAnnotations) {
addAnnotation(a, false, false, null);
}
updateIterators(documentAnnotation);
} else {
for (AnnotationFS e : basicIndex) {
beginAnchors.put(e.getBegin(), (RutaBasic) e);
endAnchors.put(e.getEnd(), (RutaBasic) e);
}
RutaBasic firstBasic = (RutaBasic) basicIndex.iterator().get();
if (firstBasic.isLowMemoryProfile() != lowMemoryProfile) {
for (AnnotationFS each : basicIndex) {
RutaBasic eachBasic = (RutaBasic) each;
eachBasic.setLowMemoryProfile(lowMemoryProfile);
}
}
// TODO: find a better solution for this:
for (AnnotationFS a : allAnnotations) {
Type type = a.getType();
if (!type.equals(basicType)) {
RutaBasic beginAnchor = getBeginAnchor(a.getBegin());
RutaBasic endAnchor = getEndAnchor(a.getEnd());
boolean shouldBeAdded = false;
if (beginAnchor == null || endAnchor == null) {
shouldBeAdded = true;
} else {
Collection<AnnotationFS> set = beginAnchor.getBeginAnchors(type);