Remove non-documentation lint

Because of extensive nature of changes, tested all three non-memstore
backends - passed.
This commit is contained in:
kortschak 2014-08-28 11:51:39 +09:30
parent 6614466d23
commit 484bf145a8
35 changed files with 277 additions and 284 deletions

View file

@ -130,7 +130,7 @@ func (it *Iterator) Clone() graph.Iterator {
func (it *Iterator) Next() bool {
var result struct {
Id string `bson:"_id"`
ID string `bson:"_id"`
Added []int64 `bson:"Added"`
Deleted []int64 `bson:"Deleted"`
}
@ -145,7 +145,7 @@ func (it *Iterator) Next() bool {
if it.collection == "quads" && len(result.Added) <= len(result.Deleted) {
return it.Next()
}
it.result = result.Id
it.result = result.ID
return true
}

View file

@ -18,45 +18,48 @@ import (
"container/list"
)
type IDLru struct {
// TODO(kortschak) Reimplement without container/list.
// cache implements an LRU cache.
type cache struct {
cache map[string]*list.Element
priority *list.List
maxSize int
}
type KV struct {
type kv struct {
key string
value string
}
func NewIDLru(size int) *IDLru {
var lru IDLru
func newCache(size int) *cache {
var lru cache
lru.maxSize = size
lru.priority = list.New()
lru.cache = make(map[string]*list.Element)
return &lru
}
func (lru *IDLru) Put(key string, value string) {
func (lru *cache) Put(key string, value string) {
if _, ok := lru.Get(key); ok {
return
}
if len(lru.cache) == lru.maxSize {
lru.removeOldest()
}
lru.priority.PushFront(KV{key: key, value: value})
lru.priority.PushFront(kv{key: key, value: value})
lru.cache[key] = lru.priority.Front()
}
func (lru *IDLru) Get(key string) (string, bool) {
func (lru *cache) Get(key string) (string, bool) {
if element, ok := lru.cache[key]; ok {
lru.priority.MoveToFront(element)
return element.Value.(KV).value, true
return element.Value.(kv).value, true
}
return "", false
}
func (lru *IDLru) removeOldest() {
func (lru *cache) removeOldest() {
last := lru.priority.Remove(lru.priority.Back())
delete(lru.cache, last.(KV).key)
delete(lru.cache, last.(kv).key)
}

View file

@ -45,7 +45,7 @@ var (
type QuadStore struct {
session *mgo.Session
db *mgo.Database
idCache *IDLru
ids *cache
}
func createNewMongoGraph(addr string, options graph.Options) error {
@ -97,11 +97,11 @@ func newQuadStore(addr string, options graph.Options) (graph.QuadStore, error) {
}
qs.db = conn.DB(dbName)
qs.session = conn
qs.idCache = NewIDLru(1 << 16)
qs.ids = newCache(1 << 16)
return &qs, nil
}
func (qs *QuadStore) getIdForQuad(t quad.Quad) string {
func (qs *QuadStore) getIDForQuad(t quad.Quad) string {
id := hashOf(t.Subject)
id += hashOf(t.Predicate)
id += hashOf(t.Object)
@ -121,7 +121,7 @@ func hashOf(s string) string {
}
type MongoNode struct {
Id string `bson:"_id"`
ID string `bson:"_id"`
Name string `bson:"Name"`
Size int `bson:"Size"`
}
@ -133,11 +133,11 @@ type MongoLogEntry struct {
Timestamp int64
}
func (qs *QuadStore) updateNodeBy(node_name string, inc int) error {
node := qs.ValueOf(node_name)
func (qs *QuadStore) updateNodeBy(name string, inc int) error {
node := qs.ValueOf(name)
doc := bson.M{
"_id": node.(string),
"Name": node_name,
"Name": name,
}
upsert := bson.M{
"$setOnInsert": doc,
@ -166,7 +166,7 @@ func (qs *QuadStore) updateQuad(q quad.Quad, id int64, proc graph.Procedure) err
setname: id,
},
}
_, err := qs.db.C("quads").UpsertId(qs.getIdForQuad(q), upsert)
_, err := qs.db.C("quads").UpsertId(qs.getIDForQuad(q), upsert)
if err != nil {
glog.Errorf("Error: %v", err)
}
@ -202,7 +202,7 @@ func (qs *QuadStore) updateLog(d graph.Delta) error {
entry := MongoLogEntry{
LogID: d.ID,
Action: action,
Key: qs.getIdForQuad(d.Quad),
Key: qs.getIDForQuad(d.Quad),
Timestamp: d.Timestamp.UnixNano(),
}
err := qs.db.C("log").Insert(entry)
@ -217,7 +217,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta) error {
ids := make(map[string]int)
// Pre-check the existence condition.
for _, d := range in {
key := qs.getIdForQuad(d.Quad)
key := qs.getIDForQuad(d.Quad)
switch d.Action {
case graph.Add:
if qs.checkValid(key) {
@ -292,7 +292,7 @@ func (qs *QuadStore) ValueOf(s string) graph.Value {
}
func (qs *QuadStore) NameOf(v graph.Value) string {
val, ok := qs.idCache.Get(v.(string))
val, ok := qs.ids.Get(v.(string))
if ok {
return val
}
@ -301,7 +301,7 @@ func (qs *QuadStore) NameOf(v graph.Value) string {
if err != nil {
glog.Errorf("Error: Couldn't retrieve node %s %v", v, err)
}
qs.idCache.Put(v.(string), node.Name)
qs.ids.Put(v.(string), node.Name)
return node.Name
}