Compare commits

..

No commits in common. "master" and "测试" have entirely different histories.

9 changed files with 400014 additions and 40 deletions

View File

@ -1,7 +1,7 @@
include_directories(./src)
project (invodb)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 17)

BIN
benchmark/benchmark.sqlite Normal file

Binary file not shown.

View File

@ -3,6 +3,7 @@ const { execSync } = require("child_process")
execSync("rm -rf benchmark.invodb")
let time = 0
function clock() {
let last = time

130004
benchmark/test.log Normal file

File diff suppressed because it is too large Load Diff

270004
benchmark/test2.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
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)

View File

@ -17,7 +17,7 @@ function collection(collectionName) {
let json = JSON.stringify(object);
core.remove(collectionName, json);
}
function find(object) {
function query(object) {
if(!core.exists(collectionName)) throw `Collection ${collectionName} doesn't exists!`;
let json = JSON.stringify(object);
let res = [];
@ -26,18 +26,12 @@ function collection(collectionName) {
}
return res;
}
function findOne(object) {
let res = find(object);
if(res.length >= 1) return res[0];
return undefined;
}
return {
exist: exist,
create: create,
insert: insert,
remove: remove,
find: find,
findOne: findOne,
query: query,
update: insert
}
}

View File

@ -1,6 +1,6 @@
{
"name": "invodb",
"version": "1.1.1",
"version": "1.0.23",
"description": "a nosql json document database",
"main": "index.js",
"scripts": {

View File

@ -10,7 +10,6 @@ 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();
@ -69,13 +68,12 @@ 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;