Powerbasic Museum 2020-B

IT-Consultant: Patrice Terrier => Addon tools for PB => Topic started by: Patrice Terrier on August 03, 2007, 04:48:19 PM

Title: dvBTree (free index manager)
Post by: Patrice Terrier on August 03, 2007, 04:48:19 PM
The dvBTree implementation uses a pure balanced B-Tree algorithm to provide you with a fast and flexible way to index more than two billion records with no limitations on the type of data file.

You can use B-Tree routines to find a given record very quickly even if you are using large data files.

These routines will work with either new or existing sequential or random access data files with no predefinition of structure.

You can index on any string expression and not just fields in the data file. There is not limit to the number of indices you can use.

Usually a B-Tree index does not accept duplicated keys. However dvBTree lets you use such keys transparently making them unique by adding their record number to the key without enlarging the index size.


No more need to sort:
One very useful side effect of using a B-Tree index is that all keys in the index are always sorted alphabetically. To read your key in ascending order, read the index from the first key to the last. Want a descending order ? Just read it from the last to the first.


Specifications:

For the members of this community dvBTree is free. There are no royalties nor fees for distribution with your application  :)

Note: For the purpose of speed and optimization dvBTree uses only low level file I/O API.
Title: Re: [SDK] dvBTree index manager
Post by: Kent Sarikaya on August 03, 2007, 10:04:20 PM
Thanks Patrice, downloaded for future study.
Title: Re: [SDK] dvBTree index manager
Post by: Petr Schreiber on August 03, 2007, 10:10:22 PM
Patrice,

what a nice gift !
I have checked your website and you normally sell it for $135...

Another great contribution to PB community ...


Thanks!,
Petr

Title: Re: [SDK] dvBTree (free index manager)
Post by: Patrice Terrier on August 10, 2011, 03:05:09 PM
The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...
Title: Multiple versions of 2.06 purchased 2.04. manual says 2.0 and another 2.04
Post by: Mike Doty on December 19, 2011, 06:36:16 PM
I thought my version 2.04 was current and found 2 more versions of 2.06.
Notice the difference in dvBtAfter&.  My older version is the second one.


FUNCTION dvBtAfter& ALIAS "dvBtAfter" (BYVAL hBtFile&, zRKey AS ASCIIZ, Record&, BtErr&) EXPORT AS LONG
    KeyIn$ = zRKey
    FUNCTION = Bt&(hBtFile&, 66&, zRKey, Record&, BtErr&)
    IF LEN(zRKey) AND zRKey < KeyIn$ THEN
       FUNCTION = dvBtNext(hBtFile&, zRKey, Record&, BtErr&)
    ELSE
       FUNCTION = Bt&(hBtFile&, 69&, zRKey, Record&, BtErr&)
    END IF
END FUNCTION     


FUNCTION dvBtAfter& ALIAS "dvBtAfter" (BYVAL hBtFile&, zRKey AS ASCIIZ, Record&, BtErr&) EXPORT
'
  LOCAL KeyIn       AS STRING
  LOCAL FirstRecord AS LONG
  LOCAL BtErrFirst  AS LONG
  LOCAL FirstKey    AS STRING
    KeyIn$ = zRKey
'
    ' 06-26-2002 Jean-Pierre LEROY
    IF Bt&(hBtFile&, 70, zRKey, FirstRecord&, BtErrFirst&) = 0 THEN FirstKey$ = zRKey
    zRKey = KeyIn$

    FUNCTION = Bt&(hBtFile&, 66&, zRKey, Record&, BtErr&)
    IF LEN(zRKey) AND zRKey < KeyIn$ THEN
       FUNCTION = dvBtNext(hBtFile&, zRKey, Record&, BtErr&)
    ELSE
       IF LEN(FirstKey$) AND KeyIn$ < FirstKey$ THEN ' 06-26-2002 Jean-Pierre LEROY
           Record& = FirstRecord&
           zRKey = FirstKey$
           BtErr& = BtErrFirst&
           EXIT FUNCTION
       END IF
       FUNCTION = Bt&(hBtFile&, 69&, zRKey, Record&, BtErr&)
    END IF
END FUNCTION


One readme has Version 2.06 from 06-22-2002 
Another has     Version 2.06 from 05-11-2002 

Noticed the download was modified in August of 2011.
Which one is current?






Title: Re: dvBTree (free index manager)
Post by: Haim Jamer on December 24, 2011, 12:34:07 PM
Hello,
In the dvbtree.doc it is stated that dvbtsearch is able to find partial keys. How is such a search to be implemented. In all my tests I succeeded to find only when the search string contained the full key.
(in the xbtree sample the searches are made on full keys.
Thanks for any explanation on this.
HJ
Title: Re: dvBTree (free index manager)
Post by: Patrice Terrier on December 24, 2011, 01:33:32 PM
Please look inside the code of the main Bt() function, things should be obvious.

Look also for dvBtnext.

The ZIP file has been updated in august 2011, after the server colapse problem.
But the provided files haven't changed for more than 10 years now, and dvBtree was provided with dv32 in 1996/1997, when the first PB version for Windows was released.

...
Title: Re: dvBTree (free index manager)
Post by: Haim Jamer on December 24, 2011, 04:16:45 PM
Thanks for your prompt response.
I'll keep studying this.
HJ
Title: Re: dvBTree (free index manager)
Post by: Mike Doty on December 24, 2011, 04:26:37 PM
Patrice,

The version of dvbtree.bas just downloaded shows 5-11-2002
My version shows 6-22-02 with different code dated 06-26-2002 Jean-Pierre LEROY

Should I use the older version posted on this BBS without the Jean_Pierrre LEROY modification?
I can not find dvBText in any version?


'Lastest download  Version 2.06 from 05-11-2002
FUNCTION dvBtAfter& ALIAS "dvBtAfter" (BYVAL hBtFile&, zRKey AS ASCIIZ, Record&, BtErr&) EXPORT AS LONG
    KeyIn$ = zRKey
    FUNCTION = Bt&(hBtFile&, 66&, zRKey, Record&, BtErr&)
    IF LEN(zRKey) AND zRKey < KeyIn$ THEN
       FUNCTION = dvBtNext(hBtFile&, zRKey, Record&, BtErr&)
    ELSE
       FUNCTION = Bt&(hBtFile&, 69&, zRKey, Record&, BtErr&)
    END IF
END FUNCTION


This code may or may not be more current?

' Version 2.06 from 06-22-2002   

FUNCTION dvBtAfter& ALIAS "dvBtAfter" (BYVAL hBtFile&, zRKey AS ASCIIZ, Record&, BtErr&) EXPORT
'
    KeyIn$ = zRKey
'
    ' 06-26-2002 Jean-Pierre LEROY
    IF Bt&(hBtFile&, 70, zRKey, FirstRecord&, BtErrFirst&) = 0 THEN FirstKey$ = zRKey
    zRKey = KeyIn$

    FUNCTION = Bt&(hBtFile&, 66&, zRKey, Record&, BtErr&)
    IF LEN(zRKey) AND zRKey < KeyIn$ THEN
       FUNCTION = dvBtNext(hBtFile&, zRKey, Record&, BtErr&)
    ELSE
       IF LEN(FirstKey$) AND KeyIn$ < FirstKey$ THEN ' 06-26-2002 Jean-Pierre LEROY
           Record& = FirstRecord&
           zRKey = FirstKey$
           BtErr& = BtErrFirst&
           EXIT FUNCTION
       END IF
       FUNCTION = Bt&(hBtFile&, 69&, zRKey, Record&, BtErr&)
    END IF
END FUNCTION

                                   
Title: Re: dvBTree (free index manager)
Post by: Patrice Terrier on December 24, 2011, 06:31:46 PM
Mike,

It is rather old, but from the top of my head i would say use the dvBtAfter code change done for Jean-Pierre.

...
Title: Re: dvBTree (free index manager)
Post by: Mike Doty on December 24, 2011, 06:34:41 PM
It appears the help in one of my versions is also newer.
I haven't done a complete check of all the code.
Do you still use it?

Title: Re: dvBTree (free index manager)
Post by: Patrice Terrier on December 24, 2011, 06:58:51 PM
I have attached a new ZIP file with the correct CHM help file, and the latest change from 06-22-2002.

Mike I am still using it in the "ZAP Image Solution" database, however the code is embedded directly into the zBt.dll that does extra things, but i have not integrated the change done for Jean-Pierre, probably because i forgot to do it, as i am not using it in ZIS ;)

...

Title: Re: dvBTree (free index manager)
Post by: Mike Doty on December 24, 2011, 07:37:56 PM
Really appreciate it!  Now they match.
dvbtree.bas compiled with PB9   45,056  bytes.
dvbtree.bas compiled with PB10 47,616 bytes.

It is really great code for indexing anything
while still allowing direct access to the data.
This can be many times faster than other methods.