On Fri, 26 Feb 2010, smu johnson wrote:

Hi,

> With a Roll-your-own index open, when you use a dbgoto(), the record pointer
> is moved to the correct row in the table but the pointer in the index file
> is not positioned to the corresponding row, even though the record is in the
> index.  With a regular cdx index, the index pointer is always positioned
> after a dbgoto().

No. It's positioned in the same way in both cases using sth like:
   SEEK EVAL( <KEYEXP> ) + <RECNO>
It means that it will not work when you used in RYO index your own
values which are not results of <KEYEXP> evaluation because corresponding
entry cannot be found.

> Perhaps the reason for not positioning the index pointer in an ryo index is
> that an ryo index can contain multiple entries for a single table row, and
> as such, positioning the index pointer would be ambiguous action (pick one?)
> and could therefore cause unpredictable results.  Am I correct in that
> thinking?

No, see above. After DBGOTO() RDD uses seek to find corresponding record
to eliminate linear scan of all key stored in index from the index top
position to locate the entry which has corresponding record number.
Such linear scan is simply very expensive in big tables because it may
force reading whole index file to locate given entry.

> In any event, the Harbour behaviour is different from the SIX SDX, which is
> causing me problems.
> 
> I have included a URL for a tiny .ZIP file for a simple source code example,
> and 2 .txt files showing different behaviour on Clipper 5.2e / Harbour.
> Please read here:  http://209.97.219.2/sjohnson/misc/sixcdx-incompat.zip

Looks that SIX3 for template indexes enables such linear scan automatically.
Harbour doesn't. You can force linear scan for index repositioning manually
by:

   sx_findRec( recNo() )

just after dbGoTo().
I'll enable automatic linear repositioning for template SIXCDX tags ASAP.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to