Enumerate iterator types
This commit is contained in:
parent
1f67913ed9
commit
cd46452b63
23 changed files with 145 additions and 68 deletions
|
|
@ -101,12 +101,18 @@ func (it *Iterator) DebugString(indent int) string {
|
|||
return fmt.Sprintf("%s(%s tags:%s size:%d %s)", strings.Repeat(" ", indent), it.Type(), it.Tags(), size, it.data)
|
||||
}
|
||||
|
||||
func (it *Iterator) Type() string {
|
||||
return "llrb"
|
||||
}
|
||||
func (it *Iterator) Sorted() bool {
|
||||
return true
|
||||
var memType graph.Type
|
||||
|
||||
func init() {
|
||||
memType = graph.Register("llrb")
|
||||
}
|
||||
|
||||
func Type() graph.Type { return memType }
|
||||
|
||||
func (it *Iterator) Type() graph.Type { return memType }
|
||||
|
||||
func (it *Iterator) Sorted() bool { return true }
|
||||
|
||||
func (it *Iterator) Optimize() (graph.Iterator, bool) {
|
||||
return it, false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
func (ts *TripleStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
|
||||
switch it.Type() {
|
||||
case "linksto":
|
||||
case graph.LinksTo:
|
||||
return ts.optimizeLinksTo(it.(*iterator.LinksTo))
|
||||
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ func (ts *TripleStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bo
|
|||
return it, false
|
||||
}
|
||||
primary := subs[0]
|
||||
if primary.Type() == "fixed" {
|
||||
if primary.Type() == graph.Fixed {
|
||||
size, _ := primary.Size()
|
||||
if size == 1 {
|
||||
val, ok := primary.Next()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func TestLinksToOptimization(t *testing.T) {
|
|||
if !changed {
|
||||
t.Error("Iterator didn't change")
|
||||
}
|
||||
if newIt.Type() != "llrb" {
|
||||
if newIt.Type() != Type() {
|
||||
t.Fatal("Didn't swap out to LLRB")
|
||||
}
|
||||
v := newIt.(*Iterator)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue