📄 catalogmanager.cpp
字号:
// CatalogManager.cpp: implementation of the CatalogManager class.
//
//////////////////////////////////////////////////////////////////////
#include "CatalogManager.h"
#include "AttributeBlock.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CatalogManager::CatalogManager()
{
}
CatalogManager::~CatalogManager()
{
}
void CatalogManager::set_BufferManager(BufferManager *Buffer_Manager)
{
BM = Buffer_Manager;
}
opn_res * CatalogManager::create_table(table_info *table)
{
opn_res* result = new opn_res;
int attri_block = BU.add();
int record_block = BU.add();
int index_block = BU.add();
// TB.Block_head = BM->readBlock (TABLE_START_BLOCKNO);
TB.add_table(table , attri_block , record_block, index_block);
//添加表定义信息
// BM->writeBlock( TABLE_START_BLOCKNO );
//
// BM->finalize();
// BM->initialize(".//ccql.DBF");
//
AttributeBlock AB;
char* attri_head = BM->readBlock ( attri_block );
AB.add_attri_list(table,attri_head);
BM->writeBlock( attri_block );
//添加attributes 信息
result->error_info = 1;
return result;
}
void CatalogManager::init(BufferManager *Buffer_Manager)
{
set_BufferManager(Buffer_Manager);
BU.set_BufferManager(Buffer_Manager);
BU.GetBlockHead();
TB.Block_head = BM->readBlock(TABLE_START_BLOCKNO );
BM->lockBlock(TABLE_START_BLOCKNO );
IB.Block_head = BM->readBlock(INDEX_START_BLOCKNO );
BM->lockBlock(INDEX_START_BLOCKNO );
}
void CatalogManager::finalize()
{
BM->unlockBlock(TABLE_START_BLOCKNO );
BM->unlockBlock(INDEX_START_BLOCKNO );
}
struct table_info* CatalogManager::get_table_info(char *table_name)
{
struct table_info* ti;
ti = (struct table_info*) TB.get_table_info(table_name);
int attri_blockNo = TB.get_attri_start_block(table_name);
AttributeBlock AB;
char* attri_head = BM->readBlock(attri_blockNo);
BM->lockBlock(attri_blockNo);
AB.get_attri_list(attri_head,ti);
BM->unlockBlock(attri_blockNo);
return ti;
}
int CatalogManager::get_table_index_blockNo(char *table_name)
{
return TB.get_index_start_block(table_name);
}
int CatalogManager::get_table_record_blockNo(char *table_name)
{
return TB.get_record_start_block(table_name);
}
void CatalogManager::set_table_in_TB(char* table_name)
{
}
void CatalogManager::delete_a_block(int BlockNo)
{
BU.delete_a_block(BlockNo);
}
void CatalogManager::drop(char *table_name)
{
struct tableDefinition* td;
td = (struct tableDefinition*) TB.find_table_name(table_name);
this->delete_a_block(td->attri_start_block);
this->delete_a_block(td->index_start_blcok);
this->delete_a_block(td->record_start_block);
// delete td;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -