Main Page   Class Hierarchy   Compound List   File List   Compound Members  

ttree.h

00001 //-< TTREE.CPP >-----------------------------------------------------*--------*
00002 // FastDB                    Version 1.0         (c) 1999  GARRET    *     ?  *
00003 // (Main Memory Database Management System)                          *   /\|  *
00004 //                                                                   *  /  \  *
00005 //                          Created:     20-Nov-98    K.A. Knizhnik  * / [] \ *
00006 //                          Last update: 10-Dec-98    K.A. Knizhnik  * GARRET *
00007 //-------------------------------------------------------------------*--------*
00008 // T-Tree interface
00009 //-------------------------------------------------------------------*--------*
00010 
00011 #ifndef __TTREE_H__
00012 #define __TTREE_H__
00013 
00014 BEGIN_FASTDB_NAMESPACE
00015 
00016 class FASTDB_DLL_ENTRY dbTtreeNode { 
00017     enum { 
00018         pageSize = 125,
00019         minItems = pageSize - 2 // minimal number of items in internal node
00020     };
00021 
00022   public:
00023     oid_t left;
00024     oid_t right;
00025     int1  balance;
00026     nat2  nItems;
00027     oid_t item[pageSize];
00028 
00029     static oid_t allocate(dbDatabase* db, oid_t recordId);
00030     
00031     static bool  insert(dbDatabase* db, oid_t& nodeId, oid_t recordId, 
00032                         void* key, int type, int sizeofType, dbUDTComparator comparator, int offs);
00033     static int   remove(dbDatabase* db, oid_t& nodeId, oid_t recordId,  
00034                         void* key, int type, int sizeofType, dbUDTComparator comparator, int offs);
00035     static int   balanceRightBranch(dbDatabase* db, oid_t& nodeId);
00036     static int   balanceLeftBranch(dbDatabase* db, oid_t& nodeId);
00037     
00038     static void  purge(dbDatabase* db, oid_t nodeId);
00039 
00040     bool find(dbDatabase* db, dbSearchContext& sc);
00041     bool prefixSearch(dbDatabase* db, dbSearchContext& sc);
00042 
00043     bool traverseForward(dbDatabase* db,dbAnyCursor* cursor);
00044     bool traverseBackward(dbDatabase* db, dbAnyCursor* cursor);
00045     bool traverseForward(dbDatabase* db,dbAnyCursor* cursor,dbExprNode* cond);
00046     bool traverseBackward(dbDatabase* db,dbAnyCursor* cursor,dbExprNode* cond);
00047 };
00048 
00049 class FASTDB_DLL_ENTRY dbTtree { 
00050   protected:
00051     oid_t root;
00052 
00053   public:
00054     static oid_t allocate(dbDatabase* db);
00055     static void  find(dbDatabase* db, oid_t treeId, dbSearchContext& sc);
00056     static void  prefixSearch(dbDatabase* db, oid_t treeId, dbSearchContext& sc);
00057     static void  insert(dbDatabase* db, oid_t treeId, oid_t recordId, 
00058                         int type, int sizeofType, dbUDTComparator comparator, int offs);
00059     static void  remove(dbDatabase* db, oid_t treeId, oid_t recordId,
00060                         int type, int sizeofType, dbUDTComparator comparator, int offs);
00061     static void  drop(dbDatabase* db, oid_t treeId);
00062     static void  purge(dbDatabase* db, oid_t treeId);
00063     
00064     static void  traverseForward(dbDatabase* db, oid_t treeId,
00065                                  dbAnyCursor* cursor);
00066     static void  traverseBackward(dbDatabase* db, oid_t treeId,
00067                                   dbAnyCursor* cursor);
00068     static void  traverseForward(dbDatabase* db, oid_t treeId,
00069                                  dbAnyCursor* cursor, dbExprNode* condition);
00070     static void  traverseBackward(dbDatabase* db, oid_t treeId,
00071                                   dbAnyCursor* cursor, dbExprNode* condition);
00072 };
00073 
00074 END_FASTDB_NAMESPACE
00075 
00076 #endif

Generated on Mon Oct 23 13:23:58 2006 for FastDB by doxygen1.2.18