Open way modify

This commit is contained in:
Eli-Class
2026-02-03 06:39:46 +00:00
parent 9eb4b17b34
commit 00635bdb67
7 changed files with 61 additions and 21 deletions

View File

@@ -117,6 +117,7 @@ export class DataWriter<T> {
this.currentOffset += BigInt(buf.length);
++this.recordCount;
this.writeHeader();
return this.latestSequence;
}
@@ -149,8 +150,11 @@ export class DataWriter<T> {
return this.latestSequence;
}
getNextSequence(): number {
return this.latestSequence + 1;
writeHeader(): void {
if (this.fd === null || !this.headerBuf) return;
DataProtocol.updateHeader(this.headerBuf, this.currentOffset, this.recordCount);
fs.writeSync(this.fd, this.headerBuf, 0, DATA_HEADER_SIZE, 0);
}
sync(): void {
@@ -159,8 +163,6 @@ export class DataWriter<T> {
DataProtocol.updateHeader(this.headerBuf, this.currentOffset, this.recordCount);
fs.writeSync(this.fd, this.headerBuf, 0, DATA_HEADER_SIZE, 0);
fs.fsyncSync(this.fd);
this.indexWriter.syncAll();
}
close(): void {
@@ -175,6 +177,10 @@ export class DataWriter<T> {
this.headerBuf = null;
}
writeFlags(flags: number): void {
this.indexWriter.writeFlags(flags);
}
getStats() {
return {
dataPath: this.dataPath,