-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,15 @@ type SegmentFileSizes = number[]; | |
* Byte sizes for non-segment archive files. | ||
*/ | ||
interface NonSegmentFileSizes { | ||
metadataDB: number; | ||
metadataDb: number; | ||
logTypeDict: number; | ||
logTypeSegIndex: number; | ||
varDict: number; | ||
varSegIndex: number; | ||
} | ||
|
||
/** | ||
* Segment Metadata. | ||
* Segment metadata. | ||
*/ | ||
interface SegmentInfo { | ||
numMessages: number; | ||
|
@@ -72,28 +72,28 @@ const deserializeHeaderMetadata = ( | |
}; | ||
|
||
/** | ||
* Parse single file archive metadata to retrieve byte sizes of all files | ||
* in the archive. The sizes are needed to accurately decode individual files. | ||
* Parse header metadata to retrieve byte sizes of all files in the archive. | ||
* The sizes are needed to accurately decode individual files. | ||
* | ||
* @param singleFileArchiveMetadata Metadata containing archived file sizes. | ||
* @param headerMetadata Metadata containing archived file sizes. | ||
* @return Array with two elements. First element contains sizes of non-segment | ||
* files. Second element contains the size for each segment. | ||
*/ | ||
Check warning on line 81 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L74-L81
|
||
const parseHeaderMetadata = ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
singleFileArchiveMetadata: any | ||
headerMetadata: any | ||
): [NonSegmentFileSizes, SegmentFileSizes] => { | ||
if (!singleFileArchiveMetadata.archive_files) { | ||
if (!headerMetadata.archive_files) { | ||
Check failure on line 86 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L86
Check failure on line 86 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L86
|
||
throw new Error("Archive file metadata not found"); | ||
Check failure on line 87 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L87
|
||
} | ||
Check failure on line 88 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L88
|
||
|
||
// Array of files in the archive each containing a name (fileInfo.n) and an | ||
Check failure on line 90 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L90
|
||
// offset (fileInfo.o). | ||
Check failure on line 91 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L91
|
||
const fileInfos = singleFileArchiveMetadata.archive_files; | ||
const fileInfos = headerMetadata.archive_files; | ||
Check failure on line 92 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L92
Check failure on line 92 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L92
Check failure on line 92 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L92
|
||
|
||
// Create null instances to fill in afterwards. | ||
Check failure on line 94 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L94
|
||
const nonSegmentSizes: NonSegmentFileSizes = { | ||
Check failure on line 95 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L95
|
||
metadataDB: 0, | ||
metadataDb: 0, | ||
Check failure on line 96 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L96
|
||
logTypeDict: 0, | ||
Check failure on line 97 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L97
Check warning on line 97 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L97
|
||
logTypeSegIndex: 0, | ||
Check failure on line 98 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L98
|
||
varDict: 0, | ||
Check failure on line 99 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L99
|
||
|
@@ -114,7 +114,7 @@ const parseHeaderMetadata = ( | |
if (false === isSegment(name)) { | ||
Check failure on line 114 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L114
Check failure on line 114 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L114
|
||
switch (name) { | ||
Check failure on line 115 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L115
|
||
case "metadata.db": | ||
Check failure on line 116 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L116
|
||
nonSegmentSizes.metadataDB = size; | ||
nonSegmentSizes.metadataDb = size; | ||
Check failure on line 117 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L117
|
||
break; | ||
Check failure on line 118 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L118
|
||
case "logtype.dict": | ||
Check failure on line 119 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L119
|
||
nonSegmentSizes.logTypeDict = size; | ||
Check failure on line 120 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L120
|
||
|
@@ -155,19 +155,19 @@ const isSegment = (name: string) => { | |
* | ||
* @param dataInputStream Byte stream containing single file archive with | ||
* offset at start of database. | ||
* @param metadataDBsize Byte size of database. | ||
* @param metadataDbSize Byte size of database. | ||
* @return Array containing metadata for each segment. | ||
*/ | ||
const querySegmentInfos = async ( | ||
dataInputStream: DataInputStream, | ||
metadataDBsize: number | ||
metadataDbSize: number | ||
): Promise<SegmentInfo[]> => { | ||
// Required to load the sqljs wasm binary asynchronously. | ||
Check failure on line 165 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L165
|
||
const SQL: initSqlJs.SqlJsStatic = await initSqlJs({ | ||
Check failure on line 166 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L166
Check failure on line 166 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L166
|
||
locateFile: (file) => `static/js/${file}`, | ||
Check failure on line 167 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L167
|
||
}); | ||
Check failure on line 168 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L166-L168
Check failure on line 168 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L168
|
||
|
||
const dbBytes: Uint8Array = dataInputStream.readFully(metadataDBsize); | ||
const dbBytes: Uint8Array = dataInputStream.readFully(metadataDbSize); | ||
Check failure on line 170 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L170
|
||
|
||
const db = new SQL.Database(dbBytes); | ||
Check failure on line 172 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L172
Check failure on line 172 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L172
Check failure on line 172 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L172
Check failure on line 172 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L172
|
||
const queryResult: initSqlJs.QueryExecResult[] = db.exec(` | ||
Check failure on line 173 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L173
Check failure on line 173 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L173
Check failure on line 173 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/metadata.ts#L173
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ interface Segment { | |
* @param dataInputStream Byte stream containing single file archive with offset | ||
* at start of segments. | ||
* @param segmentSize Array of byte sizes for each segment in archive. | ||
Check warning on line 24 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L24
|
||
* @param segmentInfos Byte sizes for non-segment archive files. | ||
* @param segmentInfos Segment metadata. | ||
* @param logTypeDict Archive log type dictionary. | ||
* @param varDict Archive variable dictionary. | ||
* @return Array with combined log events from all segments. | ||
|
@@ -36,16 +36,16 @@ const deserializeSegments = async ( | |
): Promise<ArchiveLogEvent[]> => { | ||
Check failure on line 36 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L36
|
||
const logEvents: ArchiveLogEvent[] = []; | ||
Check failure on line 37 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L37
|
||
for (let index = 0; index < segmentSizes.length; index++) { | ||
Check failure on line 38 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L38
|
||
const size: number | undefined = segmentSizes[index]; | ||
const segmentSize: number | undefined = segmentSizes[index]; | ||
Check failure on line 39 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L39
|
||
const segmentInfo: SegmentInfo | undefined = segmentInfos[index]; | ||
Check failure on line 40 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L40
|
||
|
||
if (!size || !segmentInfo) { | ||
if (!segmentSize || !segmentInfo) { | ||
Check failure on line 42 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L42
|
||
throw new Error("Segment metadata was not found"); | ||
Check failure on line 43 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L43
|
||
} | ||
Check failure on line 44 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L44
|
||
|
||
const segment: Segment = await deserializeSegment( | ||
Check failure on line 46 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L46
Check failure on line 46 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L46
|
||
dataInputStream, | ||
Check failure on line 47 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L47
|
||
size, | ||
segmentSize, | ||
Check failure on line 48 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L48
|
||
segmentInfo | ||
Check failure on line 49 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L49
|
||
); | ||
Check failure on line 50 in new-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts GitHub Actions / ESLint Report Analysisnew-log-viewer/src/services/decoders/ClpArchiveDecoder/segment.ts#L50
|
||
|
||
|
@@ -155,19 +155,20 @@ const toLogEvents = ( | |
|
||
/** | ||
* Retrieves dictionary and encoded variables for a specific log message. | ||
* Traverses log type until a variable placeholder is found. For each | ||
* variable placeholder found, a value is popped from the segment variables array. | ||
* Dictionary and encoded variables are distinguished by different byte | ||
* placeholders. If the variable is a dictionary variable, the value is used | ||
* to index into the archive's variable dictionary, and the lookup result is | ||
* added to its array. If the variable is an encoded variable, the value is simply | ||
* added to its array. The function returns two arrays. First for dictionary | ||
* variables, and second for encoded variables. | ||
* The function returns two arrays; The first for dictionary variables, | ||
* and the second for encoded variables. Traverses log type until a variable | ||
* placeholder is found. For each variable placeholder found, a value is | ||
* popped from the segment variables array. Dictionary and encoded variables | ||
* are distinguished by different byte placeholders. If the variable is a | ||
* dictionary variable, the value is used to index into the archive's variable | ||
* dictionary, and the lookup result is added to dictionary array. If the variable is | ||
* an encoded variable, the value is simply added to encoded array. | ||
* | ||
* @param logType Log with placeholders for variables. | ||
* @param segmentVarIterator Iterator for segment variables. | ||
* @param varDict Archive variable dictionary. | ||
* @return Two arrays, the first for dictionary variables and the second for encoded variables. | ||
* @return Two arrays, the first for dictionary variables and the second for | ||
* encoded variables. | ||
*/ | ||
const getLogEventVariables = ( | ||
logType: Uint8Array, | ||
|