public void calculate(String queryString,String fieldString) {
        this.query=queryString.split(" ");
        this.field=fieldString.split(" ");

        thisRow=new Cell[query.length+1];
        previousRow=new Cell[query.length+1];
        previousPreviousRow=new Cell[query.length+1];

        for(int i=0; i<=query.length; i++) {
            thisRow[i]=new Cell(i+1,0,0,0);
            previousRow[i]=new Cell(i,0,0,0);
            previousPreviousRow[i]=new Cell(i-1,0,0,0);
        }

        print(previousRow);

        for(int j=1;j<=field.length; j++) {
            thisRow[0].setTo(0,j,0,0);
            for(int i=1; i<=query.length; i++) {
                setCell(i,j);
            }

            print(thisRow);

            // Shift round thisRow -> previousRow -> previousPreviousRow -> thisRow
            Cell[] temporaryRow=thisRow;
            thisRow=previousPreviousRow;
            previousPreviousRow=previousRow;
            previousRow=temporaryRow;
        }
        value=previousRow[query.length];
    }
The cell containg the last calculated edit distance
searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/reference/OptimalStringAlignmentDistance.java