当前位置: 首页>>代码示例>>C++>>正文


C++ FileManager::openFile方法代码示例

本文整理汇总了C++中FileManager::openFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileManager::openFile方法的具体用法?C++ FileManager::openFile怎么用?C++ FileManager::openFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileManager的用法示例。


在下文中一共展示了FileManager::openFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_delete_record

void test_delete_record() {
	int fileID;
	FileManager* fm = new FileManager();
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
	RecordManager* test = new RecordManager(fm);
	test->load_table_info(fileID);
	vector<string> newRecord, newRecord2, newRecord3;

	newRecord.push_back("106001");
	newRecord.push_back("'CHAD CABELLO'");
	newRecord.push_back("'F'");
	newRecord2.push_back("106002");
	newRecord2.push_back("'CHAD CABELLO'");
	newRecord2.push_back("'M'");
	newRecord3.push_back("106003");
	newRecord3.push_back("'CHAD CABELLO'");
	newRecord3.push_back("'F'");
	vector<int> nulls;
	nulls.push_back(1);
	nulls.push_back(1);
	nulls.push_back(1);

	test->insert_record(fileID, newRecord, nulls);	
	test->insert_record(fileID, newRecord2, nulls);
	test->insert_record(fileID, newRecord3, nulls);

	test->print_all_record(fileID);
	test->delete_record(fileID, 2);
	test->insert_record(fileID, newRecord, nulls);	
	test->print_all_record(fileID);
	// for (int i = 0; i < 9000; i++) {
	// 	test->insert_record(fileID, newRecord);
	// }
	// test->print_all_record();
}
开发者ID:AnthonyWang14,项目名称:DB_prj,代码行数:35,代码来源:testfilesystem.cpp

示例2: test_create_table

void test_create_table() {
	int fileID;
	FileManager* fm = new FileManager();
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
	RecordManager* test = new RecordManager(fm);
	int attr_num = 3;
	int attr_len[9] = {1, 10, 1, 0, 25, 0, 0, 1, 1};
	int primary_key = 0;
	vector<string> attr_name;
	attr_name.push_back("id");
	attr_name.push_back("name");
	attr_name.push_back("gender");
	test->init(fileID, attr_num, attr_len, primary_key, attr_name);
	test->load_table_info(fileID);
}
开发者ID:AnthonyWang14,项目名称:DB_prj,代码行数:15,代码来源:testfilesystem.cpp

示例3: test_find_attr

void test_find_attr() {
	int fileID;
	FileManager* fm = new FileManager();
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
	RecordManager* test = new RecordManager(fm);
	test->load_table_info(fileID);
	vector<string> rtn = test->find_attr(fileID, "hehe");
	for (int i = 0; i < rtn.size(); i++) {
		cout << rtn[i] << endl;
	}	

	vector<string> rtn2 = test->find_attr(fileID, "name");
	for (int i = 0; i < rtn2.size(); i++) {
		cout << rtn2[i] << endl;
	}
}
开发者ID:AnthonyWang14,项目名称:DB_prj,代码行数:16,代码来源:testfilesystem.cpp

示例4: test_update_record

void test_update_record() {
	int fileID;
	FileManager* fm = new FileManager();
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
	RecordManager* test = new RecordManager(fm);
	test->load_table_info(fileID);
	test->print_all_record(fileID);
	test->update_record(fileID, 0, "id", "106002", 0);
	test->update_record(fileID, 1, "name", "'wangsu'", 1);
	if (test->update_record(fileID, 2, "heheh", "21331312111", 1)) {
		cout << "wrong update" << endl;
	}
	else {
		cout << "success update" << endl;
	}
	test->print_all_record(fileID);
}
开发者ID:AnthonyWang14,项目名称:DB_prj,代码行数:17,代码来源:testfilesystem.cpp

示例5: init

void init() {
	FileManager* fm = new FileManager();
	BufPageManager* bpm = new BufPageManager(fm);
	fm->createFile("testfile.txt"); //新建文件
	int fileID;
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id

	int index;
	BufType b = bpm->allocPage(fileID, 0, index, true);
	b[0] = 256;
	b[1] = 100;
	b[2] = 0;
	b[3] = 0;
	for (int i = 0; i < b[1]; i++) {
		b[i+4] = 0;
	}
	bpm->markDirty(index);
	fm->writePage(fileID, 0, b, 0);
	bpm->close();
}
开发者ID:AnthonyWang14,项目名称:DB_prj,代码行数:20,代码来源:testfilesystem.cpp

示例6: main

int main() {
	FileManager* fm = new FileManager();
	BufPageManager* bpm = new BufPageManager(fm);
	fm->createFile("testfile.txt"); //新建文件
	int fileID;
	fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
	for (int pageID = 0; pageID < 1000; ++ pageID) {
		int index;
		//为pageID获取一个缓存页
		BufType b = bpm->allocPage(fileID, pageID, index, false);
		b[0] = pageID; //对缓存页进行写操作
		bpm->markDirty(index); //标记脏页
	}
	for (int pageID = 0; pageID < 1000; ++ pageID) {
		int index;
		//为pageID获取一个缓存页
		BufType b = bpm->getPage(fileID, pageID, index);
		cout << b[0] << endl; 		//读取缓存页中第一个整数
		bpm->access(index); //标记访问
	}
	return 0;
}
开发者ID:Naiselim,项目名称:database,代码行数:22,代码来源:testfilesystem.cpp


注:本文中的FileManager::openFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。