Skip to content

Commit e568b66

Browse files
taloricsharang
authored andcommitted
fix: update disjointset index preset
1 parent 234374d commit e568b66

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
@@ -1725,8 +1725,8 @@ def split_to_multiple_process_span_set(self) -> list:
17251725

17261726
# 构建一个并查集,将 spans 按 root 划分成多个子树
17271727
disjoint_set = DisjointSet()
1728-
# 避免 parent_index out of range
1729-
disjoint_set.disjoint_set = [-1] * max_flow_index
1728+
# 这里会跳索引,不是连续顺序,避免 index out of range,预分配大小
1729+
disjoint_set.disjoint_set = [-1] * (max_flow_index + 1)
17301730
for i in range(len(self.spans)):
17311731
parent_span_index = flow_index_to_span_index.get(
17321732
self.spans[i].get_parent_id(), -1)
@@ -2336,7 +2336,7 @@ def _union_sys_spans(
23362336

23372337
# 对 client_sys_spans 按 syscall_trace_id 划分为一个个集合
23382338
cp_disjoint_set = DisjointSet()
2339-
cp_disjoint_set.disjoint_set = [-1] * len(client_sys_spans)
2339+
cp_disjoint_set.disjoint_set = [-1] * (len(client_sys_spans) + 1)
23402340
for i in range(len(client_sys_spans)):
23412341
span = client_sys_spans[i]
23422342
if span.get_syscall_trace_id_response() > 0:

0 commit comments

Comments
 (0)