Skip to content

Commit

Permalink
Clean up a little lint and some shadowed variables
Browse files Browse the repository at this point in the history
  • Loading branch information
barakmich committed Feb 21, 2015
1 parent 969aa1a commit 67673b3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

func init() {
glog.SetToStderr(true)
cfg := config.ParseConfigFromFile("cayley_appengine.cfg")
cfg, _ := config.Load("cayley_appengine.cfg")
qs, _ := graph.NewQuadStore("memstore", "", nil)
glog.Errorln(cfg)
db.Load(qs, cfg, cfg.DatabasePath)
Expand Down
7 changes: 3 additions & 4 deletions graph/bolt/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var (
}
hashSize = sha1.Size
localFillPercent = 0.7

)

type Token struct {
Expand Down Expand Up @@ -209,10 +208,10 @@ func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreOpts graph.IgnoreOp
for _, d := range deltas {
err := qs.buildQuadWrite(tx, d.Quad, d.ID.Int(), d.Action == graph.Add)
if err != nil {
if err == graph.ErrQuadExists && ignoreOpts.IgnoreDup{
if err == graph.ErrQuadExists && ignoreOpts.IgnoreDup {
continue
}
if err == graph.ErrQuadNotExist && ignoreOpts.IgnoreMissing{
if err == graph.ErrQuadNotExist && ignoreOpts.IgnoreMissing {
continue
}
return err
Expand Down Expand Up @@ -269,7 +268,7 @@ func (qs *QuadStore) buildQuadWrite(tx *bolt.Tx, q quad.Quad, id int64, isAdd bo
return graph.ErrQuadExists
}
if !isAdd && len(entry.History)%2 == 0 {
glog.Error("attempt to delete non-existent quad %v: %#c", entry, q)
glog.Errorf("attempt to delete non-existent quad %v: %#v", entry, q)
return graph.ErrQuadNotExist
}

Expand Down
8 changes: 5 additions & 3 deletions graph/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Tagger struct {
fixedTags map[string]Value
}

// Adds a tag to the iterator.
// Add a tag to the iterator.
func (t *Tagger) Add(tag string) {
t.tags = append(t.tags, tag)
}
Expand All @@ -42,12 +42,12 @@ func (t *Tagger) AddFixed(tag string, value Value) {
t.fixedTags[tag] = value
}

// Returns the tags. The returned value must not be mutated.
// Tags returns the tags held in the tagger. The returned value must not be mutated.
func (t *Tagger) Tags() []string {
return t.tags
}

// Returns the fixed tags. The returned value must not be mutated.
// Fixed returns the fixed tags held in the tagger. The returned value must not be mutated.
func (t *Tagger) Fixed() map[string]Value {
return t.fixedTags
}
Expand Down Expand Up @@ -206,6 +206,7 @@ type IteratorStats struct {
// Type enumerates the set of Iterator types.
type Type int

// These are the iterator types, defined as constants
const (
Invalid Type = iota
All
Expand Down Expand Up @@ -306,6 +307,7 @@ func DumpStats(it Iterator) StatsContainer {

// Utility logging functions for when an iterator gets called Next upon, or Contains upon, as
// well as what they return. Highly useful for tracing the execution path of a query.

func ContainsLogIn(it Iterator, val Value) {
if glog.V(4) {
glog.V(4).Infof("%s %d CHECK CONTAINS %d", strings.ToUpper(it.Type().String()), it.UID(), val)
Expand Down
6 changes: 3 additions & 3 deletions graph/iterator/or_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func TestShortCircuitingOrBasics(t *testing.T) {
or = NewShortCircuitOr()
or.AddSubIterator(f1)
or.AddSubIterator(f2)
v, exact := or.Size()
if v != 4 {
t.Errorf("Unexpected iterator size, got:%d expected %d", v, 4)
size, exact := or.Size()
if size != 4 {
t.Errorf("Unexpected iterator size, got:%d expected %d", size, 4)
}
if !exact {
t.Error("Size not exact.")
Expand Down
2 changes: 1 addition & 1 deletion graph/mongo/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (it *Iterator) NextPath() bool {
return false
}

// No subiterators.
// SubIterators returns no subiterators for a Mongo iterator.
func (it *Iterator) SubIterators() []graph.Iterator {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions graph/quadwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ package graph

import (
"errors"
"time"
"flag"
"time"

"github.com/google/cayley/quad"
)
Expand Down Expand Up @@ -64,7 +64,7 @@ var (
)

var (
IgnoreDup = flag.Bool("ignoredup", false, "Don't stop loading on duplicated key on add")
IgnoreDup = flag.Bool("ignoredup", false, "Don't stop loading on duplicated key on add")
IgnoreMissing = flag.Bool("ignoremissing", false, "Don't stop loading on missing key on delete")
)

Expand Down
11 changes: 8 additions & 3 deletions query/gremlin/build_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ func buildInOutIterator(obj *otto.Object, qs graph.QuadStore, base graph.Iterato
}

func buildIteratorTreeHelper(obj *otto.Object, qs graph.QuadStore, base graph.Iterator) graph.Iterator {
it := base

// TODO: Better error handling
var subIt graph.Iterator
var (
it graph.Iterator
subIt graph.Iterator
)

if prev, _ := obj.Get("_gremlin_prev"); !prev.IsObject() {
subIt = base
} else {
Expand Down Expand Up @@ -314,5 +316,8 @@ func buildIteratorTreeHelper(obj *otto.Object, qs graph.QuadStore, base graph.It
and.AddSubIterator(notIt)
it = and
}
if it == nil {
panic("Iterator building does not catch the output iterator in some case.")
}
return it
}
6 changes: 3 additions & 3 deletions query/sexp/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ var testQueries = []struct {
func TestMemstoreBackedSexp(t *testing.T) {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
it := BuildIteratorTreeForQuery(qs, "()")
if it.Type() != graph.Null {
t.Errorf(`Incorrect type for empty query, got:%q expect: "null"`, it.Type())
emptyIt := BuildIteratorTreeForQuery(qs, "()")
if emptyIt.Type() != graph.Null {
t.Errorf(`Incorrect type for empty query, got:%q expect: "null"`, emptyIt.Type())
}
for _, test := range testQueries {
if test.add.IsValid() {
Expand Down

0 comments on commit 67673b3

Please sign in to comment.