Remove redundant loggin functions
This commit is contained in:
parent
2f2f580858
commit
a31a5a170c
7 changed files with 38 additions and 74 deletions
|
|
@ -67,9 +67,9 @@ func (it *Int64) DebugString(indent int) string {
|
|||
// Next() on an Int64 all iterator is a simple incrementing counter.
|
||||
// Return the next integer, and mark it as the result.
|
||||
func (it *Int64) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
if it.at == -1 {
|
||||
return NextLogOut(it, nil, false)
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
val := it.at
|
||||
it.at = it.at + 1
|
||||
|
|
@ -77,7 +77,7 @@ func (it *Int64) Next() (graph.TSVal, bool) {
|
|||
it.at = -1
|
||||
}
|
||||
it.Last = val
|
||||
return NextLogOut(it, val, true)
|
||||
return graph.NextLogOut(it, val, true)
|
||||
}
|
||||
|
||||
// The number of elements in an Int64 is the size of the range.
|
||||
|
|
@ -90,13 +90,13 @@ func (it *Int64) Size() (int64, bool) {
|
|||
// Check() for an Int64 is merely seeing if the passed value is
|
||||
// withing the range, assuming the value is an int64.
|
||||
func (it *Int64) Check(tsv graph.TSVal) bool {
|
||||
CheckLogIn(it, tsv)
|
||||
graph.CheckLogIn(it, tsv)
|
||||
v := tsv.(int64)
|
||||
if it.min <= v && v <= it.max {
|
||||
it.Last = v
|
||||
return CheckLogOut(it, v, true)
|
||||
return graph.CheckLogOut(it, v, true)
|
||||
}
|
||||
return CheckLogOut(it, v, false)
|
||||
return graph.CheckLogOut(it, v, false)
|
||||
}
|
||||
|
||||
// The type of this iterator is an "all". This is important, as it puts it in
|
||||
|
|
|
|||
|
|
@ -139,17 +139,17 @@ func (it *And) AddSubIterator(sub graph.Iterator) {
|
|||
// candidate, and check this value against the subiterators. A productive choice
|
||||
// of primary iterator is therefore very important.
|
||||
func (it *And) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
var curr graph.TSVal
|
||||
var exists bool
|
||||
for {
|
||||
curr, exists = it.primaryIt.Next()
|
||||
if !exists {
|
||||
return NextLogOut(it, nil, false)
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
if it.checkSubIts(curr) {
|
||||
it.Last = curr
|
||||
return NextLogOut(it, curr, true)
|
||||
return graph.NextLogOut(it, curr, true)
|
||||
}
|
||||
}
|
||||
panic("Somehow broke out of Next() loop in And")
|
||||
|
|
@ -178,25 +178,25 @@ func (it *And) checkCheckList(val graph.TSVal) bool {
|
|||
if ok {
|
||||
it.Last = val
|
||||
}
|
||||
return CheckLogOut(it, val, ok)
|
||||
return graph.CheckLogOut(it, val, ok)
|
||||
}
|
||||
|
||||
// Check a value against the entire iterator, in order.
|
||||
func (it *And) Check(val graph.TSVal) bool {
|
||||
CheckLogIn(it, val)
|
||||
graph.CheckLogIn(it, val)
|
||||
if it.checkList != nil {
|
||||
return it.checkCheckList(val)
|
||||
}
|
||||
mainGood := it.primaryIt.Check(val)
|
||||
if !mainGood {
|
||||
return CheckLogOut(it, val, false)
|
||||
return graph.CheckLogOut(it, val, false)
|
||||
}
|
||||
othersGood := it.checkSubIts(val)
|
||||
if !othersGood {
|
||||
return CheckLogOut(it, val, false)
|
||||
return graph.CheckLogOut(it, val, false)
|
||||
}
|
||||
it.Last = val
|
||||
return CheckLogOut(it, val, true)
|
||||
return graph.CheckLogOut(it, val, true)
|
||||
}
|
||||
|
||||
// Returns the approximate size of the And iterator. Because we're dealing
|
||||
|
|
|
|||
|
|
@ -108,26 +108,26 @@ func (it *Fixed) Check(v graph.TSVal) bool {
|
|||
// Could be optimized by keeping it sorted or using a better datastructure.
|
||||
// However, for fixed iterators, which are by definition kind of tiny, this
|
||||
// isn't a big issue.
|
||||
CheckLogIn(it, v)
|
||||
graph.CheckLogIn(it, v)
|
||||
for _, x := range it.values {
|
||||
if it.cmp(x, v) {
|
||||
it.Last = x
|
||||
return CheckLogOut(it, v, true)
|
||||
return graph.CheckLogOut(it, v, true)
|
||||
}
|
||||
}
|
||||
return CheckLogOut(it, v, false)
|
||||
return graph.CheckLogOut(it, v, false)
|
||||
}
|
||||
|
||||
// Return the next stored value from the iterator.
|
||||
func (it *Fixed) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
if it.lastIndex == len(it.values) {
|
||||
return NextLogOut(it, nil, false)
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
out := it.values[it.lastIndex]
|
||||
it.Last = out
|
||||
it.lastIndex++
|
||||
return NextLogOut(it, out, true)
|
||||
return graph.NextLogOut(it, out, true)
|
||||
}
|
||||
|
||||
// Optimize() for a Fixed iterator is simple. Returns a Null iterator if it's empty
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func (it *HasA) DebugString(indent int) string {
|
|||
// iterator of "triples that have `val` in our direction", given to us by the triple store,
|
||||
// and then Next() values out of that iterator and Check() them against our subiterator.
|
||||
func (it *HasA) Check(val graph.TSVal) bool {
|
||||
CheckLogIn(it, val)
|
||||
graph.CheckLogIn(it, val)
|
||||
if glog.V(4) {
|
||||
glog.V(4).Infoln("Id is", it.ts.GetNameFor(val))
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ func (it *HasA) Check(val graph.TSVal) bool {
|
|||
it.resultIt.Close()
|
||||
}
|
||||
it.resultIt = it.ts.GetTripleIterator(it.dir, val)
|
||||
return CheckLogOut(it, val, it.GetCheckResult())
|
||||
return graph.CheckLogOut(it, val, it.GetCheckResult())
|
||||
}
|
||||
|
||||
// GetCheckResult() is shared code between Check() and GetNextResult() -- calls next on the
|
||||
|
|
@ -174,7 +174,7 @@ func (it *HasA) NextResult() bool {
|
|||
// subiterator we can get a value from, and we can take that resultant triple,
|
||||
// pull our direction out of it, and return that.
|
||||
func (it *HasA) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
if it.resultIt != nil {
|
||||
it.resultIt.Close()
|
||||
}
|
||||
|
|
@ -182,12 +182,12 @@ func (it *HasA) Next() (graph.TSVal, bool) {
|
|||
|
||||
tID, ok := it.primaryIt.Next()
|
||||
if !ok {
|
||||
return NextLogOut(it, 0, false)
|
||||
return graph.NextLogOut(it, 0, false)
|
||||
}
|
||||
name := it.ts.GetTriple(tID).Get(it.dir)
|
||||
val := it.ts.GetIdFor(name)
|
||||
it.Last = val
|
||||
return NextLogOut(it, val, true)
|
||||
return graph.NextLogOut(it, val, true)
|
||||
}
|
||||
|
||||
// GetStats() returns the statistics on the HasA iterator. This is curious. Next
|
||||
|
|
|
|||
|
|
@ -185,39 +185,3 @@ func (it *Null) DebugString(indent int) string {
|
|||
func (it *Null) GetStats() *graph.IteratorStats {
|
||||
return &graph.IteratorStats{}
|
||||
}
|
||||
|
||||
// Utility logging functions for when an iterator gets called Next upon, or Check upon, as
|
||||
// well as what they return. Highly useful for tracing the execution path of a query.
|
||||
func CheckLogIn(it graph.Iterator, val graph.TSVal) {
|
||||
if glog.V(4) {
|
||||
glog.V(4).Infof("%s %d CHECK %d", strings.ToUpper(it.Type()), it.GetUid(), val)
|
||||
}
|
||||
}
|
||||
|
||||
func CheckLogOut(it graph.Iterator, val graph.TSVal, good bool) bool {
|
||||
if glog.V(4) {
|
||||
if good {
|
||||
glog.V(4).Infof("%s %d CHECK %d GOOD", strings.ToUpper(it.Type()), it.GetUid(), val)
|
||||
} else {
|
||||
glog.V(4).Infof("%s %d CHECK %d BAD", strings.ToUpper(it.Type()), it.GetUid(), val)
|
||||
}
|
||||
}
|
||||
return good
|
||||
}
|
||||
|
||||
func NextLogIn(it graph.Iterator) {
|
||||
if glog.V(4) {
|
||||
glog.V(4).Infof("%s %d NEXT", strings.ToUpper(it.Type()), it.GetUid())
|
||||
}
|
||||
}
|
||||
|
||||
func NextLogOut(it graph.Iterator, val graph.TSVal, ok bool) (graph.TSVal, bool) {
|
||||
if glog.V(4) {
|
||||
if ok {
|
||||
glog.V(4).Infof("%s %d NEXT IS %d", strings.ToUpper(it.Type()), it.GetUid(), val)
|
||||
} else {
|
||||
glog.V(4).Infof("%s %d NEXT DONE", strings.ToUpper(it.Type()), it.GetUid())
|
||||
}
|
||||
}
|
||||
return val, ok
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ func (it *LinksTo) DebugString(indent int) string {
|
|||
// If it checks in the right direction for the subiterator, it is a valid link
|
||||
// for the LinksTo.
|
||||
func (it *LinksTo) Check(val graph.TSVal) bool {
|
||||
CheckLogIn(it, val)
|
||||
graph.CheckLogIn(it, val)
|
||||
node := it.ts.GetTripleDirection(val, it.dir)
|
||||
if it.primaryIt.Check(node) {
|
||||
it.Last = val
|
||||
return CheckLogOut(it, val, true)
|
||||
return graph.CheckLogOut(it, val, true)
|
||||
}
|
||||
return CheckLogOut(it, val, false)
|
||||
return graph.CheckLogOut(it, val, false)
|
||||
}
|
||||
|
||||
// Return a list containing only our subiterator.
|
||||
|
|
@ -136,14 +136,14 @@ func (it *LinksTo) Optimize() (graph.Iterator, bool) {
|
|||
|
||||
// Next()ing a LinksTo operates as described above.
|
||||
func (it *LinksTo) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
val, ok := it.nextIt.Next()
|
||||
if !ok {
|
||||
// Subiterator is empty, get another one
|
||||
candidate, ok := it.primaryIt.Next()
|
||||
if !ok {
|
||||
// We're out of nodes in our subiterator, so we're done as well.
|
||||
return NextLogOut(it, 0, false)
|
||||
return graph.NextLogOut(it, 0, false)
|
||||
}
|
||||
it.nextIt.Close()
|
||||
it.nextIt = it.ts.GetTripleIterator(it.dir, candidate)
|
||||
|
|
@ -151,7 +151,7 @@ func (it *LinksTo) Next() (graph.TSVal, bool) {
|
|||
return it.Next()
|
||||
}
|
||||
it.Last = val
|
||||
return NextLogOut(it, val, ok)
|
||||
return graph.NextLogOut(it, val, ok)
|
||||
}
|
||||
|
||||
// Close our subiterators.
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ func (it *Or) AddSubIterator(sub graph.Iterator) {
|
|||
// union of its subiterators, it must produce from all subiterators -- unless
|
||||
// it's shortcircuiting, in which case, it's the first one that returns anything.
|
||||
func (it *Or) Next() (graph.TSVal, bool) {
|
||||
NextLogIn(it)
|
||||
graph.NextLogIn(it)
|
||||
var curr graph.TSVal
|
||||
var exists bool
|
||||
firstTime := false
|
||||
|
|
@ -142,15 +142,15 @@ func (it *Or) Next() (graph.TSVal, bool) {
|
|||
curr, exists = curIt.Next()
|
||||
if !exists {
|
||||
if it.isShortCircuiting && !firstTime {
|
||||
return NextLogOut(it, nil, false)
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
it.currentIterator++
|
||||
if it.currentIterator == it.itCount {
|
||||
return NextLogOut(it, nil, false)
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
} else {
|
||||
it.Last = curr
|
||||
return NextLogOut(it, curr, true)
|
||||
return graph.NextLogOut(it, curr, true)
|
||||
}
|
||||
}
|
||||
panic("Somehow broke out of Next() loop in Or")
|
||||
|
|
@ -171,13 +171,13 @@ func (it *Or) checkSubIts(val graph.TSVal) bool {
|
|||
|
||||
// Check a value against the entire graph.iterator, in order.
|
||||
func (it *Or) Check(val graph.TSVal) bool {
|
||||
CheckLogIn(it, val)
|
||||
graph.CheckLogIn(it, val)
|
||||
anyGood := it.checkSubIts(val)
|
||||
if !anyGood {
|
||||
return CheckLogOut(it, val, false)
|
||||
return graph.CheckLogOut(it, val, false)
|
||||
}
|
||||
it.Last = val
|
||||
return CheckLogOut(it, val, true)
|
||||
return graph.CheckLogOut(it, val, true)
|
||||
}
|
||||
|
||||
// Returns the approximate size of the Or graph.iterator. Because we're dealing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue