Skip to content

Commit

Permalink
Rename logEntryRanges to logEntryCharIndexMaps
Browse files Browse the repository at this point in the history
  • Loading branch information
LightFLP committed Sep 26, 2023
1 parent ee65996 commit 8d0c63e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/viewer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import LogFile from "./LogFile";
import LogView from "./log/LogView";
import MinimapView from "./minimap/MinimapView";
import Tooltip from "@mui/material/Tooltip";
import { LogViewState, StructureMatchId, RowProperty, Segment, LogEntryCharRanges } from "./types";
import { LogViewState, StructureMatchId, RowProperty, Segment, LogEntryCharMaps } from "./types";
import {
LOG_HEADER_HEIGHT,
MINIMAP_COLUMN_WIDTH,
Expand Down Expand Up @@ -49,7 +49,7 @@ interface State {

// Structure related
logFileAsString: string;
logEntryCharRanges: LogEntryCharRanges;
logEntryCharIndexMaps: LogEntryCharMaps;
selectedLogRows: string[][];
// selectedRowsTypes: RowType[];
rowProperties: RowProperty[];
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class App extends React.Component<Props, State> {
caseSearch: false,
selectedLogRows: [],
rowProperties: [],
logEntryCharRanges: { firstCharIndexMap: null, lastCharIndexMap: null },
logEntryCharIndexMaps: { firstCharIndexMap: null, lastCharIndexMap: null },
showStructureDialog: false,
structureMatches: [],
structureMatchesLogRows: [],
Expand Down Expand Up @@ -136,15 +136,15 @@ export default class App extends React.Component<Props, State> {
const rules = message.rules.map((r) => Rule.fromJSON(r)).filter((r) => r);
const lines = JSON.parse(message.text);
const logFileText = JSON.stringify(lines, null, 2);
const charRangesMaps = useGetCharIndicesForLogEntries(logFileText);
const logEntryCharIndexMaps = useGetCharIndicesForLogEntries(logFileText);
const logFile = LogFile.create(lines, rules);
const newRowsProps = logFile.rows.map(() =>
constructNewRowProperty(true, true, SelectedRowType.None),
);
this.setState({
logFile,
logFileAsString: logFileText,
logEntryCharRanges: charRangesMaps,
logEntryCharIndexMaps: logEntryCharIndexMaps,
rules,
rowProperties: newRowsProps,
});
Expand Down Expand Up @@ -184,11 +184,11 @@ export default class App extends React.Component<Props, State> {
return constructNewRowProperty(true, true, SelectedRowType.None);
else return constructNewRowProperty(false, false, SelectedRowType.None);
});
const charRangesMaps = useGetCharIndicesForLogEntries(logFileText);
const logEntryCharIndexMaps = useGetCharIndicesForLogEntries(logFileText);
this.setState({
logFile,
logFileAsString: logFileText,
logEntryCharRanges: charRangesMaps,
logEntryCharIndexMaps: logEntryCharIndexMaps,
rules,
rowProperties: newRowsProps,
});
Expand Down Expand Up @@ -322,13 +322,13 @@ export default class App extends React.Component<Props, State> {

handleStructureMatching(expression: string) {
const rowProperties = this.clearSelectedRowsTypes();
const { logFileAsString, logEntryCharRanges } = this.state;
const { logFileAsString, logEntryCharIndexMaps } = this.state;
let { currentStructureMatch, currentStructureMatchIndex } = this.state;

const structureMatches = useStructureRegularExpressionSearch(
expression,
logFileAsString,
logEntryCharRanges,
logEntryCharIndexMaps,
);
let structureMatchesLogRows: number[] = [];

Expand Down Expand Up @@ -381,18 +381,18 @@ export default class App extends React.Component<Props, State> {
}

handleSegmentation(entryExpression: string, exitExpression: string) {
const { logFileAsString, logEntryCharRanges } = this.state;
const { logFileAsString, logEntryCharIndexMaps } = this.state;
const { collapsibleRows } = this.state;

const entryMatches = getRegularExpressionMatches(
entryExpression,
logFileAsString,
logEntryCharRanges,
logEntryCharIndexMaps,
);
const exitMatches = getRegularExpressionMatches(
exitExpression,
logFileAsString,
logEntryCharRanges,
logEntryCharIndexMaps,
);

const stack: number[] = [];
Expand Down
10 changes: 5 additions & 5 deletions src/viewer/hooks/useStructureRegularExpressionManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CellContents, Header, LogEntryCharRanges, StructureEntry, Wildcard } from "../types";
import { CellContents, Header, LogEntryCharMaps, StructureEntry, Wildcard } from "../types";
import { StructureHeaderColumnType, StructureLinkDistance } from "../constants";
import { isSubstitutionFirstForWildcard } from "./useWildcardManager";

Expand Down Expand Up @@ -182,7 +182,7 @@ export const useStructureQueryConstructor = (
return regularExp;
};

export const useGetCharIndicesForLogEntries = (logFileAsString: string): LogEntryCharRanges => {
export const useGetCharIndicesForLogEntries = (logFileAsString: string): LogEntryCharMaps => {
const perfStart = performance.now();
const jsonObjectsRegExp = new RegExp(regExpjsonObject, flags);
const firstCharIndexMap = new Map();
Expand All @@ -208,7 +208,7 @@ export const useGetCharIndicesForLogEntries = (logFileAsString: string): LogEntr
export const useStructureRegularExpressionSearch = (
expression: string,
logFileAsString: string,
logEntryCharRanges: LogEntryCharRanges,
logEntryCharIndexMaps: LogEntryCharMaps,
): number[][] => {
console.log("Starting Structure Matching");
const perfStart = performance.now();
Expand All @@ -230,8 +230,8 @@ export const useStructureRegularExpressionSearch = (
textRanges.forEach((matchRanges) => {
const indexesOfEntriesInMatch: number[] = [];

const indexOfFirstObjectInMatch = logEntryCharRanges.firstCharIndexMap.get(matchRanges[0]);
const indexOfLastObjectInMatch = logEntryCharRanges.lastCharIndexMap.get(matchRanges[1]);
const indexOfFirstObjectInMatch = logEntryCharIndexMaps.firstCharIndexMap.get(matchRanges[0]);
const indexOfLastObjectInMatch = logEntryCharIndexMaps.lastCharIndexMap.get(matchRanges[1]);

for (let i = indexOfFirstObjectInMatch; i <= indexOfLastObjectInMatch; i++) {
indexesOfEntriesInMatch.push(i);
Expand Down
2 changes: 1 addition & 1 deletion src/viewer/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface Segment {
level: number;
}

export interface LogEntryCharRanges {
export interface LogEntryCharMaps {
firstCharIndexMap;
lastCharIndexMap;
}

0 comments on commit 8d0c63e

Please sign in to comment.