add index tree

This commit is contained in:
YuhangQ 2021-11-02 11:35:41 +08:00
parent 0c05c4424c
commit 7e8d6d8e5a
2 changed files with 26 additions and 17 deletions

View File

@ -13,7 +13,7 @@ int main() {
srand(t); srand(t);
printf("seed: %d\n", t); printf("seed: %d\n", t);
//system("rm -rf test.invodb && touch test.invodb"); system("rm -rf test.invodb && touch test.invodb");
PageManager::loadDatabase("test.invodb"); PageManager::loadDatabase("test.invodb");
@ -29,24 +29,31 @@ int main() {
col = &Collection::getCollection("hello"); col = &Collection::getCollection("hello");
} }
testAndBenchmark(10000); //testAndBenchmark(10000);
// nlohmann::json j = nlohmann::json::parse(R"( nlohmann::json j = nlohmann::json::parse(R"(
//{ {
// "string": "this is a string!", "string": "this is a string!",
// "double": 3.1415, "double": 3.1415,
// "int": 25565, "int": 25565,
// "bool": true, "bool": true,
// "child": { "child": {
// "id": 3 "id": 3
// }, },
// "array": ["1", "2", "3"] "array": ["1", "2", "3"]
// )"); )");
//
// col->insert(j);
// try {
// col->remove(j); col->insert(j);
}catch(const char * s ){
puts(s);
}
printf("?");
col->remove(j);
return 0; return 0;
} }

View File

@ -77,6 +77,8 @@ Collection::Collection(const std::string &name, const int &firstPage) {
} }
void Collection::insert(nlohmann::json &json) { void Collection::insert(nlohmann::json &json) {
if(json["__INVO_ID__"].empty()) { if(json["__INVO_ID__"].empty()) {
json["__INVO_ID__"] = generateUUID(); json["__INVO_ID__"] = generateUUID();
} else { } else {