@Specialization(contains="doIntegerSequencePosition") protected int doIntegerPosition(RAbstractVector left,Object leftStore,int leftBase,int leftLength,Object targetDimensions,@SuppressWarnings("unused") int targetDimension,Object[] positions,RAbstractIntVector position,int positionOffset,int positionLength,RTypedValue right,Object rightStore,int rightBase,int rightLength,boolean parentNA,@Cached("createCountingProfile()") LoopConditionProfile lengthProfile){
  positionNACheck.enable(position);
  int rightIndex=rightBase;
  initRightIndexCheck(rightBase,positionLength,leftLength,rightLength);
  lengthProfile.profileCounted(positionLength);
  for (int i=0; lengthProfile.inject(i < positionLength); i++) {
    int positionValue=position.getDataAt(i);
    boolean isNA=positionNACheck.check(positionValue);
    if (isNA) {
      if (skipNA) {
        continue;
      }
    }
    rightIndex=applyInner(left,leftStore,leftBase,leftLength,targetDimensions,positions,positionOffset,positionValue - 1,right,rightStore,rightLength,rightIndex,isNA || parentNA);
  }
  return rightIndex;
}

@ Specialization ( contains = "doIntegerSequencePosition" ) protected int doIntegerPosition ( RAbstractVector left , Object leftStore , int leftBase , int leftLength , Object targetDimensions , @ SuppressWarnings ( "unused" ) int targetDimension , Object [ ] positions , RAbstractIntVector position , int positionOffset , int positionLength , RTypedValue right , Object rightStore , int rightBase , int rightLength , boolean parentNA , @ Cached ( "createCountingProfile()" ) LoopConditionProfile lengthProfile ) { positionNACheck . enable ( position ) ; int rightIndex = rightBase ; initRightIndexCheck ( rightBase , positionLength , leftLength , rightLength ) ; lengthProfile . profileCounted ( positionLength ) ; for ( int i = 0 ; lengthProfile . inject ( i < positionLength ) ; i ++ ) { int positionValue = position . getDataAt ( i ) ; boolean isNA = positionNACheck . check ( positionValue ) ; if ( isNA ) { if ( skipNA ) { continue ; } } rightIndex = applyInner ( left , leftStore , leftBase , leftLength , targetDimensions , positions , positionOffset , positionValue - 1 , right , rightStore , rightLength , rightIndex , isNA || parentNA ) ; } return rightIndex ; }
integer vectors iterate over the number of positions because we assume that the number of positions in an integer vector is significantly lower than the number of elements in the store . this might not be always true and could benefit from more investigation .
