speedup and cleanup
This commit is contained in:
parent
d4e5eead32
commit
c3bd1644a1
1 changed files with 19 additions and 7 deletions
|
|
@ -233,12 +233,16 @@ func (it *Iterator) Contains(v graph.Value) bool {
|
||||||
}
|
}
|
||||||
offset := PositionOf(val[0:2], it.dir, it.qs)
|
offset := PositionOf(val[0:2], it.dir, it.qs)
|
||||||
if bytes.HasPrefix(val[offset:], it.checkId[1:]) {
|
if bytes.HasPrefix(val[offset:], it.checkId[1:]) {
|
||||||
data, err := it.qs.db.Get(val, it.ro)
|
// You may ask, why don't we check to see if it's a valid (not deleted) triple
|
||||||
if err != nil {
|
// again?
|
||||||
glog.Error("Couldn't get data for key ", val, " in iterator ", it.UID(), " failing Contains.")
|
//
|
||||||
return false
|
// We've already done that -- in order to get the graph.Value token in the
|
||||||
}
|
// first place, we had to have done the check already; it came from a Next().
|
||||||
return it.isLiveValue(data)
|
//
|
||||||
|
// However, if it ever starts coming from somewhere else, it'll be more
|
||||||
|
// efficient to change the interface of the graph.Value for LevelDB to a
|
||||||
|
// struct with a flag for isValid, to save another random read.
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +253,15 @@ func (it *Iterator) Size() (int64, bool) {
|
||||||
|
|
||||||
func (it *Iterator) DebugString(indent int) string {
|
func (it *Iterator) DebugString(indent int) string {
|
||||||
size, _ := it.Size()
|
size, _ := it.Size()
|
||||||
return fmt.Sprintf("%s(%s %d tags: %v dir: %s size:%d %s)", strings.Repeat(" ", indent), it.Type(), it.UID(), it.tags.Tags(), it.dir, size, it.qs.NameOf(it.checkId))
|
return fmt.Sprintf("%s(%s %d tags: %v dir: %s size:%d %s)",
|
||||||
|
strings.Repeat(" ", indent),
|
||||||
|
it.Type(),
|
||||||
|
it.UID(),
|
||||||
|
it.tags.Tags(),
|
||||||
|
it.dir,
|
||||||
|
size,
|
||||||
|
it.qs.NameOf(it.checkId),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var levelDBType graph.Type
|
var levelDBType graph.Type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue