|
From: Micha N. <md...@us...> - 2004-08-24 12:47:53
|
Update of /cvsroot/tdbf/tdbf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21189 Modified Files: dbf_idxfile.pas history.txt Log Message: - fixed: index resync current record - fixed: resync range at eof Index: history.txt =================================================================== RCS file: /cvsroot/tdbf/tdbf/history.txt,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** history.txt 24 Aug 2004 08:56:38 -0000 1.69 --- history.txt 24 Aug 2004 12:47:35 -0000 1.70 *************** *** 61,64 **** --- 61,66 ---- **Version .2: - fixed: recursive loop in index first/last + - fixed: index resync current record + - fixed: resync range at eof Index: dbf_idxfile.pas =================================================================== RCS file: /cvsroot/tdbf/tdbf/dbf_idxfile.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dbf_idxfile.pas 24 Aug 2004 08:56:38 -0000 1.5 --- dbf_idxfile.pas 24 Aug 2004 12:47:35 -0000 1.6 *************** *** 3408,3412 **** SetBracketLow; // search upper bound ! SearchKey(FHighBuffer, stGreater); // if result true, then need to get previous item <=> // last of equal/lower than key --- 3408,3412 ---- SetBracketLow; // search upper bound ! Result := SearchKey(FHighBuffer, stGreater); // if result true, then need to get previous item <=> // last of equal/lower than key *************** *** 3433,3466 **** begin if not Relative then ResyncRoot; ! ResyncRange; ! if Relative then ResyncTree; end; end; procedure TIndexFile.ResyncTree; begin // if at BOF or EOF, then we need to resync by first or last if FLeaf.Entry = FEntryBof then begin ! WalkFirst; end else if FLeaf.Entry = FEntryEof then begin ! WalkLast; end else begin // read current key into buffer Move(FLeaf.Key^, FKeyBuffer, PIndexHdr(FIndexHeader).KeyLen); - // search current in-mem key on disk - FUserKey := FKeyBuffer; - FUserRecNo := FLeaf.PhysicalRecNo; // translate to searchable key if KeyType = 'C' then ! TranslateToANSI(FUserKey, FUserKey); ! if (FindKey(false) <> 0) then begin ! // houston, we've got a problem! ! // our `current' record has gone. we need to find it ! // find it by using physical recno ! PhysicalRecNo := FUserRecNo; end; end; --- 3433,3484 ---- begin if not Relative then + begin ResyncRoot; ! ResyncRange; ! end else begin ! // resyncing tree implies resyncing range ResyncTree; + end; end; end; procedure TIndexFile.ResyncTree; + var + action, recno: integer; begin // if at BOF or EOF, then we need to resync by first or last + // remember where the cursor was if FLeaf.Entry = FEntryBof then begin ! action := 0; end else if FLeaf.Entry = FEntryEof then begin ! action := 1; end else begin // read current key into buffer Move(FLeaf.Key^, FKeyBuffer, PIndexHdr(FIndexHeader).KeyLen); // translate to searchable key if KeyType = 'C' then ! TranslateToANSI(FKeyBuffer, FKeyBuffer); ! recno := FLeaf.PhysicalRecNo; ! action := 2; ! end; ! ! // we now know cursor position, resync possible range ! ResyncRange; ! ! // go to cursor position ! case action of ! 0: WalkFirst; ! 1: WalkLast; ! 2: begin ! // search current in-mem key on disk ! if (Find(recno, FKeyBuffer) <> 0) then ! begin ! // houston, we've got a problem! ! // our `current' record has gone. we need to find it ! // find it by using physical recno ! PhysicalRecNo := recno; ! end; end; end; |