Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion point/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import (
"fmt"
"log"
"math"
"reflect"
"strings"
Expand Down Expand Up @@ -77,17 +78,22 @@

// check each kv valid
idx := 0
for _, kv := range kvs {
for i, kv := range kvs {
if x, ok := c.checkKV(kv, kvs); ok {

Check failure on line 82 in point/check.go

View workflow job for this annotation

GitHub Actions / build

ifElseChain: rewrite if-else to switch statement (gocritic)
log.Printf("set %d kv to %d", i, idx)
kvs[idx] = x
idx++
} else if defaultPTPool != nil {
// When point-pool enabled, on drop f, we should put-back to pool.
defaultPTPool.PutKV(x)
} else {
log.Printf("kv at %d removed", i)
}
}

log.Printf("trim at %d", idx)
for j := idx; j < len(kvs); j++ { // remove deleted elems
log.Printf("set %d kv to nil", j)
kvs[j] = nil
}

Expand Down
20 changes: 20 additions & 0 deletions point/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,26 @@ func TestCheckFields(t *T.T) {
}
}

func TestCheckAfterDelete(t *T.T) {
t.Run(`basic`, func(t *T.T) {
cfg := GetCfg()
defer PutCfg(cfg)

WithMaxFieldValLen(1)(cfg)
WithDisabledKeys(NewKey("f3", 0), NewKey("f5", 0))(cfg)

c := checker{cfg: cfg}
var kvs KVs

kvs1 := kvs.Add("f1", "1").Add("f2", 2).Add("f3", "333").Add("f4", 3.14).Add("f5", 1.414).Add("f6", "foo")
kvs2 := c.checkKVs(kvs1)
t.Logf("%s", kvs2.Pretty())
t.Logf("%s", kvs1.Pretty())

c.checkKVs(kvs1)
})
}

func TestAdjustKV(t *T.T) {
cases := []struct {
name, x, y string
Expand Down
Loading