Virtual Machinery logo BTree
Home BTree Guide BTree Performance Sample Applications BTree Roadmap Other Products
Quick start For Smalltalk BTree implementation

This code is designed to show you how easy it is to use the Virtual Machinery Smalltalk implementation of the BTree classes. It shows you all the basic operations including opening and closing a BTree, adding, fetching and deleting data and closing the BTree.

Creating a new BTree

 Obviously the first time you use this software you will be creating a new BTree so lets do that

 |myTree|

 myTree := BTree createNewTree: 'MYTREE'.
 myTree at: 'MYINDEX' put: 'MYDATA'.
 Transcript nextPutAll: (myTree at: 'MYINDEX'); cr.
 myTree at: 'MYNEXTINDEX' put: 'MYNEXTPIECEOFDATA'.
 myTree remove: 'MYINDEX'.
 Transcript nextPutAll: (myTree at: 'MYINDEX'); cr.
 myTree closeBtree.

 The mesage protocol follows that of the Dictionary classes - #at:put: adds data to the BTree, #at: retrieves it and #remove: removes it. Both data and index must be Strings. As you can see nothing was output for the second attempt to get the data at 'MYINDEX' since we had deleted the data.

Opening an existing BTree

 You can also open an existing tree - so lets re-open the tree we created above - as you can see we can still access the data at 'MYNEXTINDEX'

 |myTree|

 myTree := BTree openExistingTree: 'MYTREE'.
 Transcript nextPutAll: (myTree at: 'MYNEXTINDEX'); cr.
 myTree closeBtree.

 These are the basics of using the BTree in your code - for more details of the other options including  page sizes , cacheing and commit and rollback see the programmers guide .