querysub 0.374.0 → 0.376.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/package.json +2 -4
- package/src/deployManager/components/MachineDetailPage.tsx +2 -5
- package/src/deployManager/components/ServiceDetailPage.tsx +2 -5
- package/src/deployManager/machineApplyMainCode.ts +7 -0
- package/src/diagnostics/NodeViewer.tsx +4 -5
- package/src/diagnostics/logs/IndexedLogs/BufferIndex.ts +10 -5
- package/src/diagnostics/logs/IndexedLogs/BufferIndexCPP.cpp +20 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexHelpers.ts +29 -2
- package/src/diagnostics/logs/IndexedLogs/BufferUnitIndex.ts +61 -20
- package/src/diagnostics/logs/IndexedLogs/BufferUnitSet.ts +2 -2
- package/src/diagnostics/logs/IndexedLogs/IndexedLogs.ts +7 -7
- package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +250 -243
- package/src/diagnostics/logs/IndexedLogs/LogViewerParams.ts +21 -0
- package/src/diagnostics/logs/IndexedLogs/{bufferMatcher.ts → bufferSearchFindMatcher.ts} +9 -4
- package/src/diagnostics/logs/IndexedLogs/moveIndexLogsToPublic.ts +3 -3
- package/src/diagnostics/logs/diskLogger.ts +0 -38
- package/src/diagnostics/logs/errorNotifications2/errorNotifications2.ts +9 -0
- package/src/diagnostics/logs/injectFileLocationToConsole.ts +3 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycles.tsx +24 -22
- package/src/diagnostics/managementPages.tsx +0 -18
- package/test.ts +0 -5
- package/bin/error-email.js +0 -8
- package/bin/error-im.js +0 -8
- package/src/diagnostics/logs/FastArchiveAppendable.ts +0 -843
- package/src/diagnostics/logs/FastArchiveController.ts +0 -573
- package/src/diagnostics/logs/FastArchiveViewer.tsx +0 -1090
- package/src/diagnostics/logs/LogViewer2.tsx +0 -552
- package/src/diagnostics/logs/errorNotifications/ErrorDigestPage.tsx +0 -409
- package/src/diagnostics/logs/errorNotifications/ErrorNotificationController.ts +0 -756
- package/src/diagnostics/logs/errorNotifications/ErrorSuppressionUI.tsx +0 -280
- package/src/diagnostics/logs/errorNotifications/ErrorWarning.tsx +0 -254
- package/src/diagnostics/logs/errorNotifications/errorDigestEmail.tsx +0 -233
- package/src/diagnostics/logs/errorNotifications/errorDigestEntry.tsx +0 -14
- package/src/diagnostics/logs/errorNotifications/errorDigests.tsx +0 -292
- package/src/diagnostics/logs/errorNotifications/errorWatchEntry.tsx +0 -209
- package/src/diagnostics/logs/importLogsEntry.ts +0 -38
- package/src/diagnostics/logs/lifeCycleAnalysis/LifeCyclePages.tsx +0 -150
- package/src/diagnostics/logs/logViewerExtractField.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "querysub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.376.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
|
|
@@ -34,9 +34,7 @@
|
|
|
34
34
|
"join": "./bin/join.js",
|
|
35
35
|
"join-public": "./bin/join-public.js",
|
|
36
36
|
"movelogs": "./bin/movelogs.js",
|
|
37
|
-
"addsuperuser": "./bin/addsuperuser.js"
|
|
38
|
-
"error-email": "./bin/error-email.js",
|
|
39
|
-
"error-im": "./bin/error-im.js"
|
|
37
|
+
"addsuperuser": "./bin/addsuperuser.js"
|
|
40
38
|
},
|
|
41
39
|
"dependencies": {
|
|
42
40
|
"@types/fs-ext": "^2.0.3",
|
|
@@ -7,10 +7,10 @@ import { formatNumber, formatVeryNiceDateTime } from "socket-function/src/format
|
|
|
7
7
|
import { sort } from "socket-function/src/misc";
|
|
8
8
|
import { ATag, Anchor } from "../../library-components/ATag";
|
|
9
9
|
import { ShowMore } from "../../library-components/ShowMore";
|
|
10
|
-
import { filterParam } from "../../diagnostics/logs/FastArchiveViewer";
|
|
11
10
|
import { managementPageURL } from "../../diagnostics/managementPages";
|
|
12
11
|
import { t } from "../../2-proxy/schema2";
|
|
13
12
|
import { Querysub } from "../../4-querysub/QuerysubController";
|
|
13
|
+
import { getLogViewerParams } from "../../diagnostics/logs/IndexedLogs/LogViewerParams";
|
|
14
14
|
|
|
15
15
|
export class MachineDetailPage extends qreact.Component {
|
|
16
16
|
render() {
|
|
@@ -105,10 +105,7 @@ export class MachineDetailPage extends qreact.Component {
|
|
|
105
105
|
<div>
|
|
106
106
|
Apply Node ID: {machine.applyNodeId}
|
|
107
107
|
</div>
|
|
108
|
-
<ATag values={
|
|
109
|
-
managementPageURL.getOverride("LogViewer2"),
|
|
110
|
-
filterParam.getOverride(`__machineId = ${machineInfo.machineId}`),
|
|
111
|
-
]}>
|
|
108
|
+
<ATag values={getLogViewerParams({ __machineId: machineInfo.machineId })}>
|
|
112
109
|
Machine Logs
|
|
113
110
|
</ATag>
|
|
114
111
|
</div>
|
|
@@ -20,8 +20,8 @@ import { PrimitiveDisplay } from "../../diagnostics/logs/ObjectDisplay";
|
|
|
20
20
|
import { parseAnsiColors, rgbToHsl } from "../../diagnostics/logs/ansiFormat";
|
|
21
21
|
import { RenderGitRefInfo, UpdateServiceButtons, bigEmoji, buttonStyle } from "./deployButtons";
|
|
22
22
|
import { TypedConfigEditor } from "../../library-components/TypedConfigEditor";
|
|
23
|
-
import { filterParam } from "../../diagnostics/logs/FastArchiveViewer";
|
|
24
23
|
import { managementPageURL } from "../../diagnostics/managementPages";
|
|
24
|
+
import { getLogViewerParams } from "../../diagnostics/logs/IndexedLogs/LogViewerParams";
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
@@ -401,10 +401,7 @@ export class ServiceDetailPage extends qreact.Component {
|
|
|
401
401
|
{isWatching ? "Stop Watching Output" : "Watch Screen Output"}
|
|
402
402
|
</div>
|
|
403
403
|
|
|
404
|
-
<ATag values={
|
|
405
|
-
managementPageURL.getOverride("LogViewer2"),
|
|
406
|
-
filterParam.getOverride(`__machineId = ${machineId}`),
|
|
407
|
-
]}>
|
|
404
|
+
<ATag values={getLogViewerParams({ __machineId: machineId })}>
|
|
408
405
|
Machine Logs
|
|
409
406
|
</ATag>
|
|
410
407
|
</div>
|
|
@@ -866,6 +866,13 @@ export async function machineApplyMain() {
|
|
|
866
866
|
if (await quickIsOutdated()) {
|
|
867
867
|
console.log(magenta("Likely outdated, resyncing now"));
|
|
868
868
|
await resyncServices();
|
|
869
|
+
} else {
|
|
870
|
+
let config = await machineInfos.get(getOwnMachineId());
|
|
871
|
+
if (config) {
|
|
872
|
+
config.heartbeat = Date.now();
|
|
873
|
+
console.log(magenta(`Updating heartbeat for ${getOwnMachineId()} to ${config.heartbeat}`));
|
|
874
|
+
await machineInfos.set(getOwnMachineId(), config);
|
|
875
|
+
}
|
|
869
876
|
}
|
|
870
877
|
});
|
|
871
878
|
|
|
@@ -36,8 +36,8 @@ import { SocketRegistered } from "socket-function/SocketFunctionTypes";
|
|
|
36
36
|
import { ATag } from "../library-components/ATag";
|
|
37
37
|
import { getSyncedController } from "../library-components/SyncedController";
|
|
38
38
|
import child_process from "child_process";
|
|
39
|
-
import { filterParam } from "./logs/FastArchiveViewer";
|
|
40
39
|
import { getHTTPSKeyCert } from "../-e-certs/certAuthority";
|
|
40
|
+
import { getLogViewerParams } from "./logs/IndexedLogs/LogViewerParams";
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
type NodeData = {
|
|
@@ -296,10 +296,9 @@ export class NodeViewer extends qreact.Component {
|
|
|
296
296
|
if (str.startsWith("http")) return formatValue(obj);
|
|
297
297
|
|
|
298
298
|
return (
|
|
299
|
-
<ATag values={
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
]}>
|
|
299
|
+
<ATag values={getLogViewerParams({
|
|
300
|
+
__nodeId: str,
|
|
301
|
+
})}>
|
|
303
302
|
Logs
|
|
304
303
|
</ATag>
|
|
305
304
|
);
|
|
@@ -10,7 +10,7 @@ import { measureBlock, measureFnc, measureWrap } from "socket-function/src/profi
|
|
|
10
10
|
import { formatNumber, formatTime } from "socket-function/src/formatting/format";
|
|
11
11
|
import { magenta, yellow } from "socket-function/src/formatting/logColors";
|
|
12
12
|
import { Unit, getAllUnits, Reader, createOffsetReader, SearchParams, IndexedLogResults } from "./BufferIndexHelpers";
|
|
13
|
-
import { createMatchesPattern, getSearchUnits } from "./
|
|
13
|
+
import { createMatchesPattern, getSearchUnits } from "./bufferSearchFindMatcher";
|
|
14
14
|
import { UnitSet } from "./BufferUnitSet";
|
|
15
15
|
import { BufferUnitIndex } from "./BufferUnitIndex";
|
|
16
16
|
import { BufferListStreamer } from "./BufferListStreamer";
|
|
@@ -178,13 +178,13 @@ export class BufferIndex {
|
|
|
178
178
|
|
|
179
179
|
// IMPORTANT! The input data values should be sorted from newest to oldest.
|
|
180
180
|
@measureFnc
|
|
181
|
-
public static encodeAll(config: {
|
|
181
|
+
public static async encodeAll(config: {
|
|
182
182
|
data: Buffer[];
|
|
183
|
-
}): {
|
|
183
|
+
}): Promise<{
|
|
184
184
|
data: Buffer;
|
|
185
185
|
index: Buffer;
|
|
186
|
-
} {
|
|
187
|
-
let obj = BufferUnitIndex.encode(config.data, {
|
|
186
|
+
}> {
|
|
187
|
+
let obj = await BufferUnitIndex.encode(config.data, {
|
|
188
188
|
type: BULK_TYPE,
|
|
189
189
|
});
|
|
190
190
|
return {
|
|
@@ -453,6 +453,11 @@ export class BufferIndex {
|
|
|
453
453
|
results.remoteIndexesSearched += 1;
|
|
454
454
|
results.remoteIndexSize += index.length;
|
|
455
455
|
} else {
|
|
456
|
+
let dataLength = await dataReader.getLength();
|
|
457
|
+
if (dataLength < 32) {
|
|
458
|
+
// If it's a small file, nothing of value will be lost by ignoring it. And almost all of our errors are coming from extremely small files.
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
456
461
|
throw new Error(`Unknown type in index file: ${type}`);
|
|
457
462
|
}
|
|
458
463
|
}
|
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
#include <string.h>
|
|
4
4
|
#include <algorithm>
|
|
5
5
|
|
|
6
|
+
static uint32_t RemapUnit(uint32_t unit) {
|
|
7
|
+
uint8_t byte0 = (unit >> 0) & 0xFF;
|
|
8
|
+
uint8_t byte1 = (unit >> 8) & 0xFF;
|
|
9
|
+
uint8_t byte2 = (unit >> 16) & 0xFF;
|
|
10
|
+
uint8_t byte3 = (unit >> 24) & 0xFF;
|
|
11
|
+
|
|
12
|
+
if (byte0 >= 65 && byte0 <= 90) byte0 += 32;
|
|
13
|
+
if (byte1 >= 65 && byte1 <= 90) byte1 += 32;
|
|
14
|
+
if (byte2 >= 65 && byte2 <= 90) byte2 += 32;
|
|
15
|
+
if (byte3 >= 65 && byte3 <= 90) byte3 += 32;
|
|
16
|
+
|
|
17
|
+
return byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
static napi_value PopulateUnits(napi_env env, napi_callback_info info) {
|
|
7
21
|
size_t argc = 2;
|
|
8
22
|
napi_value args[2];
|
|
@@ -75,6 +89,8 @@ static napi_value PopulateUnits(napi_env env, napi_callback_info info) {
|
|
|
75
89
|
(bufferData[i+2] << 16) |
|
|
76
90
|
(bufferData[i+3] << 24);
|
|
77
91
|
|
|
92
|
+
unit = RemapUnit(unit);
|
|
93
|
+
|
|
78
94
|
if (unit == 0) continue;
|
|
79
95
|
|
|
80
96
|
unitsArray[currentOffset] = unit;
|
|
@@ -184,6 +200,8 @@ static napi_value BuildHashTable(napi_env env, napi_callback_info info) {
|
|
|
184
200
|
// This reads 4 bytes starting at position i
|
|
185
201
|
uint32_t unit = *(uint32_t*)(blockData + i);
|
|
186
202
|
|
|
203
|
+
unit = RemapUnit(unit);
|
|
204
|
+
|
|
187
205
|
uint32_t maskedHash = GetMaskedHash(unit, mask);
|
|
188
206
|
uint32_t currentHead = hashTable[maskedHash];
|
|
189
207
|
|
|
@@ -291,6 +309,8 @@ static napi_value EstimateUniqueUnits(napi_env env, napi_callback_info info) {
|
|
|
291
309
|
// Read unit directly by casting pointer (little-endian architecture)
|
|
292
310
|
uint32_t unit = *(uint32_t*)(bufferData + i);
|
|
293
311
|
|
|
312
|
+
unit = RemapUnit(unit);
|
|
313
|
+
|
|
294
314
|
// Get masked hash with 0xFFFF mask (16-bit)
|
|
295
315
|
uint32_t maskedHash = GetMaskedHash(unit, 0xFFFF);
|
|
296
316
|
|
|
@@ -16,7 +16,7 @@ export type SearchParams = {
|
|
|
16
16
|
findBuffer: Buffer;
|
|
17
17
|
pathOverrides?: TimeFilePathWithSize[];
|
|
18
18
|
only?: "local" | "public";
|
|
19
|
-
|
|
19
|
+
forceReadProduction?: boolean;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type Unit = number;
|
|
@@ -57,6 +57,33 @@ export function createOffsetReader(reader: Reader, offset: number): Reader {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export function remapUnit(unit: Unit): Unit {
|
|
61
|
+
let byte0 = (unit >> 0) & 0xFF;
|
|
62
|
+
let byte1 = (unit >> 8) & 0xFF;
|
|
63
|
+
let byte2 = (unit >> 16) & 0xFF;
|
|
64
|
+
let byte3 = (unit >> 24) & 0xFF;
|
|
65
|
+
|
|
66
|
+
if (byte0 >= 65 && byte0 <= 90) byte0 += 32;
|
|
67
|
+
if (byte1 >= 65 && byte1 <= 90) byte1 += 32;
|
|
68
|
+
if (byte2 >= 65 && byte2 <= 90) byte2 += 32;
|
|
69
|
+
if (byte3 >= 65 && byte3 <= 90) byte3 += 32;
|
|
70
|
+
|
|
71
|
+
return (byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24)) >>> 0;
|
|
72
|
+
}
|
|
73
|
+
export function remapSearchBuffer(buffer: Buffer) {
|
|
74
|
+
let newBuffer = Buffer.alloc(buffer.length);
|
|
75
|
+
buffer.copy(newBuffer);
|
|
76
|
+
buffer = newBuffer;
|
|
77
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
78
|
+
let byte = buffer[i];
|
|
79
|
+
if (byte >= 65 && byte <= 90) {
|
|
80
|
+
buffer[i] = byte + 32;
|
|
81
|
+
} else {
|
|
82
|
+
buffer[i] = byte;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return buffer;
|
|
86
|
+
}
|
|
60
87
|
|
|
61
88
|
export const getAllUnits = measureWrap(function getAllUnits(config: {
|
|
62
89
|
buffer: Buffer;
|
|
@@ -71,7 +98,7 @@ export const getAllUnits = measureWrap(function getAllUnits(config: {
|
|
|
71
98
|
const result: UnitRef[] = [];
|
|
72
99
|
// For each byte position, create a unit from that position and the next 3 bytes
|
|
73
100
|
for (let i = 0; i <= buffer.length - 4; i++) {
|
|
74
|
-
const unit = buffer.readUint32LE(i);
|
|
101
|
+
const unit = remapUnit(buffer.readUint32LE(i));
|
|
75
102
|
if (!unit) continue;
|
|
76
103
|
|
|
77
104
|
result.push({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { LZ4 } from "../../../storage/LZ4";
|
|
4
4
|
import { measureBlock, measureFnc } from "socket-function/src/profiling/measure";
|
|
5
5
|
import { Zip } from "../../../zip";
|
|
6
|
-
import { BufferReader, Reader, SearchParams, IndexedLogResults, Unit } from "./BufferIndexHelpers";
|
|
6
|
+
import { BufferReader, Reader, SearchParams, IndexedLogResults, Unit, remapUnit } from "./BufferIndexHelpers";
|
|
7
7
|
import { formatNumber, formatPercent } from "socket-function/src/formatting/format";
|
|
8
8
|
import { lazy } from "socket-function/src/caching";
|
|
9
9
|
import { list, sort } from "socket-function/src/misc";
|
|
@@ -11,23 +11,64 @@ import { testDisableCache } from "../../../-a-archives/archivesMemoryCache";
|
|
|
11
11
|
import { devDebugbreak } from "../../../config";
|
|
12
12
|
import { BufferUnitIndexParallelSearchCount, DEFAULT_BLOCK_SIZE, DEFAULT_TARGET_UNITS_PER_BUCKET } from "./BufferIndexLogsOptimizationConstants";
|
|
13
13
|
import { runInParallel } from "socket-function/src/batching";
|
|
14
|
-
import { createMatchesPattern } from "./
|
|
14
|
+
import { createMatchesPattern } from "./bufferSearchFindMatcher";
|
|
15
|
+
import * as path from "path";
|
|
16
|
+
import * as fs from "fs";
|
|
17
|
+
import { runPromise } from "socket-function/src/runPromise";
|
|
18
|
+
import * as crypto from "crypto";
|
|
15
19
|
|
|
16
20
|
const USE_COMPRESSION = true;
|
|
17
21
|
|
|
22
|
+
const getCppAddon = lazy(async () => {
|
|
23
|
+
if (typeof process === "undefined" || !process.versions || !process.versions.node) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const checkNeedsBuild = (): boolean => {
|
|
28
|
+
const cppFilePath = path.join(__dirname, "BufferIndexCPP.cpp");
|
|
29
|
+
const distPath = path.join(__dirname, "dist");
|
|
30
|
+
const versionFilePath = path.join(distPath, "BufferIndexCPP.version");
|
|
31
|
+
const buildPath = path.join(__dirname, "build");
|
|
32
|
+
|
|
33
|
+
if (!fs.existsSync(buildPath)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (!fs.existsSync(versionFilePath)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const cppFileContent = fs.readFileSync(cppFilePath, "utf-8");
|
|
41
|
+
const currentHash = crypto.createHash("sha256").update(cppFileContent).digest("hex");
|
|
42
|
+
const storedHash = fs.readFileSync(versionFilePath, "utf-8").trim();
|
|
43
|
+
if (storedHash !== currentHash) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (checkNeedsBuild()) {
|
|
53
|
+
try {
|
|
54
|
+
await runPromise("node-gyp rebuild");
|
|
55
|
+
const cppFilePath = path.join(__dirname, "BufferIndexCPP.cpp");
|
|
56
|
+
const distPath = path.join(__dirname, "dist");
|
|
57
|
+
const versionFilePath = path.join(distPath, "BufferIndexCPP.version");
|
|
58
|
+
if (!fs.existsSync(distPath)) {
|
|
59
|
+
fs.mkdirSync(distPath, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
const cppFileContent = fs.readFileSync(cppFilePath, "utf-8");
|
|
62
|
+
const currentHash = crypto.createHash("sha256").update(cppFileContent).digest("hex");
|
|
63
|
+
fs.writeFileSync(versionFilePath, currentHash);
|
|
64
|
+
} catch (e) {
|
|
24
65
|
return undefined;
|
|
25
66
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
return require("./BufferIndexCPP") as typeof import("./BufferIndexCPP");
|
|
29
71
|
} catch (e) {
|
|
30
|
-
console.warn("C++ addon not available, falling back to TypeScript implementation", e);
|
|
31
72
|
return undefined;
|
|
32
73
|
}
|
|
33
74
|
});
|
|
@@ -107,14 +148,14 @@ export class BufferUnitIndex {
|
|
|
107
148
|
|
|
108
149
|
// IMPORTANT! The input data values should be sorted from newest to oldest.
|
|
109
150
|
@measureFnc
|
|
110
|
-
public static encode(allData: Buffer[], options: {
|
|
151
|
+
public static async encode(allData: Buffer[], options: {
|
|
111
152
|
type: number;
|
|
112
153
|
blockSize?: number;
|
|
113
154
|
targetUnitsPerBucket?: number;
|
|
114
|
-
}): {
|
|
155
|
+
}): Promise<{
|
|
115
156
|
blocks: Buffer;
|
|
116
157
|
index: Buffer;
|
|
117
|
-
} {
|
|
158
|
+
}> {
|
|
118
159
|
const type = options.type;
|
|
119
160
|
const BLOCK_SIZE = options.blockSize ?? DEFAULT_BLOCK_SIZE;
|
|
120
161
|
const TARGET_UNITS_PER_BUCKET = options.targetUnitsPerBucket ?? DEFAULT_TARGET_UNITS_PER_BUCKET;
|
|
@@ -199,8 +240,8 @@ export class BufferUnitIndex {
|
|
|
199
240
|
return Buffer.concat([blocksHeaderBuffer, ...compressedBlocks]);
|
|
200
241
|
}, `createFinalBlocksBuffer`);
|
|
201
242
|
|
|
202
|
-
const estimatedUniqueUnits = measureBlock(() => {
|
|
203
|
-
const cppAddon = getCppAddon();
|
|
243
|
+
const estimatedUniqueUnits = await measureBlock(async () => {
|
|
244
|
+
const cppAddon = await getCppAddon();
|
|
204
245
|
if (cppAddon) {
|
|
205
246
|
// Use C++ addon for performance
|
|
206
247
|
return cppAddon.estimateUniqueUnits(allData);
|
|
@@ -213,7 +254,7 @@ export class BufferUnitIndex {
|
|
|
213
254
|
|
|
214
255
|
for (const buffer of allData) {
|
|
215
256
|
for (let i = 0; i <= buffer.length - 4; i++) {
|
|
216
|
-
const unit = buffer.readUint32LE(i);
|
|
257
|
+
const unit = remapUnit(buffer.readUint32LE(i));
|
|
217
258
|
const maskedHash = getMaskedHash(unit, 0xFFFF);
|
|
218
259
|
|
|
219
260
|
if (seenMaskedHashes[maskedHash] === 0) {
|
|
@@ -251,8 +292,8 @@ export class BufferUnitIndex {
|
|
|
251
292
|
|
|
252
293
|
|
|
253
294
|
// Step 4: Build hash table with linked lists using Uint32Arrays for performance
|
|
254
|
-
const { hashTable, linkedListData, nodeCount, filledSlots } = measureBlock(() => {
|
|
255
|
-
const cppAddon = getCppAddon();
|
|
295
|
+
const { hashTable, linkedListData, nodeCount, filledSlots } = await measureBlock(async () => {
|
|
296
|
+
const cppAddon = await getCppAddon();
|
|
256
297
|
if (cppAddon) {
|
|
257
298
|
// Use C++ addon for performance
|
|
258
299
|
return cppAddon.buildHashTable(blocksUncompressed, hashTableCapacity, mask);
|
|
@@ -298,7 +339,7 @@ export class BufferUnitIndex {
|
|
|
298
339
|
|
|
299
340
|
// Iterate through all units and add them directly
|
|
300
341
|
for (let i = 0; i <= blockUncompressed.length - 4; i++) {
|
|
301
|
-
const unit = blockUncompressed.readUint32LE(i);
|
|
342
|
+
const unit = remapUnit(blockUncompressed.readUint32LE(i));
|
|
302
343
|
const maskedHash = getMaskedHash(unit, mask);
|
|
303
344
|
|
|
304
345
|
const currentHead = hashTable[maskedHash];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatPercent, formatNumber } from "socket-function/src/formatting/format";
|
|
2
2
|
import { red } from "socket-function/src/formatting/logColors";
|
|
3
3
|
import { measureFnc } from "socket-function/src/profiling/measure";
|
|
4
|
-
import { Unit } from "./BufferIndexHelpers";
|
|
4
|
+
import { Unit, remapUnit } from "./BufferIndexHelpers";
|
|
5
5
|
|
|
6
6
|
export class UnitSet {
|
|
7
7
|
// Hash-based set for checking unit membership (no positions stored)
|
|
@@ -58,7 +58,7 @@ export class UnitSet {
|
|
|
58
58
|
const buffer = block[bufferIndex];
|
|
59
59
|
// Extract units directly
|
|
60
60
|
for (let i = 0; i <= buffer.length - 4; i++) {
|
|
61
|
-
const unit = buffer.readUint32LE(i);
|
|
61
|
+
const unit = remapUnit(buffer.readUint32LE(i));
|
|
62
62
|
if (!unit) continue;
|
|
63
63
|
|
|
64
64
|
totalInserts++;
|
|
@@ -272,10 +272,10 @@ export class IndexedLogs<T> {
|
|
|
272
272
|
startTime: number;
|
|
273
273
|
endTime: number;
|
|
274
274
|
only?: "local" | "public";
|
|
275
|
-
|
|
275
|
+
forceReadProduction?: boolean;
|
|
276
276
|
}): Promise<TimeFilePathWithSize[]> {
|
|
277
277
|
let finalPaths: TimeFilePathWithSize[] = [];
|
|
278
|
-
if (config.
|
|
278
|
+
if (config.forceReadProduction && !isPublic()) {
|
|
279
279
|
let machineNodes = await this.getMachineNodes();
|
|
280
280
|
if (machineNodes.length === 0) throw new Error(`Cannot find any public nodes to read from`);
|
|
281
281
|
return await IndexedLogShimController.nodes[machineNodes[0]].getPaths({
|
|
@@ -352,7 +352,7 @@ export class IndexedLogs<T> {
|
|
|
352
352
|
onResults?: (results: IndexedLogResults) => Promise<boolean>;
|
|
353
353
|
}): Promise<IndexedLogResults> {
|
|
354
354
|
|
|
355
|
-
if (config.params.
|
|
355
|
+
if (config.params.forceReadProduction && !isPublic()) {
|
|
356
356
|
let machineNodes = await this.getMachineNodes();
|
|
357
357
|
if (machineNodes.length === 0) throw new Error(`Cannot find any public nodes to read from`);
|
|
358
358
|
return await this.clientFind({
|
|
@@ -649,7 +649,7 @@ export class IndexedLogs<T> {
|
|
|
649
649
|
startTime: number;
|
|
650
650
|
endTime: number;
|
|
651
651
|
only?: "local" | "public";
|
|
652
|
-
|
|
652
|
+
forceReadProduction?: boolean;
|
|
653
653
|
|
|
654
654
|
}): Promise<TimeFilePathWithSize[]> {
|
|
655
655
|
let controller = IndexedLogShimController.nodes[SocketFunction.getBrowserNodeId()];
|
|
@@ -658,7 +658,7 @@ export class IndexedLogs<T> {
|
|
|
658
658
|
startTime: config.startTime,
|
|
659
659
|
endTime: config.endTime,
|
|
660
660
|
only: config.only,
|
|
661
|
-
|
|
661
|
+
forceReadProduction: config.forceReadProduction,
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
public onFindResult(config: {
|
|
@@ -778,7 +778,7 @@ class IndexedLogShim {
|
|
|
778
778
|
startTime: number;
|
|
779
779
|
endTime: number;
|
|
780
780
|
only?: "local" | "public";
|
|
781
|
-
|
|
781
|
+
forceReadProduction?: boolean;
|
|
782
782
|
}): Promise<TimeFilePathWithSize[]> {
|
|
783
783
|
let indexedLogs = loggerByName.get(config.indexedLogsName);
|
|
784
784
|
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
@@ -786,7 +786,7 @@ class IndexedLogShim {
|
|
|
786
786
|
startTime: config.startTime,
|
|
787
787
|
endTime: config.endTime,
|
|
788
788
|
only: config.only,
|
|
789
|
-
|
|
789
|
+
forceReadProduction: config.forceReadProduction,
|
|
790
790
|
});
|
|
791
791
|
}
|
|
792
792
|
|