Skip to content

Commit

Permalink
Merge pull request #713 from Domiii/issue#708
Browse files Browse the repository at this point in the history
resolve PR comments in #710
  • Loading branch information
MiccWan authored Apr 4, 2022
2 parents 37bc60e + ee1decc commit 8a3d29a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 4 additions & 8 deletions dbux-data/src/callGraph/CallGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,29 @@ export default class CallGraph {
const trace = this.dp.collections.traces.getById(traceId);
const realContextId = this.dp.util.getRealContextIdOfTrace(traceId);
const parentTraces = this.dp.indexes.traces.parentsByRealContext.get(realContextId) || EmptyArray;
const callerTraces = parentTraces.map(t => this.dp.util.getPreviousCallerTraceOfTrace(t.traceId))
.sort((t1, t2) => t1.traceId - t2.traceId);

const lowerIndex = this._binarySearchLowerIndexByKey(callerTraces, trace, (t) => t.traceId);
const lowerIndex = this._binarySearchLowerIndexByKey(parentTraces, trace, (t) => t.traceId);

if (lowerIndex === null) {
return null;
}
else {
return this.dp.util.getBCETraceOfTrace(callerTraces[lowerIndex].traceId);
return this.dp.util.getBCETraceOfTrace(parentTraces[lowerIndex].traceId);
}
}

_getNextChildTrace(traceId) {
const realContextId = this.dp.util.getRealContextIdOfTrace(traceId);
const trace = this.dp.collections.traces.getById(traceId);
const parentTraces = this.dp.indexes.traces.parentsByRealContext.get(realContextId) || EmptyArray;
const callerTraces = parentTraces.map(t => this.dp.util.getPreviousCallerTraceOfTrace(t.traceId))
.sort((t1, t2) => t1.traceId - t2.traceId);

const upperIndex = this._binarySearchUpperIndexByKey(callerTraces, trace, (t) => t.traceId);
const upperIndex = this._binarySearchUpperIndexByKey(parentTraces, trace, (t) => t.traceId);

if (upperIndex === null) {
return null;
}
else {
return this.dp.util.getBCETraceOfTrace(callerTraces[upperIndex].traceId);
return this.dp.util.getBCETraceOfTrace(parentTraces[upperIndex].traceId);
}
}

Expand Down
8 changes: 6 additions & 2 deletions dbux-data/src/impl/indexes/ParentTracesInRealContextIndex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ExecutionContext from '@dbux/common/src/types/ExecutionContext';
import { isVirtualContextType } from '@dbux/common/src/types/constants/ExecutionContextType';
import ExecutionContextType from '@dbux/common/src/types/constants/ExecutionContextType';
import Trace from '@dbux/common/src/types/Trace';
import CollectionIndex, { CollectionIndexDependencies } from '../../indexes/CollectionIndex';
import RuntimeDataProvider from '../../RuntimeDataProvider';
Expand Down Expand Up @@ -38,10 +38,14 @@ export default class ParentTracesInRealContextIndex extends CollectionIndex {
added: (contexts) => {
for (const context of contexts) {
const { parentTraceId, contextId } = context;
// skip empty contexts
// skip empty contexts, e.g. `Await`s
if (this.dp.indexes.traces.byContext.getSize(contextId) === 0) {
continue;
}

/**
* NOTE: this will filter out non-first virtual contexts, since they have no `parentTraceId`
*/
if (parentTraceId && !this.addedTraces.has(parentTraceId)) {
this.addEntryById(parentTraceId);
this.addedTraces.add(parentTraceId);
Expand Down

0 comments on commit 8a3d29a

Please sign in to comment.