本文整理汇总了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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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();
}
示例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;
}