bestpayAmes commented on issue #6186:
URL: https://github.com/apache/skywalking/issues/6186#issuecomment-760070323


   `private List<Span> findRoot(List<Span> spans) {
           List<Span> rootSpans = new ArrayList<>();
           spans.forEach(span -> {
               String segmentParentSpanId = span.getSegmentParentSpanId();
   
               boolean hasParent = false;
               for (Span subSpan : spans) {
                   if (segmentParentSpanId.equals(subSpan.getSegmentSpanId())) {
                       hasParent = true;
                       // if find parent, quick exit
                       break;
                   }
               }
   
               if (!hasParent) {
                   span.setRoot(true);
                   rootSpans.add(span);
               }
           });`
   because of it,This code is inefficient,O(N^2)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to