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) {
|
func (it *AllIterator) Size() (int64, bool) {
|
||||||
size, err := it.ts.GetApproximateSizeForPrefix(it.prefix)
|
size, err := it.ts.SizeOfPrefix(it.prefix)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return size, false
|
return size, false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
||||||
return nil, false
|
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")) {
|
if bytes.Equal(prefix, []byte("sp")) {
|
||||||
switch d {
|
switch d {
|
||||||
case graph.Subject:
|
case graph.Subject:
|
||||||
|
|
@ -171,7 +171,7 @@ func (it *Iterator) Check(v graph.Value) bool {
|
||||||
if val[0] == 'z' {
|
if val[0] == 'z' {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
offset := GetPositionFromPrefix(val[0:2], it.dir, it.ts)
|
offset := PositionOf(val[0:2], it.dir, it.ts)
|
||||||
if offset != -1 {
|
if offset != -1 {
|
||||||
if bytes.HasPrefix(val[offset:], it.checkId[1:]) {
|
if bytes.HasPrefix(val[offset:], it.checkId[1:]) {
|
||||||
return true
|
return true
|
||||||
|
|
@ -187,7 +187,7 @@ func (it *Iterator) Check(v graph.Value) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *Iterator) Size() (int64, 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 {
|
func (it *Iterator) DebugString(indent int) string {
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ func TestLoadDatabase(t *testing.T) {
|
||||||
if s := ts.Size(); s != 11 {
|
if s := ts.Size(); s != 11 {
|
||||||
t.Errorf("Unexpected triplestore size, got:%d expect:11", s)
|
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)
|
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 {
|
if s := ts.Size(); s != 10 {
|
||||||
t.Errorf("Unexpected triplestore size after RemoveTriple, got:%d expect:10", s)
|
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)
|
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)
|
return ts.createValueKeyFor(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TripleStore) getValueData(value_key []byte) ValueData {
|
func (ts *TripleStore) valueData(value_key []byte) ValueData {
|
||||||
var out ValueData
|
var out ValueData
|
||||||
if glog.V(3) {
|
if glog.V(3) {
|
||||||
glog.V(3).Infof("%s %v\n", string(value_key[0]), value_key)
|
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")
|
glog.V(2).Infoln("k was nil")
|
||||||
return ""
|
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 {
|
if k == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return int64(ts.getValueData(k.([]byte)).Size)
|
return int64(ts.valueData(k.([]byte)).Size)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TripleStore) getSize() {
|
func (ts *TripleStore) getSize() {
|
||||||
|
|
@ -386,7 +386,7 @@ func (ts *TripleStore) getSize() {
|
||||||
ts.size = size
|
ts.size = size
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TripleStore) GetApproximateSizeForPrefix(pre []byte) (int64, error) {
|
func (ts *TripleStore) SizeOfPrefix(pre []byte) (int64, error) {
|
||||||
limit := make([]byte, len(pre))
|
limit := make([]byte, len(pre))
|
||||||
copy(limit, pre)
|
copy(limit, pre)
|
||||||
end := len(limit) - 1
|
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 {
|
func (ts *TripleStore) TripleDirection(val graph.Value, d graph.Direction) graph.Value {
|
||||||
v := val.([]uint8)
|
v := val.([]uint8)
|
||||||
offset := GetPositionFromPrefix(v[0:2], d, ts)
|
offset := PositionOf(v[0:2], d, ts)
|
||||||
if offset != -1 {
|
if offset != -1 {
|
||||||
return append([]byte("z"), v[offset:offset+ts.hasher.Size()]...)
|
return append([]byte("z"), v[offset:offset+ts.hasher.Size()]...)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue