Clean up a little lint and some shadowed variables
This commit is contained in:
parent
969aa1a6c3
commit
67673b31f4
8 changed files with 26 additions and 20 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ var (
|
|||
}
|
||||
hashSize = sha1.Size
|
||||
localFillPercent = 0.7
|
||||
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ package graph
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/google/cayley/quad"
|
||||
)
|
||||
|
|
@ -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")
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue