Skip to content

Commit

Permalink
kv: Fix go vet warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Jul 6, 2024
1 parent 0bcb9ba commit 75897db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions graph/kv/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (qs *QuadStore) applyAddDeltas(ctx context.Context, tx kv.Tx, in []graph.De
}
deltas.IncNode = nil
// resolve and insert all new quads
links := make([]cproto.Primitive, 0, len(deltas.QuadAdd))
links := make([]*cproto.Primitive, 0, len(deltas.QuadAdd))
qadd := make(map[[4]uint64]struct{}, len(deltas.QuadAdd))
for _, q := range deltas.QuadAdd {
var link cproto.Primitive
Expand Down Expand Up @@ -541,7 +541,7 @@ func (qs *QuadStore) applyAddDeltas(ctx context.Context, tx kv.Tx, in []graph.De
return nil, err
}
}
links = append(links, link)
links = append(links, &link)
}
qadd = nil
deltas.QuadAdd = nil
Expand Down Expand Up @@ -585,7 +585,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
}

if len(deltas.QuadDel) != 0 || len(deltas.DecNode) != 0 {
links := make([]cproto.Primitive, 0, len(deltas.QuadDel))
links := make([]*cproto.Primitive, 0, len(deltas.QuadDel))
// resolve all nodes that will be removed
dnodes := make(map[refs.ValueHash]uint64, len(deltas.DecNode))
if err := qs.resolveValDeltas(ctx, tx, deltas.DecNode, func(i int, id uint64) {
Expand All @@ -597,7 +597,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
// check for existence and delete quads
fixNodes := make(map[refs.ValueHash]int)
for _, q := range deltas.QuadDel {
var link cproto.Primitive
link := new(cproto.Primitive)
exists := true
// resolve values of all quad directions
// if any of the direction does not exists, the quad does not exists as well
Expand All @@ -616,13 +616,13 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
link.SetDirection(dir, n.ID)
}
if exists {
p, err := qs.hasPrimitive(ctx, tx, &link, true)
p, err := qs.hasPrimitive(ctx, tx, link, true)
if err != nil {
return err
} else if p == nil || p.Deleted {
exists = false
} else {
link = *p
link = p
}
}
if !exists {
Expand Down Expand Up @@ -692,9 +692,9 @@ func (qs *QuadStore) indexNode(ctx context.Context, tx kv.Tx, p *cproto.Primitiv
return qs.addToLog(ctx, tx, p)
}

func (qs *QuadStore) indexLinks(ctx context.Context, tx kv.Tx, links []cproto.Primitive) error {
func (qs *QuadStore) indexLinks(ctx context.Context, tx kv.Tx, links []*cproto.Primitive) error {
for _, p := range links {
if err := qs.indexLink(ctx, tx, &p); err != nil {
if err := qs.indexLink(ctx, tx, p); err != nil {
return err
}
}
Expand Down Expand Up @@ -730,9 +730,9 @@ func (qs *QuadStore) delLog(ctx context.Context, tx kv.Tx, id uint64) error {
return tx.Del(ctx, logIndex.Append(uint64KeyBytes(id)))
}

func (qs *QuadStore) markLinksDead(ctx context.Context, tx kv.Tx, links []cproto.Primitive) error {
func (qs *QuadStore) markLinksDead(ctx context.Context, tx kv.Tx, links []*cproto.Primitive) error {
for _, p := range links {
if err := qs.markAsDead(ctx, tx, &p); err != nil {
if err := qs.markAsDead(ctx, tx, p); err != nil {
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions graph/proto/primitive_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/cayleygraph/quad"

//go:generate protoc --go_opt=paths=source_relative --proto_path=. --go_out=. primitive.proto

func (p Primitive) GetDirection(d quad.Direction) uint64 {
func (p *Primitive) GetDirection(d quad.Direction) uint64 {
switch d {
case quad.Subject:
return p.Subject
Expand All @@ -31,11 +31,11 @@ func (p *Primitive) SetDirection(d quad.Direction, v uint64) {
}
}

func (p Primitive) IsNode() bool {
func (p *Primitive) IsNode() bool {
return len(p.Value) != 0
}

func (p Primitive) Key() interface{} {
func (p *Primitive) Key() interface{} {
return p.ID
}

Expand Down

0 comments on commit 75897db

Please sign in to comment.