Skip to content

Commit 2da2a08

Browse files
taloricsharang
authored andcommitted
fix: update disjointset index preset
1 parent bfdf426 commit 2da2a08

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/app/application/l7_flow_tracing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,8 @@ def split_to_multiple_process_span_set(self) -> list:
16171617

16181618
# 构建一个并查集,将 spans 按 root 划分成多个子树
16191619
disjoint_set = DisjointSet()
1620-
# 避免 parent_index out of range
1621-
disjoint_set.disjoint_set = [-1] * max_flow_index
1620+
# 这里会跳索引,不是连续顺序,避免 index out of range,预分配大小
1621+
disjoint_set.disjoint_set = [-1] * (max_flow_index + 1)
16221622
for i in range(len(self.spans)):
16231623
parent_span_index = flow_index_to_span_index.get(
16241624
self.spans[i].get_parent_id(), -1)
@@ -2168,7 +2168,7 @@ def _union_sys_spans(
21682168

21692169
# 对 client_sys_spans 按 syscall_trace_id 划分为一个个集合
21702170
cp_disjoint_set = DisjointSet()
2171-
cp_disjoint_set.disjoint_set = [-1] * len(client_sys_spans)
2171+
cp_disjoint_set.disjoint_set = [-1] * (len(client_sys_spans) + 1)
21722172
for i in range(len(client_sys_spans)):
21732173
span = client_sys_spans[i]
21742174
if span.get_syscall_trace_id_response() > 0:

0 commit comments

Comments
 (0)