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 0b399ff9 Implement atomic counters for total queries and writes in 
sidx (#740)
0b399ff9 is described below

commit 0b399ff9b92c4fec8f21f5776144172d787e333b
Author: Gao Hongtao <[email protected]>
AuthorDate: Thu Aug 28 12:46:41 2025 +0800

    Implement atomic counters for total queries and writes in sidx (#740)
    
    - Added atomic counters for tracking total queries and writes in the sidx 
struct.
    - Updated Write and Query methods to increment respective counters.
    - Modified Stats method to return the new counters for queries and writes.
---
 banyand/internal/sidx/sidx.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/banyand/internal/sidx/sidx.go b/banyand/internal/sidx/sidx.go
index 22c9bd50..fa9150a4 100644
--- a/banyand/internal/sidx/sidx.go
+++ b/banyand/internal/sidx/sidx.go
@@ -44,6 +44,8 @@ type sidx struct {
        pm                         protector.Memory
        totalIntroduceLoopStarted  atomic.Int64
        totalIntroduceLoopFinished atomic.Int64
+       totalQueries               atomic.Int64
+       totalWrites                atomic.Int64
        mu                         sync.RWMutex
 }
 
@@ -85,6 +87,9 @@ func (s *sidx) Write(ctx context.Context, reqs 
[]WriteRequest) error {
                }
        }
 
+       // Increment write counter
+       s.totalWrites.Add(1)
+
        // Create elements from requests
        es := generateElements()
        defer releaseElements(es)
@@ -158,6 +163,9 @@ func (s *sidx) Query(ctx context.Context, req QueryRequest) 
(*QueryResponse, err
                return nil, err
        }
 
+       // Increment query counter
+       s.totalQueries.Add(1)
+
        // Get current snapshot
        snap := s.currentSnapshot()
        if snap == nil {
@@ -248,8 +256,8 @@ func (s *sidx) Stats(_ context.Context) (*Stats, error) {
        }
 
        // Load atomic counters
-       stats.QueryCount.Store(s.totalIntroduceLoopStarted.Load())
-       stats.WriteCount.Store(s.totalIntroduceLoopFinished.Load())
+       stats.QueryCount.Store(s.totalQueries.Load())
+       stats.WriteCount.Store(s.totalWrites.Load())
 
        return stats, nil
 }

Reply via email to