MCPcopy Create free account
hub / github.com/Permify/permify / GetNext

Method GetNext

pkg/database/iterators.go:62–87  ·  view source on GitHub ↗

GetNext returns the next unique Tuple from the two TupleIterators.

()

Source from the content-addressed store, hash-verified

60
61// GetNext returns the next unique Tuple from the two TupleIterators.
62func (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.

Callers 12

TestUniqueTupleIteratorFunction · 0.95
expandDirectRelationMethod · 0.95
expandTupleToUserSetMethod · 0.95
relationEntranceMethod · 0.95
pathChainEntranceMethod · 0.95
checkDirectRelationMethod · 0.95
checkTupleToUserSetMethod · 0.95

Calls 3

ToStringFunction · 0.92
HasNextMethod · 0.45
GetNextMethod · 0.45

Tested by 2

TestUniqueTupleIteratorFunction · 0.76