Fix hashability for graph.Value
This commit is contained in:
parent
2bec255b52
commit
6f1e46c2d8
4 changed files with 41 additions and 19 deletions
|
|
@ -32,6 +32,10 @@ type result struct {
|
|||
tags map[string]graph.Value
|
||||
}
|
||||
|
||||
type hashable interface {
|
||||
Hashable() interface{}
|
||||
}
|
||||
|
||||
type Materialize struct {
|
||||
uid uint64
|
||||
tags graph.Tagger
|
||||
|
|
@ -228,7 +232,7 @@ func (it *Materialize) NextResult() bool {
|
|||
func (it *Materialize) materializeSet() {
|
||||
i := 0
|
||||
for {
|
||||
val, ok := graph.Next(it.subIt)
|
||||
id, ok := graph.Next(it.subIt)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
|
@ -237,6 +241,10 @@ func (it *Materialize) materializeSet() {
|
|||
it.aborted = true
|
||||
break
|
||||
}
|
||||
val := id
|
||||
if h, ok := id.(hashable); ok {
|
||||
val = h.Hashable()
|
||||
}
|
||||
if _, ok := it.containsMap[val]; !ok {
|
||||
it.containsMap[val] = len(it.values)
|
||||
it.values = append(it.values, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue