Skip to content

Commit

Permalink
Fix aborted materialization
Browse files Browse the repository at this point in the history
  • Loading branch information
barakmich committed Aug 11, 2014
1 parent 11c3cd1 commit aad21b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions graph/iterator/materialize_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (it *Materialize) TagResults(dst map[string]graph.Value) {
}
if it.aborted {
it.subIt.TagResults(dst)
for _, tag := range it.tags.Tags() {
dst[tag] = it.Result()
}
return
}
if it.Result() == nil {
Expand Down Expand Up @@ -134,6 +137,9 @@ func (it *Materialize) ResultTree() *graph.ResultTree {
}

func (it *Materialize) Result() graph.Value {
if it.aborted {
return it.subIt.Result()
}
if len(it.values) == 0 {
return nil
}
Expand Down Expand Up @@ -164,7 +170,7 @@ func (it *Materialize) Optimize() (graph.Iterator, bool) {
// Size is the number of values stored, if we've got them all.
// Otherwise, guess based on the size of the subiterator.
func (it *Materialize) Size() (int64, bool) {
if it.hasRun {
if it.hasRun && !it.aborted {
return int64(len(it.values)), true
}
return it.subIt.Size()
Expand Down Expand Up @@ -265,10 +271,12 @@ func (it *Materialize) materializeSet() {
}
}
if it.aborted {
if glog.V(2) {
glog.V(2).Infoln("Aborting subiterator")
}
it.values = nil
it.containsMap = nil
it.subIt.Reset()
}
glog.Infof("Materialization List %d: %#v", it.values)
it.hasRun = true
}

2 comments on commit aad21b0

@kortschak
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@kortschak
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gravy for this is here. I don't want to send a PR for this until your behemoth is in since they collide heavily, but it shows that it is a worthwhile move.

Please sign in to comment.