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

Method GetNext

pkg/database/iterators.go:112–137  ·  view source on GitHub ↗

GetNext returns the next unique Tuple from the two TupleIterators.

()

Source from the content-addressed store, hash-verified

110
111// GetNext returns the next unique Tuple from the two TupleIterators.
112func (i *UniqueAttributeIterator) GetNext() (*base.Attribute, bool) {
113 // Check the first iterator for any next Tuples
114 for i.iterator1.HasNext() {
115 attr := i.iterator1.GetNext() // Get the next Tuple
116 key := attr.GetEntity().GetType() + ":" + attr.GetEntity().GetId() + "$" + attr.GetAttribute()
117 // If the Tuple hasn't been visited yet, mark it as visited and return it
118 if _, found := i.visited[key]; !found {
119 i.visited[key] = true
120 return attr, true
121 }
122 }
123
124 // If no more unique Tuples are in the first iterator, check the second one
125 for i.iterator2.HasNext() {
126 attr := i.iterator2.GetNext() // Get the next Tuple
127 key := attr.GetEntity().GetType() + ":" + attr.GetEntity().GetId() + "$" + attr.GetAttribute()
128 // If the Tuple hasn't been visited yet, mark it as visited and return it
129 if _, found := i.visited[key]; !found {
130 i.visited[key] = true
131 return attr, true
132 }
133 }
134
135 // If no more unique Tuples are in either of the iterators, return nil
136 return &base.Attribute{}, false
137}
138
139// SUBJECT
140

Callers 7

expandDirectCallMethod · 0.95
attributeEntranceMethod · 0.95
pathChainEntranceMethod · 0.95
checkDirectCallMethod · 0.95

Calls 6

GetTypeMethod · 0.65
HasNextMethod · 0.45
GetNextMethod · 0.45
GetEntityMethod · 0.45
GetIdMethod · 0.45
GetAttributeMethod · 0.45

Tested by 2