Rename some methods and funcs since we are here
Very probably some of these can be made private.
This commit is contained in:
parent
d1fdba1cbb
commit
e39063e3ec
4 changed files with 12 additions and 12 deletions
|
|
@ -105,7 +105,7 @@ func (it *AllIterator) Close() {
|
|||
}
|
||||
|
||||
func (it *AllIterator) Size() (int64, bool) {
|
||||
size, err := it.ts.GetApproximateSizeForPrefix(it.prefix)
|
||||
size, err := it.ts.SizeOfPrefix(it.prefix)
|
||||
if err == nil {
|
||||
return size, false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
func GetPositionFromPrefix(prefix []byte, d graph.Direction, ts *TripleStore) int {
|
||||
func PositionOf(prefix []byte, d graph.Direction, ts *TripleStore) int {
|
||||
if bytes.Equal(prefix, []byte("sp")) {
|
||||
switch d {
|
||||
case graph.Subject:
|
||||
|
|
@ -171,7 +171,7 @@ func (it *Iterator) Check(v graph.Value) bool {
|
|||
if val[0] == 'z' {
|
||||
return false
|
||||
}
|
||||
offset := GetPositionFromPrefix(val[0:2], it.dir, it.ts)
|
||||
offset := PositionOf(val[0:2], it.dir, it.ts)
|
||||
if offset != -1 {
|
||||
if bytes.HasPrefix(val[offset:], it.checkId[1:]) {
|
||||
return true
|
||||
|
|
@ -187,7 +187,7 @@ func (it *Iterator) Check(v graph.Value) bool {
|
|||
}
|
||||
|
||||
func (it *Iterator) Size() (int64, bool) {
|
||||
return it.ts.GetSizeFor(it.checkId), true
|
||||
return it.ts.SizeOf(it.checkId), true
|
||||
}
|
||||
|
||||
func (it *Iterator) DebugString(indent int) string {
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ func TestLoadDatabase(t *testing.T) {
|
|||
if s := ts.Size(); s != 11 {
|
||||
t.Errorf("Unexpected triplestore size, got:%d expect:11", s)
|
||||
}
|
||||
if s := ts.GetSizeFor(ts.ValueOf("B")); s != 5 {
|
||||
if s := ts.SizeOf(ts.ValueOf("B")); s != 5 {
|
||||
t.Errorf("Unexpected triplestore size, got:%d expect:5", s)
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ func TestLoadDatabase(t *testing.T) {
|
|||
if s := ts.Size(); s != 10 {
|
||||
t.Errorf("Unexpected triplestore size after RemoveTriple, got:%d expect:10", s)
|
||||
}
|
||||
if s := ts.GetSizeFor(ts.ValueOf("B")); s != 4 {
|
||||
if s := ts.SizeOf(ts.ValueOf("B")); s != 4 {
|
||||
t.Errorf("Unexpected triplestore size, got:%d expect:4", s)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ func (ts *TripleStore) ValueOf(s string) graph.Value {
|
|||
return ts.createValueKeyFor(s)
|
||||
}
|
||||
|
||||
func (ts *TripleStore) getValueData(value_key []byte) ValueData {
|
||||
func (ts *TripleStore) valueData(value_key []byte) ValueData {
|
||||
var out ValueData
|
||||
if glog.V(3) {
|
||||
glog.V(3).Infof("%s %v\n", string(value_key[0]), value_key)
|
||||
|
|
@ -357,14 +357,14 @@ func (ts *TripleStore) NameOf(k graph.Value) string {
|
|||
glog.V(2).Infoln("k was nil")
|
||||
return ""
|
||||
}
|
||||
return ts.getValueData(k.([]byte)).Name
|
||||
return ts.valueData(k.([]byte)).Name
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetSizeFor(k graph.Value) int64 {
|
||||
func (ts *TripleStore) SizeOf(k graph.Value) int64 {
|
||||
if k == nil {
|
||||
return 0
|
||||
}
|
||||
return int64(ts.getValueData(k.([]byte)).Size)
|
||||
return int64(ts.valueData(k.([]byte)).Size)
|
||||
}
|
||||
|
||||
func (ts *TripleStore) getSize() {
|
||||
|
|
@ -386,7 +386,7 @@ func (ts *TripleStore) getSize() {
|
|||
ts.size = size
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetApproximateSizeForPrefix(pre []byte) (int64, error) {
|
||||
func (ts *TripleStore) SizeOfPrefix(pre []byte) (int64, error) {
|
||||
limit := make([]byte, len(pre))
|
||||
copy(limit, pre)
|
||||
end := len(limit) - 1
|
||||
|
|
@ -428,7 +428,7 @@ func (ts *TripleStore) TriplesAllIterator() graph.Iterator {
|
|||
|
||||
func (ts *TripleStore) TripleDirection(val graph.Value, d graph.Direction) graph.Value {
|
||||
v := val.([]uint8)
|
||||
offset := GetPositionFromPrefix(v[0:2], d, ts)
|
||||
offset := PositionOf(v[0:2], d, ts)
|
||||
if offset != -1 {
|
||||
return append([]byte("z"), v[offset:offset+ts.hasher.Size()]...)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue