xHarbour Reference Documentation > Function Reference |
Verifies a HS_Next() match against the index key.
HS_Verify( <xIndexKey>, <cSearch> ) --> lMatched
The function returns .T. (true) when <cSearch> is contained anywhere in the result of the code block, or index value, otherwise .F. (false) is returned.
HS_Verify() is used to make sure that the value found in a HiPer-SEEK index file actually matches the data in the corresponding database file. The HiPer-SEEK algorithm calculates fixed size hash keys from text strings. This makes it possible that two different text strings result in the same hash key so that a search may result in false positives. HS_Verify() prevents from finding false positives by comparing the search string against the data stored in the database.
See also: | HS_Next() |
Category: | Database functions , HiPer-SEEK functions , Index functions , xHarbour extensions |
Source: | rdd\hsx\hsx.c |
LIB: | lib\xhb.lib |
DLL: | dll\xhbdll.dll |
// The example demonstrates how HiPer-SEEK search operations // are verified against a database. PROCEDURE Main LOCAL cIndex, bIndex, nHandle LOCAL nRecno, cSearch := "ller" CLS USE Customer ALIAS Cust cIndex := 'Trim(Cust->LastName) +' cIndex += '" "' cIndex += '+ Trim(Cust->FirstName)' bIndex := &( "{||" + cIndex + "}" ) nHandle := HS_Index( "Customer.hsx", cIndex, 3, 0, 16 ) IF nHandle < 0 ? "HiPer-SEEK index creation failed with error:", nHandle QUIT ENDIF // define search string and find first index entry HS_Set( nHandle, cSearch ) nRecno := HS_Next( nHandle ) DO WHILE nRecno > 0 DbGoto( nRecno ) IF HS_Verify( bIndex, cSearch ) ? "Matched :", Eval( bIndex ) ELSE ? "No match:", Eval( bIndex ) ENDIF // find next index entry nRecno := HS_Next( nHandle ) ENDDO HS_Close( nHandle ) USE RETURN
http://www.xHarbour.com