📄 bplustree.h
字号:
// BplusTree.h: interface for the CBplusTree class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BPLUSTREE_H__A6AE4165_56BA_4CEB_8259_1687119E96DC__INCLUDED_)
#define AFX_BPLUSTREE_H__A6AE4165_56BA_4CEB_8259_1687119E96DC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "BTNODE.h"
#include "Memory.h"
#include "IndexFile.h"
#include "Buffer.h"
#include "MultiIdx.h"
#include "Result.h"
//B树主文件
//UINT MainID
//BYTE DUP
//BYTE KeyType
//BYTE KeyNum
//WORD KeyLength
//WORD M
//PDB ROOT
//PDB SQT
//unsigned int m_uiKeyCount;
//unsigned int m_uiEffectKey;
//UINT CurrentFile//当前文件号
class CBplusTree
{
public:
UINT MainID;
BYTE KeyNum;
BYTE KeyType;
WORD KeyLength;
unsigned short M;
BTNODE *m_root;
BTNODE * m_sqt;
UINT CurrentFile;
BOOL Dup;//是否允许重复键.与KEY中的Dup不同
double m_dbFillDegree;
unsigned int m_uiKeyCount;
unsigned int m_uiEffectKey;
PDB ROOT;
PDB SQT;
public:
BOOL DeletePtr(KEY key,PDB pdbNode,int pos,PDB recptr=0);
CBuffer * SearchScope(KEY key1, KEY key2, PDB pdbNode,bool flag1,bool flag2
, int pos);
CBuffer * SearchAll(KEY key, CResult *res, BOOL Dup);
BOOL WriteBack(CMultiIdx *multi_idx,WORD multi_num);
BOOL Construct(UINT FileNo);
//BOOL DeleteKey(BTNODE *pNode,KEY x,int pos);
//CBplusTree & operator =(CBplusTree &T);
int DeleteBTreeAll(KEY key,PDB pdbNode,int pos);
unsigned short GetM();
BTNODE *GetRoot();
PDB GetSqt();
CResult SearchBTree(KEY key);
int InsertBTree(KEY key,PDB db_addr,PDB pdbNode,int pos);
CBplusTree();
CBplusTree(UINT main_id,BOOL D,BYTE KT,BYTE KN,WORD KL,UINT currentf);
virtual ~CBplusTree();
protected:
BOOL InsertKey(BTNODE *pNode,KEY x,PDB db_addr,int pos,BTNODE *pApNode);
private:
int Position(BTNODE *pNode,BTNODE *parent);
void NewRoot(BTNODE *pNode,KEY key,BTNODE *pApNode,PDB key_db_addr);//key_db_addr只在没有根结点时使用
int Position(KEY key,BTNODE *pNode);
KEY Split(BTNODE *pNode,unsigned int s,BTNODE *pApNode);//改变next和keynum
};
#endif // !defined(AFX_BPLUSTREE_H__A6AE4165_56BA_4CEB_8259_1687119E96DC__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -