core/src/main/java/com/orientechnologies/orient/core/iterator/OIdentifiableIterator.java
protected ORecord readCurrentRecord(ORecord iRecord, final int iMovement) {
    if (limit > -1 && browsedRecords >= limit)
      // LIMIT REACHED
      return null;

    do {
      final boolean moveResult;
      switch (iMovement) {
      case 1:
        moveResult = nextPosition();
        break;
      case -1:
        moveResult = prevPosition();
        break;
      case 0:
        moveResult = checkCurrentPosition();
        break;
      default:
        throw new IllegalStateException("Invalid movement value : " + iMovement);
      }

      if (!moveResult)
        return null;

      try {
        if (iRecord != null) {
          ORecordInternal.setIdentity(iRecord, new ORecordId(current.getClusterId(), current.getClusterPosition()));
          iRecord = database.load(iRecord, fetchPlan, false);
        } else
          iRecord = database.load(current, fetchPlan, false);
      } catch (ODatabaseException e) {
        if (Thread.interrupted() || database.isClosed())
          // THREAD INTERRUPTED: RETURN
          throw e;

        if (e.getCause() instanceof OSecurityException)
          throw e;

        brokenRIDs.add(current.copy());

        OLogManager.instance().error(this, "Error on fetching record during browsing. The record has been skipped", e);
      }

      if (iRecord != null) {
        browsedRecords++;
        return iRecord;
      }
    } while (iMovement != 0);

    return null;
  }
protected ORecord readCurrentRecord(ORecord iRecord, final int iMovement) {
    if (limit > -1 && browsedRecords >= limit)
      // LIMIT REACHED
      return null;

    do {
      final boolean moveResult;
      switch (iMovement) {
      case 1:
        moveResult = nextPosition();
        break;
      case -1:
        moveResult = prevPosition();
        break;
      case 0:
        moveResult = checkCurrentPosition();
        break;
      default:
        throw new IllegalStateException("Invalid movement value : " + iMovement);
      }

      if (!moveResult)
        return null;

      try {
        if (iRecord != null) {
          ORecordInternal.setIdentity(iRecord, new ORecordId(current.getClusterId(), current.getClusterPosition()));
          iRecord = database.load(iRecord, fetchPlan, false);
        } else
          iRecord = database.load(current, fetchPlan, false);
      } catch (ODatabaseException e) {
        if (Thread.interrupted() || database.isClosed())
          // THREAD INTERRUPTED: RETURN
          throw e;

        if (e.getCause() instanceof OSecurityException)
          throw e;

        brokenRIDs.add(current.copy());

        OLogManager.instance().error(this, "Error on fetching record during browsing. The record has been skipped", e);
      }

      if (iRecord != null) {
        browsedRecords++;
        return iRecord;
      }
    } while (iMovement != 0);

    return null;
  }
protected ORecord readCurrentRecord ( ORecord iRecord , final int iMovement ) { if ( limit > - 1 && browsedRecords >= limit ) // LIMIT REACHED
 return null ; do { final boolean moveResult ; switch ( iMovement ) { case 1 : moveResult = nextPosition ( ) ; break ; case - 1 : moveResult = prevPosition ( ) ; break ; case 0 : moveResult = checkCurrentPosition ( ) ; break ; default : throw new IllegalStateException ( "Invalid movement value : " + iMovement ) ; } if ( ! moveResult ) return null ; try { if ( iRecord != null ) { ORecordInternal . setIdentity ( iRecord , new ORecordId ( current . getClusterId ( ) , current . getClusterPosition ( ) ) ) ; iRecord = database . load ( iRecord , fetchPlan , false ) ; } else iRecord = database . load ( current , fetchPlan , false ) ; } catch ( ODatabaseException e ) { if ( Thread . interrupted ( ) || database . isClosed ( ) ) // THREAD INTERRUPTED: RETURN
 throw e ; if ( e . getCause ( ) instanceof OSecurityException ) throw e ; brokenRIDs . add ( current . copy ( ) ) ; OLogManager . instance ( ) . error ( this , "Error on fetching record during browsing. The record has been skipped" , e ) ; } if ( iRecord != null ) { browsedRecords ++ ; return iRecord ; } } while ( iMovement != 0 ) ; return null ; }
Read the current record and increment the counter if the record was found.

@param iRecord to read value from database inside it. If record is null link will be created and stored in it.

@return record which was read from db.
Read the current record and increment the counter if the record was found .