private PendingChange prepareAddEntry(Entry newEntry,boolean isNullEntry,Object[] row,AddRowPendingChange change) throws IOException {
  DataPage dataPage=findDataPage(newEntry);
  int idx=dataPage.findEntry(newEntry);
  if (idx < 0) {
    idx=missingIndexToInsertionPoint(idx);
    Position newPos=new Position(dataPage,idx,newEntry,true);
    Position nextPos=getNextPosition(newPos);
    Position prevPos=getPreviousPosition(newPos);
    boolean isDupeEntry=(((nextPos != null) && newEntry.equalsEntryBytes(nextPos.getEntry())) || ((prevPos != null) && newEntry.equalsEntryBytes(prevPos.getEntry())));
    if (isUnique() && !isNullEntry && isDupeEntry) {
      throw new ConstraintViolationException(withErrorContext("New row " + Arrays.asList(row) + " violates uniqueness constraint for index"));
    }
    change.setAddRow(newEntry,dataPage,idx,isDupeEntry);
  }
 else {
    change.setOldRow(newEntry);
  }
  return change;
}

private PendingChange prepareAddEntry ( Entry newEntry , boolean isNullEntry , Object [ ] row , AddRowPendingChange change ) throws IOException { DataPage dataPage = findDataPage ( newEntry ) ; int idx = dataPage . findEntry ( newEntry ) ; if ( idx < 0 ) { idx = missingIndexToInsertionPoint ( idx ) ; Position newPos = new Position ( dataPage , idx , newEntry , true ) ; Position nextPos = getNextPosition ( newPos ) ; Position prevPos = getPreviousPosition ( newPos ) ; boolean isDupeEntry = ( ( ( nextPos != null ) && newEntry . equalsEntryBytes ( nextPos . getEntry ( ) ) ) || ( ( prevPos != null ) && newEntry . equalsEntryBytes ( prevPos . getEntry ( ) ) ) ) ; if ( isUnique ( ) && ! isNullEntry && isDupeEntry ) { throw new ConstraintViolationException ( withErrorContext ( "New row " + Arrays . asList ( row ) + " violates uniqueness constraint for index" ) ) ; } change . setAddRow ( newEntry , dataPage , idx , isDupeEntry ) ; } else { change . setOldRow ( newEntry ) ; } return change ; }
adds an entry to the correct index datapage , maintaining the order .
