InvoDB/invodb/main.cpp

38 lines
777 B
C++
Raw Normal View History

2021-10-05 14:41:15 +08:00
//
// Created by YuhangQ on 2021/9/24.
//
#include "main.h"
int main() {
2021-10-25 22:07:18 +08:00
srand(time(NULL));
system("rm -rf test.invodb && touch test.invodb");
2021-10-24 20:21:04 +08:00
2021-10-23 16:28:57 +08:00
PageManager::loadDatabase("test.invodb");
Collection::loadCollections();
2021-10-11 22:05:45 +08:00
2021-10-23 16:28:57 +08:00
PageManager& manager = PageManager::Instance();
2021-10-11 22:05:45 +08:00
2021-10-25 22:07:18 +08:00
Collection *col;
try {
col = &Collection::getCollection("hello");
} catch(const char *error) {
Collection::createCollection("hello");
}
2021-10-23 16:28:57 +08:00
JSON json("{\"hello\": 1}");
2021-10-25 22:07:18 +08:00
col->insert(json);
BTreeUUID *btree = new BTreeUUID(PageManager::Instance().allocate());
char uuid[32];
for(int i=0; i<1000; i++) {
generateUUID(uuid);
btree->insert(uuid, PageManager::Instance().allocate());
}
btree->print();
2021-10-05 14:41:15 +08:00
return 0;
}