Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert timestamp type back to Number; Only keeping bigint for DecodeR…
Browse files Browse the repository at this point in the history
…esult timestamp
Henry8192 committed Dec 12, 2024
1 parent 6c2b45a commit 255f3e3
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/contexts/UrlContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -205,12 +205,10 @@ const getWindowUrlHashParams = () => {
);
const hashParams = new URLSearchParams(window.location.hash.substring(1));

const checkAndSetHashParam = (hashParamName: string) => {
const checkAndSetHashParam = (hashParamName: keyof UrlHashParams) => {
const hashParam = hashParams.get(hashParamName);
if (null !== hashParam) {
const parsed = Number(hashParam);

// FIXME: hashParamName type
urlHashParams[hashParamName] = Number.isNaN(parsed) ?
null :
parsed;
4 changes: 4 additions & 0 deletions src/services/decoders/ClpIrDecoder.ts
Original file line number Diff line number Diff line change
@@ -77,6 +77,10 @@ class ClpIrDecoder implements Decoder {
return this.#streamReader.getFilteredLogEventMap();
}

getLogEventIdxByTimestamp (timestamp: number): number {
return this.#streamReader.getLogEventIdxByTimestamp(timestamp);

Check failure on line 81 in src/services/decoders/ClpIrDecoder.ts

GitHub Actions / lint-check

Unsafe return of an error typed value

Check failure on line 81 in src/services/decoders/ClpIrDecoder.ts

GitHub Actions / lint-check

Unsafe call of an `error` type typed value
}

setLogLevelFilter (logLevelFilter: LogLevelFilter): boolean {
this.#streamReader.filterLogEvents(logLevelFilter);

9 changes: 4 additions & 5 deletions src/services/decoders/JsonlDecoder/index.ts
Original file line number Diff line number Diff line change
@@ -122,18 +122,17 @@ class JsonlDecoder implements Decoder {
return results;
}

getLogEventIdxByTimestamp (timestamp: bigint): number {
getLogEventIdxByTimestamp (timestamp: number): number {
let low = 0;
let high = this.#logEvents.length - 1;
let result = -1;

while (low <= high) {
const mid = Math.floor((low + high) / 2);
const midTimestamp = BigInt(this.#logEvents[mid].timestamp.valueOf());

console.log(`midTimestamp: ${midTimestamp}, mid: ${mid}, low: ${low}, high: ${high}`);
if (midTimestamp == timestamp) {
console.error(`result recorded: ${mid}`);
// @ts-expect-error TS2532: Object is possibly 'undefined'.
const midTimestamp = this.#logEvents[mid].timestamp.valueOf();
if (midTimestamp === timestamp) {
result = mid;
low = mid + 1;
} else if (midTimestamp < timestamp) {
2 changes: 1 addition & 1 deletion src/typings/decoders.ts
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ interface Decoder {
* @param timestamp
* @return
*/
getLogEventIdxByTimestamp(timestamp: bigint): number;
getLogEventIdxByTimestamp(timestamp: number): number;
}

export type {
2 changes: 1 addition & 1 deletion src/typings/worker.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ enum CURSOR_CODE {
type CursorArgMap = {
[CURSOR_CODE.LAST_EVENT]: null;
[CURSOR_CODE.EVENT_NUM]: { eventNum: number };
[CURSOR_CODE.TIMESTAMP]: { timestamp: bigint };
[CURSOR_CODE.TIMESTAMP]: { timestamp: number };
[CURSOR_CODE.PAGE_NUM]: { pageNum: number, eventPositionOnPage: EVENT_POSITION_ON_PAGE };
};

0 comments on commit 255f3e3

Please sign in to comment.