GetNext returns the next unique Tuple from the two TupleIterators.
()
| 60 | |
| 61 | // GetNext returns the next unique Tuple from the two TupleIterators. |
| 62 | func (i *UniqueTupleIterator) GetNext() (*base.Tuple, bool) { |
| 63 | // Check the first iterator for any next Tuples |
| 64 | for i.iterator1.HasNext() { |
| 65 | tup := i.iterator1.GetNext() // Get the next Tuple |
| 66 | key := tuple.ToString(tup) |
| 67 | // If the Tuple hasn't been visited yet, mark it as visited and return it |
| 68 | if _, found := i.visited[key]; !found { |
| 69 | i.visited[key] = true |
| 70 | return tup, true |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // If no more unique Tuples are in the first iterator, check the second one |
| 75 | for i.iterator2.HasNext() { |
| 76 | tup := i.iterator2.GetNext() // Get the next Tuple |
| 77 | key := tuple.ToString(tup) |
| 78 | // If the Tuple hasn't been visited yet, mark it as visited and return it |
| 79 | if _, found := i.visited[key]; !found { |
| 80 | i.visited[key] = true |
| 81 | return tup, true |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // If no more unique Tuples are in either of the iterators, return nil |
| 86 | return &base.Tuple{}, false |
| 87 | } |
| 88 | |
| 89 | // UniqueAttributeIterator combines two AttributeIterators and ensures that only unique Attributes are returned. |
| 90 | // Uniqueness is based on the Attribute's pointer address. |