fix: 修复 CI 卡死 + LZ4/SSTable/Checkpoint 多项 bug — 526 测试全通过
This commit is contained in:
Vendored
+12
-8
@@ -1764,8 +1764,8 @@ class SSTableReader {
|
||||
// 查询
|
||||
// -----------------------------------------------------------------------
|
||||
/** 精确查找 key */
|
||||
get(key) {
|
||||
const blockIdx = this.locateBlock(key);
|
||||
get(targetKey) {
|
||||
const blockIdx = this.locateBlock(targetKey);
|
||||
if (blockIdx < 0)
|
||||
return null;
|
||||
const entry = this.indexEntries[blockIdx];
|
||||
@@ -1773,8 +1773,7 @@ class SSTableReader {
|
||||
const blockView = new DataView(blockData.buffer, blockData.byteOffset, blockData.byteLength);
|
||||
const entryCount = blockView.getUint32(0, false);
|
||||
let offset = 4;
|
||||
// 二分查找 block 内的 key
|
||||
// 为简单起见,这里使用顺序扫描(生产中应二分查找)
|
||||
// 顺序扫描 block 内的条目(生产中应二分查找)
|
||||
for (let i = 0; i < entryCount; i++) {
|
||||
const keyLen = blockView.getUint16(offset, false);
|
||||
offset += 2;
|
||||
@@ -1784,8 +1783,13 @@ class SSTableReader {
|
||||
offset += 2;
|
||||
const valBytes = blockData.slice(offset, offset + valLen);
|
||||
offset += valLen;
|
||||
if (key === key) {
|
||||
return JSON.parse(new TextDecoder().decode(valBytes));
|
||||
if (key === targetKey) {
|
||||
try {
|
||||
return JSON.parse(new TextDecoder().decode(valBytes));
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -2293,8 +2297,8 @@ class LSM {
|
||||
this.freezeMemtable();
|
||||
this.flushImmutableSync();
|
||||
}
|
||||
// 等待存储完成
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
// 确保所有微任务完成(不使用 setTimeout,避免额外 timer 阻止进程退出)
|
||||
await Promise.resolve();
|
||||
}
|
||||
async clear() {
|
||||
this.memtable.clear();
|
||||
|
||||
Reference in New Issue
Block a user