|
From: Micha N. <md...@us...> - 2004-08-28 12:42:23
|
Update of /cvsroot/tdbf/tdbf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29336 Modified Files: dbf_idxfile.pas history.txt Log Message: fixed: index findkey finds last, deleted key in index page Index: history.txt =================================================================== RCS file: /cvsroot/tdbf/tdbf/history.txt,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** history.txt 24 Aug 2004 12:47:35 -0000 1.70 --- history.txt 28 Aug 2004 12:42:13 -0000 1.71 *************** *** 63,66 **** --- 63,67 ---- - fixed: index resync current record - fixed: resync range at eof + - fixed: index findkey finds last, deleted key in index page Index: dbf_idxfile.pas =================================================================== RCS file: /cvsroot/tdbf/tdbf/dbf_idxfile.pas,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dbf_idxfile.pas 24 Aug 2004 12:47:35 -0000 1.6 --- dbf_idxfile.pas 28 Aug 2004 12:42:13 -0000 1.7 *************** *** 871,929 **** // ARecNo <> -3 -> Entry(high).Key will contain first key that matches -> go to high // ARecNo = -3 -> Entry(high).Key will contain first key that is greater -> go to high ! recNo := high; ! if FEntryNo <> recNo then ! begin ! FEntryNo := recNo; ! FEntry := GetEntry(recNo); ! end; // calc end result: can't inspect high if lowerpage <> nil // if this is a leaf, we need to find specific recno if (LowerPage = nil) then begin ! // FLowerPage = nil -> can inspect high ! Result := MatchKey; ! // test if we need to find a specific recno ! // result < 0 -> current key greater -> nothing found -> don't search ! if (ARecNo > 0) then begin ! // BLS to RecNo ! high := FHighIndex + 1; ! low := FEntryNo; ! // inv: FLowIndex <= FEntryNo <= high <= FHighIndex + 1 /\ ! // (Ai: FLowIndex <= i < FEntryNo: Entry(i).RecNo <> ARecNo) ! while FEntryNo <> high do begin ! // FEntryNo < high, get new entry ! if low <> FEntryNo then begin ! FEntry := GetEntry(FEntryNo); ! // check if entry key still ok ! Result := MatchKey; ! end; ! // get recno of current item ! recNo := GetRecNo; ! // test if out of range or found ! if (Result <> 0) or (recNo = ARecNo) then ! high := FEntryNo ! else begin ! // default to EOF ! inc(FEntryNo); ! Result := 1; end; end; - // if not found, get EOF entry - if (Result <> 0) then - begin - // Entry(FEntryNo) <> Entry - // bypass SetEntryNo check - FEntryNo := -1; - EntryNo := high; - end; end; end else begin // FLowerPage <> nil -> high contains entry, can not have empty range Result := 0; - // sync lower page - SyncLowerPage; end; end; --- 871,918 ---- // ARecNo <> -3 -> Entry(high).Key will contain first key that matches -> go to high // ARecNo = -3 -> Entry(high).Key will contain first key that is greater -> go to high ! EntryNo := high; // calc end result: can't inspect high if lowerpage <> nil // if this is a leaf, we need to find specific recno if (LowerPage = nil) then begin ! if high > FHighIndex then begin ! Result := 1; ! end else begin ! Result := MatchKey; ! // test if we need to find a specific recno ! // result < 0 -> current key greater -> nothing found -> don't search ! if (ARecNo > 0) then begin ! // BLS to RecNo ! high := FHighIndex + 1; ! low := FEntryNo; ! // inv: FLowIndex <= FEntryNo <= high <= FHighIndex + 1 /\ ! // (Ai: FLowIndex <= i < FEntryNo: Entry(i).RecNo <> ARecNo) ! while FEntryNo <> high do begin ! // FEntryNo < high, get new entry ! if low <> FEntryNo then ! begin ! FEntry := GetEntry(FEntryNo); ! // check if entry key still ok ! Result := MatchKey; ! end; ! // get recno of current item ! recNo := GetRecNo; ! // test if out of range or found ! if (Result <> 0) or (recNo = ARecNo) then ! high := FEntryNo ! else begin ! // default to EOF ! inc(FEntryNo); ! Result := 1; ! end; end; end; end; end else begin // FLowerPage <> nil -> high contains entry, can not have empty range Result := 0; end; end; |