fix(kv): update label collection to use new forward cursor (#16636)

pull/16648/head
Lyon Hill 2020-01-23 08:46:40 -07:00 committed by GitHub
parent a7dddba728
commit 25cc4ea83d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

@ -1,7 +1,6 @@
package kv
import (
"bytes"
"context"
"encoding/json"
"fmt"
@ -158,17 +157,17 @@ func (s *Service) findResourceLabels(ctx context.Context, tx Tx, filter influxdb
return err
}
cur, err := idx.Cursor()
if err != nil {
return err
}
prefix, err := filter.ResourceID.Encode()
if err != nil {
return err
}
for k, _ := cur.Seek(prefix); bytes.HasPrefix(k, prefix); k, _ = cur.Next() {
cur, err := idx.ForwardCursor(prefix, WithCursorPrefix(prefix))
if err != nil {
return err
}
for k, _ := cur.Next(); k != nil; k, _ = cur.Next() {
_, id, err := decodeLabelMappingKey(k)
if err != nil {
return err
@ -361,12 +360,12 @@ func (s *Service) forEachLabel(ctx context.Context, tx Tx, fn func(*influxdb.Lab
return err
}
cur, err := b.Cursor()
cur, err := b.ForwardCursor(nil)
if err != nil {
return err
}
for k, v := cur.First(); k != nil; k, v = cur.Next() {
for k, v := cur.Next(); k != nil; k, v = cur.Next() {
l := &influxdb.Label{}
if err := json.Unmarshal(v, l); err != nil {
return err