Skip to content

Commit

Permalink
scan keys in lineariable
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Apr 2, 2022
1 parent 6e828fa commit 2755e16
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pkg/meta/tkv_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ func (tx *etcdTxn) gets(keys ...[]byte) [][]byte {
}

func (tx *etcdTxn) scanRange(begin_, end_ []byte) map[string][]byte {
resp, err := tx.kv.Get(tx.ctx,
string(begin_),
etcd.WithRange(string(end_)),
etcd.WithSerializable())
resp, err := tx.kv.Get(tx.ctx, string(begin_), etcd.WithRange(string(end_)))
if err != nil {
panic(fmt.Errorf("get range [%v-%v): %s", string(begin_), string(end_), err))
}
Expand Down Expand Up @@ -145,11 +142,7 @@ func (tx *etcdTxn) scan(prefix []byte, handler func(key []byte, value []byte)) {
}

func (tx *etcdTxn) scanKeys(prefix []byte) [][]byte {
resp, err := tx.kv.Get(tx.ctx,
string(prefix),
etcd.WithPrefix(),
etcd.WithKeysOnly(),
etcd.WithSerializable())
resp, err := tx.kv.Get(tx.ctx, string(prefix), etcd.WithPrefix(), etcd.WithKeysOnly())
if err != nil {
panic(fmt.Errorf("get prefix %v with keys only: %s", string(prefix), err))
}
Expand All @@ -165,7 +158,7 @@ func (tx *etcdTxn) scanValues(prefix []byte, limit int, filter func(k, v []byte)
if limit == 0 {
return nil
}
resp, err := tx.kv.Get(tx.ctx, string(prefix), etcd.WithPrefix(), etcd.WithSerializable())
resp, err := tx.kv.Get(tx.ctx, string(prefix), etcd.WithPrefix())
if err != nil {
panic(fmt.Errorf("get prefix %s: %s", string(prefix), err))
}
Expand All @@ -184,8 +177,7 @@ func (tx *etcdTxn) scanValues(prefix []byte, limit int, filter func(k, v []byte)
}

func (tx *etcdTxn) exist(prefix []byte) bool {
resp, err := tx.kv.Get(tx.ctx, string(prefix), etcd.WithPrefix(),
etcd.WithCountOnly(), etcd.WithSerializable())
resp, err := tx.kv.Get(tx.ctx, string(prefix), etcd.WithPrefix(), etcd.WithCountOnly())
if err != nil {
panic(fmt.Errorf("get prefix %v with count only: %s", string(prefix), err))
}
Expand Down

0 comments on commit 2755e16

Please sign in to comment.