mirror of
https://github.com/YuhangQ/InvoDB.git
synced 2025-01-24 21:50:58 +00:00
add demo
This commit is contained in:
parent
5c078437bb
commit
801c9c510b
Binary file not shown.
130004
benchmark/test.log
130004
benchmark/test.log
File diff suppressed because it is too large
Load Diff
270004
benchmark/test2.log
270004
benchmark/test2.log
File diff suppressed because it is too large
Load Diff
27
docs/test.js
Normal file
27
docs/test.js
Normal file
@ -0,0 +1,27 @@
|
||||
const invodb = require('..')
|
||||
|
||||
invodb.database('test.invodb')
|
||||
|
||||
let col = invodb.collection('blog')
|
||||
if(!col.exist()) col.create();
|
||||
|
||||
col.insert({
|
||||
"id": 7,
|
||||
"title": "这是一篇文章",
|
||||
"content": "这是文章内容",
|
||||
"author": "YuhangQ",
|
||||
"category": "数据库",
|
||||
"original-url": null,
|
||||
"tags": ["数据库", "C++", "数据结构"],
|
||||
"parameters": {
|
||||
"hidden": true,
|
||||
"like": 25565,
|
||||
},
|
||||
"comment": [
|
||||
{"username": "YuhangQ", "content": "文章写的真不错!"},
|
||||
{"username": "TechCiel", "content": "能提供下打赏渠道吗?"},
|
||||
]
|
||||
})
|
||||
|
||||
let result = col.query({})
|
||||
console.log(result)
|
@ -10,6 +10,7 @@ std::fstream PageManager::stream;
|
||||
int PageManager::loadDatabase(const char *filename) {
|
||||
Instance().stream.open(filename);
|
||||
Instance().stream.seekp(0, std::ios::end);
|
||||
|
||||
if(!Instance().stream.is_open()) {
|
||||
std::ofstream file(filename, std::fstream::out);
|
||||
file.close();
|
||||
@ -68,12 +69,13 @@ int PageManager::allocate() {
|
||||
}
|
||||
|
||||
index = page.getIntStartFrom(4);
|
||||
|
||||
//printf("2allocate: %d\n", index);
|
||||
|
||||
page.setIntStartFrom(4, index + 1);
|
||||
page.save();
|
||||
// allocate block at the end
|
||||
// stream.seekp(0, std::ios::end);
|
||||
// stream.seekp(0, std::ios::end);
|
||||
// index = stream.tellp() / 1024;
|
||||
setPage(index, StoragePage(index));
|
||||
return index;
|
||||
|
Loading…
x
Reference in New Issue
Block a user