This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new d64eeb6f Set duration unit to nanosecond (#480)
d64eeb6f is described below

commit d64eeb6f25de9d4759d42a1f9ba7646c35e67ace
Author: Gao Hongtao <hanahm...@gmail.com>
AuthorDate: Fri Jun 28 20:58:51 2024 +0800

    Set duration unit to nanosecond (#480)
---
 banyand/internal/storage/segment.go | 6 +++++-
 pkg/query/tracer.go                 | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/banyand/internal/storage/segment.go 
b/banyand/internal/storage/segment.go
index 7c70e448..60e6727c 100644
--- a/banyand/internal/storage/segment.go
+++ b/banyand/internal/storage/segment.go
@@ -332,7 +332,11 @@ func (sc *segmentController[T, O]) removeSeg(segID 
segmentID) {
        for i, b := range sc.lst {
                if b.id == segID {
                        sc.lst = append(sc.lst[:i], sc.lst[i+1:]...)
-                       sc.deadline.Store(sc.lst[0].Start.UnixNano())
+                       if len(sc.lst) < 1 {
+                               sc.deadline.Store(0)
+                       } else {
+                               sc.deadline.Store(sc.lst[0].Start.UnixNano())
+                       }
                        break
                }
        }
diff --git a/pkg/query/tracer.go b/pkg/query/tracer.go
index 4d761273..eaa0de9c 100644
--- a/pkg/query/tracer.go
+++ b/pkg/query/tracer.go
@@ -151,5 +151,5 @@ func (s *Span) Error(err error) *Span {
 // Stop stops the span.
 func (s *Span) Stop() {
        s.data.EndTime = timestamppb.Now()
-       s.data.Duration = 
s.data.EndTime.AsTime().Sub(s.data.StartTime.AsTime()).Milliseconds()
+       s.data.Duration = 
s.data.EndTime.AsTime().Sub(s.data.StartTime.AsTime()).Nanoseconds()
 }

Reply via email to