generalize Linkage, add relevant comments
This commit is contained in:
parent
6201e709ef
commit
355c8ee6bc
5 changed files with 33 additions and 18 deletions
|
|
@ -34,7 +34,8 @@ type And struct {
|
|||
qs graph.QuadStore
|
||||
}
|
||||
|
||||
// Creates a new And iterator.
|
||||
// NewAnd creates an And iterator. `qs` is only required when needing a handle
|
||||
// for QuadStore-specific optimizations, otherwise nil is acceptable.
|
||||
func NewAnd(qs graph.QuadStore) *And {
|
||||
return &And{
|
||||
uid: NextUID(),
|
||||
|
|
|
|||
|
|
@ -99,10 +99,12 @@ func (it *And) Optimize() (graph.Iterator, bool) {
|
|||
// Ask the graph.QuadStore if we can be replaced. Often times, this is a great
|
||||
// optimization opportunity (there's a fixed iterator underneath us, for
|
||||
// example).
|
||||
newReplacement, hasOne := it.qs.OptimizeIterator(newAnd)
|
||||
if hasOne {
|
||||
newAnd.Close()
|
||||
return newReplacement, true
|
||||
if it.qs != nil {
|
||||
newReplacement, hasOne := it.qs.OptimizeIterator(newAnd)
|
||||
if hasOne {
|
||||
newAnd.Close()
|
||||
return newReplacement, true
|
||||
}
|
||||
}
|
||||
|
||||
return newAnd, true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue