Simplify method name

This commit is contained in:
kortschak 2014-08-27 21:40:36 +09:30
parent 443a091b72
commit 5e9da0347c
3 changed files with 18 additions and 18 deletions

View file

@ -138,16 +138,16 @@ func bucketFor(d [4]quad.Direction) []byte {
func (qs *QuadStore) createKeyFor(d [4]quad.Direction, q quad.Quad) []byte {
key := make([]byte, 0, (hashSize * 4))
key = append(key, qs.convertStringToByteHash(q.Get(d[0]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[1]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[2]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[3]))...)
key = append(key, qs.hashOf(q.Get(d[0]))...)
key = append(key, qs.hashOf(q.Get(d[1]))...)
key = append(key, qs.hashOf(q.Get(d[2]))...)
key = append(key, qs.hashOf(q.Get(d[3]))...)
return key
}
func (qs *QuadStore) createValueKeyFor(s string) []byte {
key := make([]byte, 0, hashSize)
key = append(key, qs.convertStringToByteHash(s)...)
key = append(key, qs.hashOf(s)...)
return key
}
@ -379,7 +379,7 @@ func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
return q
}
func (qs *QuadStore) convertStringToByteHash(s string) []byte {
func (qs *QuadStore) hashOf(s string) []byte {
h := hashPool.Get().(hash.Hash)
h.Reset()
defer hashPool.Put(h)

View file

@ -150,17 +150,17 @@ func (qs *QuadStore) createKeyFor(d [4]quad.Direction, q quad.Quad) []byte {
key := make([]byte, 0, 2+(hashSize*3))
// TODO(kortschak) Remove dependence on String() method.
key = append(key, []byte{d[0].Prefix(), d[1].Prefix()}...)
key = append(key, qs.convertStringToByteHash(q.Get(d[0]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[1]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[2]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[3]))...)
key = append(key, qs.hashOf(q.Get(d[0]))...)
key = append(key, qs.hashOf(q.Get(d[1]))...)
key = append(key, qs.hashOf(q.Get(d[2]))...)
key = append(key, qs.hashOf(q.Get(d[3]))...)
return key
}
func (qs *QuadStore) createValueKeyFor(s string) []byte {
key := make([]byte, 0, 1+hashSize)
key = append(key, []byte("z")...)
key = append(key, qs.convertStringToByteHash(s)...)
key = append(key, qs.hashOf(s)...)
return key
}
@ -347,7 +347,7 @@ func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
return q
}
func (qs *QuadStore) convertStringToByteHash(s string) []byte {
func (qs *QuadStore) hashOf(s string) []byte {
h := hashPool.Get().(hash.Hash)
h.Reset()
defer hashPool.Put(h)

View file

@ -102,14 +102,14 @@ func newQuadStore(addr string, options graph.Options) (graph.QuadStore, error) {
}
func (qs *QuadStore) getIdForQuad(t quad.Quad) string {
id := qs.convertStringToByteHash(t.Subject)
id += qs.convertStringToByteHash(t.Predicate)
id += qs.convertStringToByteHash(t.Object)
id += qs.convertStringToByteHash(t.Label)
id := qs.hashOf(t.Subject)
id += qs.hashOf(t.Predicate)
id += qs.hashOf(t.Object)
id += qs.hashOf(t.Label)
return id
}
func (qs *QuadStore) convertStringToByteHash(s string) string {
func (qs *QuadStore) hashOf(s string) string {
h := hashPool.Get().(hash.Hash)
h.Reset()
defer hashPool.Put(h)
@ -288,7 +288,7 @@ func (qs *QuadStore) QuadsAllIterator() graph.Iterator {
}
func (qs *QuadStore) ValueOf(s string) graph.Value {
return qs.convertStringToByteHash(s)
return qs.hashOf(s)
}
func (qs *QuadStore) NameOf(v graph.Value) string {