Skip to content

Commit 75897db

Browse files
committed
kv: Fix go vet warnings.
1 parent 0bcb9ba commit 75897db

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

graph/kv/indexing.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ func (qs *QuadStore) applyAddDeltas(ctx context.Context, tx kv.Tx, in []graph.De
506506
}
507507
deltas.IncNode = nil
508508
// resolve and insert all new quads
509-
links := make([]cproto.Primitive, 0, len(deltas.QuadAdd))
509+
links := make([]*cproto.Primitive, 0, len(deltas.QuadAdd))
510510
qadd := make(map[[4]uint64]struct{}, len(deltas.QuadAdd))
511511
for _, q := range deltas.QuadAdd {
512512
var link cproto.Primitive
@@ -541,7 +541,7 @@ func (qs *QuadStore) applyAddDeltas(ctx context.Context, tx kv.Tx, in []graph.De
541541
return nil, err
542542
}
543543
}
544-
links = append(links, link)
544+
links = append(links, &link)
545545
}
546546
qadd = nil
547547
deltas.QuadAdd = nil
@@ -585,7 +585,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
585585
}
586586

587587
if len(deltas.QuadDel) != 0 || len(deltas.DecNode) != 0 {
588-
links := make([]cproto.Primitive, 0, len(deltas.QuadDel))
588+
links := make([]*cproto.Primitive, 0, len(deltas.QuadDel))
589589
// resolve all nodes that will be removed
590590
dnodes := make(map[refs.ValueHash]uint64, len(deltas.DecNode))
591591
if err := qs.resolveValDeltas(ctx, tx, deltas.DecNode, func(i int, id uint64) {
@@ -597,7 +597,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
597597
// check for existence and delete quads
598598
fixNodes := make(map[refs.ValueHash]int)
599599
for _, q := range deltas.QuadDel {
600-
var link cproto.Primitive
600+
link := new(cproto.Primitive)
601601
exists := true
602602
// resolve values of all quad directions
603603
// if any of the direction does not exists, the quad does not exists as well
@@ -616,13 +616,13 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreOpts graph.IgnoreOpts)
616616
link.SetDirection(dir, n.ID)
617617
}
618618
if exists {
619-
p, err := qs.hasPrimitive(ctx, tx, &link, true)
619+
p, err := qs.hasPrimitive(ctx, tx, link, true)
620620
if err != nil {
621621
return err
622622
} else if p == nil || p.Deleted {
623623
exists = false
624624
} else {
625-
link = *p
625+
link = p
626626
}
627627
}
628628
if !exists {
@@ -692,9 +692,9 @@ func (qs *QuadStore) indexNode(ctx context.Context, tx kv.Tx, p *cproto.Primitiv
692692
return qs.addToLog(ctx, tx, p)
693693
}
694694

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

733-
func (qs *QuadStore) markLinksDead(ctx context.Context, tx kv.Tx, links []cproto.Primitive) error {
733+
func (qs *QuadStore) markLinksDead(ctx context.Context, tx kv.Tx, links []*cproto.Primitive) error {
734734
for _, p := range links {
735-
if err := qs.markAsDead(ctx, tx, &p); err != nil {
735+
if err := qs.markAsDead(ctx, tx, p); err != nil {
736736
return err
737737
}
738738
}

graph/proto/primitive_helpers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "github.com/cayleygraph/quad"
44

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

7-
func (p Primitive) GetDirection(d quad.Direction) uint64 {
7+
func (p *Primitive) GetDirection(d quad.Direction) uint64 {
88
switch d {
99
case quad.Subject:
1010
return p.Subject
@@ -31,11 +31,11 @@ func (p *Primitive) SetDirection(d quad.Direction, v uint64) {
3131
}
3232
}
3333

34-
func (p Primitive) IsNode() bool {
34+
func (p *Primitive) IsNode() bool {
3535
return len(p.Value) != 0
3636
}
3737

38-
func (p Primitive) Key() interface{} {
38+
func (p *Primitive) Key() interface{} {
3939
return p.ID
4040
}
4141

0 commit comments

Comments
 (0)