Skip to content

Commit cb38715

Browse files
author
Hongyu Zhou
committed
revert changes by mistake
1 parent 3aa8d98 commit cb38715

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

ldb_reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (reader *LDBReader) GetRowsByKeyPrefix(ctx context.Context, familyName stri
189189
if err != nil {
190190
return nil, err
191191
}
192-
res := &Rows{rows: rows, cols: cols, familyName: familyName, tableName: tableName, start: time.Now()}
192+
res := &Rows{rows: rows, cols: cols}
193193
return res, nil
194194
case err == sql.ErrNoRows:
195195
return &Rows{}, nil

rows.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,26 @@ package ctlstore
22

33
import (
44
"database/sql"
5-
"sync"
6-
"sync/atomic"
7-
"time"
85

9-
"github.com/segmentio/stats/v4"
10-
11-
"github.com/segmentio/ctlstore/pkg/globalstats"
126
"github.com/segmentio/ctlstore/pkg/scanfunc"
137
"github.com/segmentio/ctlstore/pkg/schema"
148
)
159

1610
// Rows composes an *sql.Rows and allows scanning ctlstore table rows into
1711
// structs or maps, similar to how the GetRowByKey reader method works.
18-
// It also keeps track of number of rows read and emits as a metric on Close
1912
//
2013
// The contract around Next/Err/Close is the same was it is for
2114
// *sql.Rows.
2215
type Rows struct {
23-
rows *sql.Rows
24-
cols []schema.DBColumnMeta
25-
familyName string
26-
tableName string
27-
count uint32
28-
once sync.Once
29-
start time.Time
16+
rows *sql.Rows
17+
cols []schema.DBColumnMeta
3018
}
3119

3220
// Next returns true if there's another row available.
3321
func (r *Rows) Next() bool {
3422
if r.rows == nil {
3523
return false
3624
}
37-
atomic.AddUint32(&r.count, 1)
3825
return r.rows.Next()
3926
}
4027

@@ -54,16 +41,6 @@ func (r *Rows) Close() error {
5441
if r.rows == nil {
5542
return nil
5643
}
57-
r.once.Do(func() {
58-
globalstats.Observe("get_rows_by_key_prefix_row_count", atomic.LoadUint32(&r.count),
59-
stats.T("family", r.familyName),
60-
stats.T("table", r.tableName))
61-
if !r.start.IsZero() {
62-
globalstats.Observe("get_rows_by_prefix_scan_time", time.Now().Sub(r.start),
63-
stats.T("family", r.familyName),
64-
stats.T("table", r.tableName))
65-
}
66-
})
6744
return r.rows.Close()
6845
}
6946

0 commit comments

Comments
 (0)