Skip to content

Commit 43690ed

Browse files
committed
refine
1 parent 95d3803 commit 43690ed

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/stat/base/bucket_leap_array.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func (bla *BucketLeapArray) ResetBucketTo(bw *BucketWrap, startTime uint64) *Buc
2929

3030
// sampleCount is the number of slots
3131
// intervalInMs is the time length of sliding window
32-
// (intervalInMs%sampleCount != 0,verification has been completed by the caller)
32+
// sampleCount and intervalInMs must be positive and intervalInMs%sampleCount == 0,
33+
// the validation must be done before call NewBucketLeapArray
3334
func NewBucketLeapArray(sampleCount uint32, intervalInMs uint32) *BucketLeapArray {
3435
bucketLengthInMs := intervalInMs / sampleCount
3536
ret := &BucketLeapArray{

core/stat/base/leap_array.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ func NewAtomicBucketWrapArray(len int, bucketLengthInMs uint32, generator Bucket
9696

9797
func (aa *AtomicBucketWrapArray) elementOffset(idx int) (unsafe.Pointer, bool) {
9898
if idx >= aa.length || idx < 0 {
99-
logging.Error(errors.Errorf("The index (%d) is out of bounds, length is %d.", idx, aa.length), "")
99+
logging.Error(errors.New("array index out of bounds"),
100+
"array index out of bounds in AtomicBucketWrapArray.elementOffset()",
101+
"idx", idx, "arrayLength", aa.length)
100102
return nil, false
101103
}
102104
basePtr := aa.base

0 commit comments

Comments
 (0)