@yydb/light-db 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/LightDB.d.ts +194 -0
- package/dist/api/LightDB.d.ts.map +1 -0
- package/dist/api/LightDB.js +299 -0
- package/dist/api/LightDB.js.map +1 -0
- package/dist/api/Transaction.d.ts +100 -0
- package/dist/api/Transaction.d.ts.map +1 -0
- package/dist/api/Transaction.js +263 -0
- package/dist/api/Transaction.js.map +1 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +54 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/types.d.ts +154 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +7 -0
- package/dist/api/types.js.map +1 -0
- package/dist/collection/Collection.d.ts +235 -0
- package/dist/collection/Collection.d.ts.map +1 -0
- package/dist/collection/Collection.js +671 -0
- package/dist/collection/Collection.js.map +1 -0
- package/dist/collection/QueryBuilder.d.ts +225 -0
- package/dist/collection/QueryBuilder.d.ts.map +1 -0
- package/dist/collection/QueryBuilder.js +475 -0
- package/dist/collection/QueryBuilder.js.map +1 -0
- package/dist/collection/QueryParser.d.ts +117 -0
- package/dist/collection/QueryParser.d.ts.map +1 -0
- package/dist/collection/QueryParser.js +438 -0
- package/dist/collection/QueryParser.js.map +1 -0
- package/dist/collection/index.d.ts +42 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +41 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/types.d.ts +365 -0
- package/dist/collection/types.d.ts.map +1 -0
- package/dist/collection/types.js +7 -0
- package/dist/collection/types.js.map +1 -0
- package/dist/constants/index.d.ts +51 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +68 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/errors/index.d.ts +69 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +132 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +729 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/BPlusTree.d.ts +181 -0
- package/dist/indexes/BPlusTree.d.ts.map +1 -0
- package/dist/indexes/BPlusTree.js +528 -0
- package/dist/indexes/BPlusTree.js.map +1 -0
- package/dist/indexes/IndexManager.d.ts +236 -0
- package/dist/indexes/IndexManager.d.ts.map +1 -0
- package/dist/indexes/IndexManager.js +502 -0
- package/dist/indexes/IndexManager.js.map +1 -0
- package/dist/indexes/PrimaryIndex.d.ts +240 -0
- package/dist/indexes/PrimaryIndex.d.ts.map +1 -0
- package/dist/indexes/PrimaryIndex.js +354 -0
- package/dist/indexes/PrimaryIndex.js.map +1 -0
- package/dist/indexes/SecondaryIndex.d.ts +204 -0
- package/dist/indexes/SecondaryIndex.d.ts.map +1 -0
- package/dist/indexes/SecondaryIndex.js +480 -0
- package/dist/indexes/SecondaryIndex.js.map +1 -0
- package/dist/indexes/errors.d.ts +66 -0
- package/dist/indexes/errors.d.ts.map +1 -0
- package/dist/indexes/errors.js +117 -0
- package/dist/indexes/errors.js.map +1 -0
- package/dist/indexes/index.d.ts +52 -0
- package/dist/indexes/index.d.ts.map +1 -0
- package/dist/indexes/index.js +131 -0
- package/dist/indexes/index.js.map +1 -0
- package/dist/indexes/types.d.ts +246 -0
- package/dist/indexes/types.d.ts.map +1 -0
- package/dist/indexes/types.js +30 -0
- package/dist/indexes/types.js.map +1 -0
- package/dist/performance/BatchWALWriter.d.ts +185 -0
- package/dist/performance/BatchWALWriter.d.ts.map +1 -0
- package/dist/performance/BatchWALWriter.js +490 -0
- package/dist/performance/BatchWALWriter.js.map +1 -0
- package/dist/performance/ColumnarStorage.d.ts +138 -0
- package/dist/performance/ColumnarStorage.d.ts.map +1 -0
- package/dist/performance/ColumnarStorage.js +875 -0
- package/dist/performance/ColumnarStorage.js.map +1 -0
- package/dist/performance/LazyQuery.d.ts +307 -0
- package/dist/performance/LazyQuery.d.ts.map +1 -0
- package/dist/performance/LazyQuery.js +588 -0
- package/dist/performance/LazyQuery.js.map +1 -0
- package/dist/performance/OptimizedBuffer.d.ts +375 -0
- package/dist/performance/OptimizedBuffer.d.ts.map +1 -0
- package/dist/performance/OptimizedBuffer.js +730 -0
- package/dist/performance/OptimizedBuffer.js.map +1 -0
- package/dist/performance/RWLock.d.ts +260 -0
- package/dist/performance/RWLock.d.ts.map +1 -0
- package/dist/performance/RWLock.js +570 -0
- package/dist/performance/RWLock.js.map +1 -0
- package/dist/performance/index.d.ts +41 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/index.js +162 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/types.d.ts +247 -0
- package/dist/performance/types.d.ts.map +1 -0
- package/dist/performance/types.js +26 -0
- package/dist/performance/types.js.map +1 -0
- package/dist/storage/Checkpoint.d.ts +128 -0
- package/dist/storage/Checkpoint.d.ts.map +1 -0
- package/dist/storage/Checkpoint.js +251 -0
- package/dist/storage/Checkpoint.js.map +1 -0
- package/dist/storage/LightFile.d.ts +227 -0
- package/dist/storage/LightFile.d.ts.map +1 -0
- package/dist/storage/LightFile.js +526 -0
- package/dist/storage/LightFile.js.map +1 -0
- package/dist/storage/Recovery.d.ts +172 -0
- package/dist/storage/Recovery.d.ts.map +1 -0
- package/dist/storage/Recovery.js +399 -0
- package/dist/storage/Recovery.js.map +1 -0
- package/dist/storage/SHMFile.d.ts +243 -0
- package/dist/storage/SHMFile.d.ts.map +1 -0
- package/dist/storage/SHMFile.js +436 -0
- package/dist/storage/SHMFile.js.map +1 -0
- package/dist/storage/StorageEngine.d.ts +146 -0
- package/dist/storage/StorageEngine.d.ts.map +1 -0
- package/dist/storage/StorageEngine.js +353 -0
- package/dist/storage/StorageEngine.js.map +1 -0
- package/dist/storage/WALFile.d.ts +248 -0
- package/dist/storage/WALFile.d.ts.map +1 -0
- package/dist/storage/WALFile.js +597 -0
- package/dist/storage/WALFile.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +153 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types/index.d.ts +220 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/binary.d.ts +271 -0
- package/dist/utils/binary.d.ts.map +1 -0
- package/dist/utils/binary.js +454 -0
- package/dist/utils/binary.js.map +1 -0
- package/dist/utils/file.d.ts +166 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +346 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +39 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +37 -0
- package/readme.md +124 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 文件操作工具类
|
|
4
|
+
* 提供文件系统操作的封装
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding =
|
|
7
|
+
(this && this.__createBinding) ||
|
|
8
|
+
(Object.create
|
|
9
|
+
? function (o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return m[k];
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}
|
|
22
|
+
: function (o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
});
|
|
26
|
+
var __setModuleDefault =
|
|
27
|
+
(this && this.__setModuleDefault) ||
|
|
28
|
+
(Object.create
|
|
29
|
+
? function (o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}
|
|
32
|
+
: function (o, v) {
|
|
33
|
+
o["default"] = v;
|
|
34
|
+
});
|
|
35
|
+
var __importStar =
|
|
36
|
+
(this && this.__importStar) ||
|
|
37
|
+
(function () {
|
|
38
|
+
var ownKeys = function (o) {
|
|
39
|
+
ownKeys =
|
|
40
|
+
Object.getOwnPropertyNames ||
|
|
41
|
+
function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.FileHandleWrapper = exports.FileUtils = void 0;
|
|
58
|
+
const fs_1 = require("fs");
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const errors_1 = require("../errors");
|
|
61
|
+
/**
|
|
62
|
+
* 文件操作工具类
|
|
63
|
+
* 提供静态方法用于文件系统操作
|
|
64
|
+
*/
|
|
65
|
+
class FileUtils {
|
|
66
|
+
/**
|
|
67
|
+
* 检查文件是否存在
|
|
68
|
+
* @param filePath 文件路径
|
|
69
|
+
*/
|
|
70
|
+
static async exists(filePath) {
|
|
71
|
+
try {
|
|
72
|
+
await fs_1.promises.access(filePath);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 确保目录存在,不存在则创建
|
|
80
|
+
* @param dirPath 目录路径
|
|
81
|
+
*/
|
|
82
|
+
static async ensureDir(dirPath) {
|
|
83
|
+
try {
|
|
84
|
+
await fs_1.promises.mkdir(dirPath, { recursive: true });
|
|
85
|
+
} catch (error) {
|
|
86
|
+
const err = error;
|
|
87
|
+
if (err.code !== "EEXIST") {
|
|
88
|
+
throw new errors_1.FileOperationError(`Failed to create directory: ${dirPath}`, dirPath, "mkdir");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 读取文件内容
|
|
94
|
+
* @param filePath 文件路径
|
|
95
|
+
*/
|
|
96
|
+
static async readFile(filePath) {
|
|
97
|
+
try {
|
|
98
|
+
return await fs_1.promises.readFile(filePath);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new errors_1.FileOperationError(`Failed to read file: ${filePath}`, filePath, "read");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 写入文件内容
|
|
105
|
+
* @param filePath 文件路径
|
|
106
|
+
* @param data 文件内容
|
|
107
|
+
*/
|
|
108
|
+
static async writeFile(filePath, data) {
|
|
109
|
+
try {
|
|
110
|
+
await fs_1.promises.writeFile(filePath, data);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw new errors_1.FileOperationError(`Failed to write file: ${filePath}`, filePath, "write");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 追加写入文件
|
|
117
|
+
* @param filePath 文件路径
|
|
118
|
+
* @param data 要追加的数据
|
|
119
|
+
*/
|
|
120
|
+
static async appendFile(filePath, data) {
|
|
121
|
+
try {
|
|
122
|
+
await fs_1.promises.appendFile(filePath, data);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw new errors_1.FileOperationError(`Failed to append to file: ${filePath}`, filePath, "append");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 删除文件
|
|
129
|
+
* @param filePath 文件路径
|
|
130
|
+
*/
|
|
131
|
+
static async deleteFile(filePath) {
|
|
132
|
+
try {
|
|
133
|
+
await fs_1.promises.unlink(filePath);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
const err = error;
|
|
136
|
+
if (err.code !== "ENOENT") {
|
|
137
|
+
throw new errors_1.FileOperationError(`Failed to delete file: ${filePath}`, filePath, "delete");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 原子性重命名文件
|
|
143
|
+
* @param oldPath 原文件路径
|
|
144
|
+
* @param newPath 新文件路径
|
|
145
|
+
*/
|
|
146
|
+
static async rename(oldPath, newPath) {
|
|
147
|
+
try {
|
|
148
|
+
await fs_1.promises.rename(oldPath, newPath);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
throw new errors_1.FileOperationError(`Failed to rename file from ${oldPath} to ${newPath}`, oldPath, "rename");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 获取文件大小
|
|
155
|
+
* @param filePath 文件路径
|
|
156
|
+
*/
|
|
157
|
+
static async getFileSize(filePath) {
|
|
158
|
+
try {
|
|
159
|
+
const stats = await fs_1.promises.stat(filePath);
|
|
160
|
+
return stats.size;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
throw new errors_1.FileOperationError(`Failed to get file size: ${filePath}`, filePath, "stat");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 同步文件到磁盘
|
|
167
|
+
* @param filePath 文件路径
|
|
168
|
+
*/
|
|
169
|
+
static async syncFile(filePath) {
|
|
170
|
+
let handle = null;
|
|
171
|
+
try {
|
|
172
|
+
handle = await fs_1.promises.open(filePath, "r+");
|
|
173
|
+
await handle.sync();
|
|
174
|
+
} catch (error) {
|
|
175
|
+
throw new errors_1.FileOperationError(`Failed to sync file: ${filePath}`, filePath, "sync");
|
|
176
|
+
} finally {
|
|
177
|
+
if (handle) {
|
|
178
|
+
await handle.close();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 打开文件句柄
|
|
184
|
+
* @param filePath 文件路径
|
|
185
|
+
* @param flags 打开标志
|
|
186
|
+
*/
|
|
187
|
+
static async openFile(filePath, flags) {
|
|
188
|
+
try {
|
|
189
|
+
return await fs_1.promises.open(filePath, flags);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
throw new errors_1.FileOperationError(`Failed to open file: ${filePath}`, filePath, "open");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 从指定位置读取文件
|
|
196
|
+
* @param handle 文件句柄
|
|
197
|
+
* @param buffer 目标缓冲区
|
|
198
|
+
* @param offset 缓冲区偏移
|
|
199
|
+
* @param length 读取长度
|
|
200
|
+
* @param position 文件位置
|
|
201
|
+
*/
|
|
202
|
+
static async readFromPosition(handle, buffer, offset, length, position) {
|
|
203
|
+
const result = await handle.read(buffer, offset, length, position);
|
|
204
|
+
return result.bytesRead;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 在指定位置写入文件
|
|
208
|
+
* @param handle 文件句柄
|
|
209
|
+
* @param buffer 源缓冲区
|
|
210
|
+
* @param offset 缓冲区偏移
|
|
211
|
+
* @param length 写入长度
|
|
212
|
+
* @param position 文件位置
|
|
213
|
+
*/
|
|
214
|
+
static async writeToPosition(handle, buffer, offset, length, position) {
|
|
215
|
+
const result = await handle.write(buffer, offset, length, position);
|
|
216
|
+
return result.bytesWritten;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 截断文件到指定大小
|
|
220
|
+
* @param filePath 文件路径
|
|
221
|
+
* @param size 目标大小
|
|
222
|
+
*/
|
|
223
|
+
static async truncateFile(filePath, size) {
|
|
224
|
+
try {
|
|
225
|
+
await fs_1.promises.truncate(filePath, size);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
throw new errors_1.FileOperationError(`Failed to truncate file: ${filePath}`, filePath, "truncate");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 构建完整文件路径
|
|
232
|
+
* @param basePath 基础路径
|
|
233
|
+
* @param name 文件名(不含扩展名)
|
|
234
|
+
* @param extension 文件扩展名
|
|
235
|
+
*/
|
|
236
|
+
static buildFilePath(basePath, name, extension) {
|
|
237
|
+
return path.join(basePath, name + extension);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 解析文件名(不含扩展名)
|
|
241
|
+
* @param filePath 文件路径
|
|
242
|
+
*/
|
|
243
|
+
static getFileName(filePath) {
|
|
244
|
+
const basename = path.basename(filePath);
|
|
245
|
+
const ext = path.extname(basename);
|
|
246
|
+
return basename.slice(0, basename.length - ext.length);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* 获取目录路径
|
|
250
|
+
* @param filePath 文件路径
|
|
251
|
+
*/
|
|
252
|
+
static getDirPath(filePath) {
|
|
253
|
+
return path.dirname(filePath);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
exports.FileUtils = FileUtils;
|
|
257
|
+
/**
|
|
258
|
+
* 文件句柄包装类
|
|
259
|
+
* 提供更高级的文件操作接口
|
|
260
|
+
*/
|
|
261
|
+
class FileHandleWrapper {
|
|
262
|
+
/**
|
|
263
|
+
* 创建文件句柄包装
|
|
264
|
+
* @param filePath 文件路径
|
|
265
|
+
* @param flags 打开标志
|
|
266
|
+
*/
|
|
267
|
+
constructor(filePath, flags) {
|
|
268
|
+
this.handle = null;
|
|
269
|
+
this.filePath = filePath;
|
|
270
|
+
this.flags = flags;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* 打开文件
|
|
274
|
+
*/
|
|
275
|
+
async open() {
|
|
276
|
+
this.handle = await FileUtils.openFile(this.filePath, this.flags);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* 关闭文件
|
|
280
|
+
*/
|
|
281
|
+
async close() {
|
|
282
|
+
if (this.handle) {
|
|
283
|
+
await this.handle.close();
|
|
284
|
+
this.handle = null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 确保文件已打开
|
|
289
|
+
*/
|
|
290
|
+
ensureOpen() {
|
|
291
|
+
if (!this.handle) {
|
|
292
|
+
throw new errors_1.FileOperationError("File handle is not open", this.filePath, "ensureOpen");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 读取数据
|
|
297
|
+
* @param buffer 目标缓冲区
|
|
298
|
+
* @param offset 缓冲区偏移
|
|
299
|
+
* @param length 读取长度
|
|
300
|
+
* @param position 文件位置
|
|
301
|
+
*/
|
|
302
|
+
async read(buffer, offset, length, position) {
|
|
303
|
+
this.ensureOpen();
|
|
304
|
+
return FileUtils.readFromPosition(this.handle, buffer, offset, length, position);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 写入数据
|
|
308
|
+
* @param buffer 源缓冲区
|
|
309
|
+
* @param offset 缓冲区偏移
|
|
310
|
+
* @param length 写入长度
|
|
311
|
+
* @param position 文件位置
|
|
312
|
+
*/
|
|
313
|
+
async write(buffer, offset, length, position) {
|
|
314
|
+
this.ensureOpen();
|
|
315
|
+
return FileUtils.writeToPosition(this.handle, buffer, offset, length, position);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 同步到磁盘
|
|
319
|
+
*/
|
|
320
|
+
async sync() {
|
|
321
|
+
this.ensureOpen();
|
|
322
|
+
await this.handle.sync();
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 获取文件大小
|
|
326
|
+
*/
|
|
327
|
+
async size() {
|
|
328
|
+
this.ensureOpen();
|
|
329
|
+
const stats = await this.handle.stat();
|
|
330
|
+
return stats.size;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 获取文件路径
|
|
334
|
+
*/
|
|
335
|
+
get path() {
|
|
336
|
+
return this.filePath;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 检查是否已打开
|
|
340
|
+
*/
|
|
341
|
+
get isOpen() {
|
|
342
|
+
return this.handle !== null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
exports.FileHandleWrapper = FileHandleWrapper;
|
|
346
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAoC;AACpC,2CAA6B;AAC7B,sCAA+C;AAE/C;;;GAGG;AACH,MAAa,SAAS;IAClB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAgB;QACvC,IAAI,CAAC;YACD,MAAM,aAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAe;QACzC,IAAI,CAAC;YACD,MAAM,aAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,KAA8B,CAAC;YAC3C,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxB,MAAM,IAAI,2BAAkB,CAAC,+BAA+B,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7F,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACzC,IA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,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 工具模块导出
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileHandleWrapper = exports.FileUtils = exports.BufferReader = exports.BufferWriter = exports.BinaryUtils = void 0;
|
|
7
|
+
var binary_1 = require("./binary");
|
|
8
|
+
Object.defineProperty(exports, "BinaryUtils", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return binary_1.BinaryUtils;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "BufferWriter", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return binary_1.BufferWriter;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "BufferReader", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return binary_1.BufferReader;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
var file_1 = require("./file");
|
|
27
|
+
Object.defineProperty(exports, "FileUtils", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return file_1.FileUtils;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "FileHandleWrapper", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return file_1.FileHandleWrapper;
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mCAAmE;AAA1D,qGAAA,WAAW,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,sGAAA,YAAY,OAAA;AAChD,+BAAsD;AAA7C,iGAAA,SAAS,OAAA;AAAE,yGAAA,iBAAiB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yydb/light-db",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "LightDB Storage Engine - A high-performance TypeScript database storage layer",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"database",
|
|
16
|
+
"storage-engine",
|
|
17
|
+
"wal",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
20
|
+
"license": "MPL-2.0",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=14.0.0"
|
|
23
|
+
},
|
|
24
|
+
"author": "LightDB Team",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/yy-database/LightDB.ts.git",
|
|
28
|
+
"directory": "projects/light-db"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^20.10.0",
|
|
35
|
+
"typescript": "^5.3.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# LightDB Storage Engine 🚀
|
|
2
|
+
|
|
3
|
+
A high-performance TypeScript database storage layer with WAL (Write-Ahead Logging), indexes, and transaction support.
|
|
4
|
+
|
|
5
|
+
## Features ✨
|
|
6
|
+
|
|
7
|
+
- **High Performance**: Optimized for speed with batch writing and columnar storage
|
|
8
|
+
- **Transaction Support**: ACID-compliant operations
|
|
9
|
+
- **Indexing**: B+ tree indexes for fast querying
|
|
10
|
+
- **Write-Ahead Logging**: Ensures data durability
|
|
11
|
+
- **Recovery**: Automatic recovery from crashes
|
|
12
|
+
- **Memory-Mapped Files**: Efficient I/O operations
|
|
13
|
+
- **TypeScript Ready**: Full TypeScript support with type definitions
|
|
14
|
+
|
|
15
|
+
## Installation 📦
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @yydb/light-db
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start 🚀
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { LightDB } from '@yydb/light-db';
|
|
25
|
+
|
|
26
|
+
// Initialize the database
|
|
27
|
+
const db = await LightDB.open('./mydb');
|
|
28
|
+
|
|
29
|
+
// Create a collection
|
|
30
|
+
const users = db.collection('users');
|
|
31
|
+
|
|
32
|
+
// Insert a document
|
|
33
|
+
await users.insert({ id: 1, name: 'John Doe', email: 'john@example.com' });
|
|
34
|
+
|
|
35
|
+
// Find a document
|
|
36
|
+
const user = await users.findOne({ id: 1 });
|
|
37
|
+
console.log(user); // { id: 1, name: 'John Doe', email: 'john@example.com' }
|
|
38
|
+
|
|
39
|
+
// Update a document
|
|
40
|
+
await users.update({ id: 1 }, { $set: { name: 'John Smith' } });
|
|
41
|
+
|
|
42
|
+
// Delete a document
|
|
43
|
+
await users.delete({ id: 1 });
|
|
44
|
+
|
|
45
|
+
// Close the database
|
|
46
|
+
await db.close();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API Reference 📚
|
|
50
|
+
|
|
51
|
+
### LightDB Class
|
|
52
|
+
|
|
53
|
+
#### `open(path: string): Promise<LightDB>`
|
|
54
|
+
Opens an existing database or creates a new one at the specified path.
|
|
55
|
+
|
|
56
|
+
#### `collection(name: string): Collection`
|
|
57
|
+
Returns a collection with the given name. Creates it if it doesn't exist.
|
|
58
|
+
|
|
59
|
+
#### `transaction(): Promise<Transaction>`
|
|
60
|
+
Starts a new transaction.
|
|
61
|
+
|
|
62
|
+
#### `close(): Promise<void>`
|
|
63
|
+
Closes the database connection.
|
|
64
|
+
|
|
65
|
+
### Collection Class
|
|
66
|
+
|
|
67
|
+
#### `insert(document: Document): Promise<void>`
|
|
68
|
+
Inserts a new document into the collection.
|
|
69
|
+
|
|
70
|
+
#### `find(query: Query): Promise<Document[]>`
|
|
71
|
+
Finds all documents matching the query.
|
|
72
|
+
|
|
73
|
+
#### `findOne(query: Query): Promise<Document | null>`
|
|
74
|
+
Finds the first document matching the query.
|
|
75
|
+
|
|
76
|
+
#### `update(query: Query, update: Update): Promise<number>`
|
|
77
|
+
Updates documents matching the query and returns the number of updated documents.
|
|
78
|
+
|
|
79
|
+
#### `delete(query: Query): Promise<number>`
|
|
80
|
+
Deletes documents matching the query and returns the number of deleted documents.
|
|
81
|
+
|
|
82
|
+
#### `createIndex(field: string): Promise<void>`
|
|
83
|
+
Creates an index on the specified field for faster queries.
|
|
84
|
+
|
|
85
|
+
### Transaction Class
|
|
86
|
+
|
|
87
|
+
#### `commit(): Promise<void>`
|
|
88
|
+
Commits the transaction.
|
|
89
|
+
|
|
90
|
+
#### `rollback(): Promise<void>`
|
|
91
|
+
Rolls back the transaction.
|
|
92
|
+
|
|
93
|
+
## Performance Features ⚡
|
|
94
|
+
|
|
95
|
+
### Batch Writing
|
|
96
|
+
LightDB uses batch writing to optimize disk I/O operations, significantly improving write performance for bulk operations.
|
|
97
|
+
|
|
98
|
+
### Columnar Storage
|
|
99
|
+
For certain data types, LightDB uses columnar storage to reduce disk space and improve query performance.
|
|
100
|
+
|
|
101
|
+
### Memory-Mapped Files
|
|
102
|
+
LightDB uses memory-mapped files for efficient I/O operations, reducing the overhead of traditional file I/O.
|
|
103
|
+
|
|
104
|
+
## Architecture 🏗️
|
|
105
|
+
|
|
106
|
+
LightDB consists of several key components:
|
|
107
|
+
|
|
108
|
+
1. **Storage Engine**: Manages the physical storage of data
|
|
109
|
+
2. **WAL (Write-Ahead Log)**: Ensures data durability and supports recovery
|
|
110
|
+
3. **Index Manager**: Manages B+ tree indexes for fast querying
|
|
111
|
+
4. **Collection Layer**: Provides a document-oriented API
|
|
112
|
+
5. **Transaction Manager**: Handles ACID-compliant transactions
|
|
113
|
+
|
|
114
|
+
## Recovery 🔄
|
|
115
|
+
|
|
116
|
+
LightDB automatically recovers from crashes using the WAL. When the database is opened after a crash, it replays the WAL to restore the database to a consistent state.
|
|
117
|
+
|
|
118
|
+
## Contributing 🤝
|
|
119
|
+
|
|
120
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
121
|
+
|
|
122
|
+
## License 📄
|
|
123
|
+
|
|
124
|
+
LightDB is licensed under the MPL-2.0 License. See the [LICENSE](LICENSE) file for details.
|