home *** CD-ROM | disk | FTP | other *** search
- RELEASE SHEET for CBTREE Version 2.30
- Revised 11/01/87
-
- This document describes the changes which you must make to your source code
- in order to upgrade from version 1.3x to version 2.x. BACKUP ALL YOUR SOURCE
- AND INDEX FILES BEFORE PROCEEDING!
-
- 1. btrinit() now allocates memory for btcommo.btkey. This means you should
- not do this. The number of bytes allocated is btcommo.btkeylen + 1.
- btcommo.btkeylen is defined by BTSETUP.EXE.
-
- 2. A new function btrterm(&btcommo) has been added to de-initialize your
- B+tree. It currently releases memory allocated for btcommo.btkey and
- btcommo.btrecnum. You should call this function instead of directly
- freeing btcommo.btkey. This function will have increased functionality
- in future releases. Therefore it is very important to start using the
- btrinit()/btrterm() function pair.
-
- 3. btcommo.btrecnum used to be an array of MAXARRAY longs. It is now a
- pointer to a dynamically allocated memory block which is allocated in
- btrinit(). The number of bytes allocated is:
-
- sizeof(long) * (btcommo.btmax + 1).
-
- btcommo.btmax is defined in BTSETUP.EXE as the field Max Recs. The main
- impact of this on your source is that all occurrences of MAXARRAY-1 should
- be replaced with btcommo.btmax.
-
- 4. GETSEQ, GETALL and the new function GETKEYS often need to be called
- several times in sequence before the entire index has been scanned. These
- functions now maintain internal variables which remember the state of the
- function between calls. This means:
- o Improved performance,
- o the original key no longer has to be re-loaded between calls
- (although this will have no harmful effect),
- o the functions *MUST* be called repeatedly until a less than full
- block is returned (fewer than btcommo.btmax record numbers were
- returned), or BTNOTFND was returned. If the calling sequence is to
- be terminated before one of these conditions is met, the function
- free_svkey(&btcommo) *MUST* be called. This is in order to reset the
- internal variables. Not doing this may be dangerous to the health of
- your B+trees.
-
- Version 2.10:
-
- 5. The CBTREE NULL key value has been changed from three 7F's to a single 7F
- in order to support key lengths of less than 3 characters. This means
- that the first character of all keys must be between 0x01 and 0x7e
- inclusive. This is typical for ASCII keys.
-
- 6. The source file 'btgiver.c' has been renamed to 'giveidxr.c'.
-
- 7. The external variable 'freespc' has been removed. The functions which
- used 'freespc' have therefore been modified to receive 'freespc' as a
- parameter. These include:
-
- putfhdr(fd, freespc) and getfhdr(freespc, fd).
-
- This is of importance only to those users who use these lower level
- functions.
-
- 8. A macro btseek() has been added to cbtree.h. This is useful in seeking
- to a record specified by btcommo.btloc. The usage of the macro is:
-
- btseek(fd, btloc, reclen).
-
- For example, after calling GETREC for a given key, you would call:
-
- btseek(fd, btcommo.btloc, btcommo.btdatlen);
-
- to seek to the desired record. btseek() takes care of the "record
- location minus one" arithmetic for you. See getfpat.c for a simple
- example on the use of btseek().
- IMPORTANT NOTE: The btcommo.btloc return value may change in a future
- release. We therefore recommend that you start using
- btseek() so that this possible future change will
- be transparent to your source code.
-
- 9. A new function bt_open() has been added to support the new file
- protection mode paramters of the open() function. bt_open() also
- maintains compatibility with older compilers. You should use bt_open()
- instead of open() to open ALL your data and index files, especially
- at places where a new file may be created. See btfio.h for more
- information. See bld2keys.c for an example on how to use bt_open().
-
- Version 2.11:
-
- 10. A new utility CHKBTREE.C has been added and performs integrity checks on
- the specified B+tree index file.
-
- 11. Bug fix for GETALL and GETKEYS: if the final call to a series of GETALL
- operations happened to exactly fill the btcommo.btrecnum block, then
- the NEXT call to GETALL/GETKEYS would not return BTNOTFND, as it should
- have. Now it does.
-
- 12. A buffer-full check in getidxr() allowed 4 bytes too many to be read into
- the buffer. This has now been fixed.
-
- 13. Reminder: the cbtree() error messages are stored in the file
- "ckerror.msg." If you would like verbose error messages to be displayed,
- instead of just numerical codes, keep a copy of this file in the current
- directory. Error messages will also get written to the file "error.fil"
- when they occur.
-
- Version 2.20:
-
- 14. Version 2.20 allows multiple B+trees to be stored in a single index file.
- In order to support this enhancement, several changes have been made to
- the CBTREE library functions as well as the support utilities:
-
- o BTSETUP.EXE has a new field for the Index File Name. The default
- name will be your B+tree Name plus the extention ".idx". The TBA
- field should be left zero for now. If you desire multiple
- B+trees to reside in the same Index File, then you should specify
- the SAME Index File Name for ALL the B+trees that are to be
- contained in it. BTSETUP.EXE now has a Delete function to allow
- you to delete a particular B+tree entry.
-
- o BTPARMS.BTR has an expanded structure. BTSETUP.EXE should be run
- for each of your B+trees to update the BTPARMS.BTR file. Each of
- your B+tree entries should be "edited," then the resulting new
- settings should be saved. This is to make your parameter file
- compatible with the changes made to support multiple B+trees in a
- single index file.
-
- o btrinit() has been enhanced to use the new information in the
- BTPARMS.BTR file. In particular, btrinit() now initializes the
- new btcommo structure member "idxname" with the Index File Name
- which you speicified in BTSETUP.EXE. We urge to refer to
- your index file names through btcommo.idxname, as when you
- bt_open() your index files.
-
- o If creatbtr() is called, it should be called IMMEDIATELY
- following the corresponding call to btrinit(), and BEFORE any
- subsequent calls to btrinit(). This is extremely important when
- multiple B+trees are contained in a single index file.
-
- o creatbtr() now only takes a single parameter (the address of the
- btcommo structure), since the second parameter (the Index file
- Name) is now included in the btcommo structure.
- creatbtr() has been substantially modified for use with multiple
- B+trees in a single index file. Previously, creatbtr() would
- always truncate an existing index file and initialize it with a
- single empty root node. Since there may be mutiple B+trees in an
- index file, creatbtr() CANNOT now truncate the file without
- destroying the other B+trees as well. If more than one B+tree
- already exists in a given index file, creatbtr() will now delete
- ONLY those nodes belonging to that B+tree. This process can take
- several moments and it is therefore recommended that you develop
- an application (if possible) using separate index files for each
- B+tree. After development you can easily place all your B+trees
- in a single index file. See Bld2keys.c which supports both
- methods.
-
- Version 2.21:
-
- 15. The portable file opening function bt_open() now supports the O_CREAT
- mode flag. Normally O_NEW is used to specify a new/empty file.
- O_CREAT will leave an existing file untouched.
-
- 16. All modules which use bt_open() should include the CBTREE file I/O
- header "btfio.h".
-
- 17. The error reporting function ckerror() now uses low-level file
- descriptors to write to ERROR.FIL. This means that the CBTREE Library
- proper now has NO EXPLICIT references to FILE streams. The library
- still has implicit references 'stdout' via calls to printf(), etc., but
- these can easily be removed without effecting the functionality of the
- library.
-
- 18. Support added for Ecosoft C compiler and Amiga Manx compiler. Special
- thanks to David E. Holt for his work in porting to the Amiga Manx
- compiler.
-
- Version 2.30:
-
- 19. This version adds support for variable length records. The support
- functions are in the file btvarlen.c. With a few exceptions, variable
- length records opereate the same way as fixed-length records. The
- support programs have all been modified (as applicable) to use a sample
- variable length data file. Simply invoke the program with the "-v"
- option and it will use the variable length database. In particular:
- o BLD2KEYS -v -- build a working database w/ two keys
- o USERBTR -v -- interactive demonstration
- o BLDBTREE -v -- rebuilds the primary B+tree
- o CBTRSEQ -v -- goes "inside" the B+tree for sequential keys
- o TIMECB5 -v -- sample CBTREE operation timing suite
-
- 20. To invoke variable-length records, specify a Data Record Length of 0
- (zero) in BTSETUP.EXE. Make sure ALL indexes for a given data file
- agree!
-
- 21. Bld2keys.c is now especially well commented and is a good starting point
- for looking into variable length records.
-
- 22. A new function initdat(fd, &btcommo) has been added to the library which
- will automatically initialize your data file header record. It will
- work properly for both fixed- and variable-length records.
-
- 23. Before calling INSERT, btcommo.btdtalen must be set to the length of
- your (variable-length) record. This is only required for the INSERT
- operation, and when using variable-length records.
-
- 24. The macro btseekv(fd, recloc, recsiz) has been added to cbtree.h for use
- with variable length records. It is designed to be compatible with
- btseek().
-
- 25. The functions in getfpatv.c and putfpatv.c (c.f. getfpat.c and
- putfpat.c) demonstrate getting and putting variable-length records.
-
- 26. Two varaible length record functions will be directly needed by your
- application:
- o btsizvar(fd, recloc), and
- o btnxtvar(fd, recloc).
-
- btsizvar() will return the size of the record at the specified record
- location. You will need to call this function before reading your
- record so you know how much to read.
-
- btnxtvar() will return the location of the next record after the given
- one. If the 'recloc' is 1L (an "illegal" record location), it will
- return the location of the FIRST record. This function can be used for
- scanning your data base or re-indexing. See bldbtree.c for an example.
-
- 27. The program MKCBTREE.EXE has been renamed to MAKBTREE.EXE.
-
- 28. The program CKBTREE.EXE has been renamed to CHKBTREE.EXE.
-
- 29. The program DELBTREE.EXE has been provided to delete a B+tree from an
- index file. If the index file has more than one B+tree, it will delete
- only those nodes belonging to the one specified.
-
- SUMMARY:
- 1. Take out memory allocation calls for btcommo.btkey.
- 2. Replace calls to free btcommo.btkey with btrterm(&btcommo).
- 3. Replace occurrences of MAXARRAY-1 with btcommo.btmax.
- 4. GETSEQ, GETALL and GETKEYS must be called repeatedly until fewer than
- btcommo.btmax records are returned. Otherwise free_svkey(&btcommo) must
- be called.
- 5. Declare local version of 'freespc' (where used) and pass as parameter to
- getfhdr() and putfhdr().
- 6. Replace all lseek( fd, (btloc-1) * reclen, 0 ) calls with
- btseek(fd, btloc, reclen) invocations.
- 7. Use bt_open() instead of open(), and include "btfio.h".
- 8. Keep the error message file "ckerror.msg" in the current directory for
- verbose error messages.
- 9. Run BTSETUP and enter the "edit" mode for EACH of your B+trees. Enter
- the proper name for the Index File corresponding to each of your B+trees.
- Then [S]ave the new settings. The file BTPARMS.BTR will be updated.
- 10. Include "btfio.h" in those modules that use bt_open().
- 11. All calls to creatbtr() (if any) should be placed immediately after the
- corresponding call to btrinit() and before any further calls to
- btrinit(). This is REQUIRED if you are placing multiple B+trees in a
- single index file.
- 12. Use the function initdat(fd, &btcommo) to initialize your data file
- header record.
- 13. Use btsizvar() to get the size of your variable length data record.
- Then use btseekv() to seek to it. Then read it. HINT: since the
- record size is embedded in the data file, use btsizvar() only just
- before reading the data record. This will reduce overall access time.
-
- NOTE: Run BTSETUP.EXE and specify the value you had for MAXARRAY-1 as
- Max Recs. See Appendix B in the manual: you may have to re-index if
- Cells Per Index Block is changed by BTSETUP.EXE.