materialize implementation and and optimization

This commit is contained in:
Barak Michener 2014-08-06 02:55:36 -04:00
parent f441fc4bbf
commit 09244ddd38
3 changed files with 267 additions and 0 deletions

View file

@ -153,6 +153,19 @@ func Next(it Iterator) (Value, bool) {
return nil, false
}
// Height is a convienence function to measure the height of an iterator tree.
func Height(it Iterator) int {
subs := it.SubIterators()
maxDepth := 0
for _, sub := range subs {
h := Height(sub)
if h > maxDepth {
maxDepth = h
}
}
return maxDepth + 1
}
// FixedIterator wraps iterators that are modifiable by addition of fixed value sets.
type FixedIterator interface {
Iterator
@ -180,6 +193,7 @@ const (
Fixed
Not
Optional
Materialize
)
var (
@ -200,6 +214,7 @@ var (
"fixed",
"not",
"optional",
"materialize",
}
)