• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

dvBTree (free index manager)

Started by Patrice Terrier, August 03, 2007, 04:48:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

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:

  • B-Tree routines are multi-user and they can be used to share file on a local network.
  • B-Tree index sizes are limited to 2^31-1 = 2,147,483,648 bytes.
  • Requested room to store one index is : Index Size = (Key Length * 2.5) * Number of records.
  • Searches can be performed on a partial or exact matching key.
  • An index stores only the keys, and returns the corresponding record number in the main database.
  • Keys in an index are always converted to uppercase.

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.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

Thanks Patrice, downloaded for future study.

Petr Schreiber

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

AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Mike Doty

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?






Mike

Haim Jamer

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

Patrice Terrier

#6
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.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Haim Jamer

Thanks for your prompt response.
I'll keep studying this.
HJ

Mike Doty

#8
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

                                   
Mike

Patrice Terrier

Mike,

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

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Mike Doty

#10
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?

Mike

Patrice Terrier

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 ;)

...

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Mike Doty

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.


Mike