Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kevindiu <[email protected]>
  • Loading branch information
kevindiu committed Sep 25, 2023
1 parent 0aeef4c commit c4c2de7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/agent/core/ngt/service/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ func (n *ngt) update(uuid string, vec []float32, t int64, updateTS bool) (err er
if err = n.readyForUpdate(uuid, vec); err != nil {
if updateTS && errors.Is(err, errors.ErrUUIDAlreadyExists(uuid)) {
// update timestamp if UUID already exists
return n.updateTimestamp(uuid, vec, t)
return n.updateTimestamp(uuid, t)
}

Check warning on line 1011 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1008-L1011

Added lines #L1008 - L1011 were not covered by tests
return err
}
Expand Down Expand Up @@ -1047,23 +1047,27 @@ func (n *ngt) updateMultiple(vecs map[string][]float32, t int64) (err error) {
return n.insertMultiple(vecs, t, false)
}

func (n *ngt) updateTimestamp(uuid string, vec []float32, t int64) error {
func (n *ngt) updateTimestamp(uuid string, t int64) error {
// update kvs if it is exists in kvs
uid, ts, ok := n.kvs.Get(uuid)
if !ok {
return errors.ErrObjectIDNotFound(uuid)
}
if ts == t {
return errors.ErrUUIDAlreadyExists(uuid)
if ok {
if ts == t {
return errors.ErrUUIDAlreadyExists(uuid)
}
n.kvs.Set(uuid, uid, t)

Check warning on line 1057 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1050-L1057

Added lines #L1050 - L1057 were not covered by tests
}

// update vqueue only if it is exists
if n.vq.IVExists(uuid) {
// update vqueue if it is exists and to be inserted
vec, ts, ok := n.vq.GetVector(uuid)
if ok {
if ts == t {
return errors.ErrUUIDAlreadyExists(uuid)
}

Check warning on line 1065 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1061-L1065

Added lines #L1061 - L1065 were not covered by tests
// PushInsert will update the timestamp even the index existed in vqueue
if err := n.vq.PushInsert(uuid, vec, t); err != nil {
return err
}

Check warning on line 1069 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1067-L1069

Added lines #L1067 - L1069 were not covered by tests
}
n.kvs.Set(uuid, uid, t)

return nil

Check warning on line 1072 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1072

Added line #L1072 was not covered by tests
}
Expand Down

0 comments on commit c4c2de7

Please sign in to comment.