SYNC: Merge branch 'feature/dblogs'

This commit is contained in:
SPRINX0\prochazka
2025-08-06 12:34:25 +02:00
committed by Diflow
parent 4ed437fd4e
commit ed7605eccd
15 changed files with 241 additions and 153 deletions

View File

@@ -12,10 +12,9 @@ const { jsldir } = require('./directories');
const LineReader = require('./LineReader');
class JsonLinesDatastore {
constructor(file, formatterFunction, resolveNextFile = null) {
constructor(file, formatterFunction) {
this.file = file;
this.formatterFunction = formatterFunction;
this.resolveNextFile = resolveNextFile;
this.reader = null;
this.readedDataRowCount = 0;
this.readedSchemaRow = false;
@@ -23,12 +22,10 @@ class JsonLinesDatastore {
this.notifyChangedCallback = null;
this.currentFilter = null;
this.currentSort = null;
this.currentFileName = null;
if (formatterFunction) {
const requirePluginFunction = require('./requirePluginFunction');
this.rowFormatter = requirePluginFunction(formatterFunction);
}
this.sortedFiles = {};
}
@@ -72,7 +69,6 @@ class JsonLinesDatastore {
// this.firstRowToBeReturned = null;
this.currentFilter = null;
this.currentSort = null;
this.currentFileName = null;
await reader.close();
}
@@ -106,18 +102,8 @@ class JsonLinesDatastore {
// return res;
// }
for (;;) {
let line = await this.reader.readLine();
while (!line) {
if (!this.currentSort && this.resolveNextFile) {
const nextFile = await this.resolveNextFile(this.currentFileName);
if (nextFile) {
await this.reader.close();
this.reader = await this._openReader(nextFile);
this.currentFileName = nextFile;
line = await this.reader.readLine();
continue;
}
}
const line = await this.reader.readLine();
if (!line) {
// EOF
return null;
}
@@ -189,7 +175,6 @@ class JsonLinesDatastore {
}
if (!this.reader) {
const reader = await this._openReader(sort ? this.sortedFiles[stableStringify(sort)] : this.file);
this.currentFileName = this.file;
this.reader = reader;
this.currentFilter = filter;
this.currentSort = sort;