MCPcopy
hub / github.com/olric-data/olric / next

Method next

cluster_iterator.go:202–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200}
201
202func (i *ClusterIterator) next() bool {
203 if len(i.page) != 0 {
204 i.pos++
205 if i.pos <= len(i.page) {
206 return true
207 }
208 }
209
210 i.resetPage()
211
212 for {
213 if err := i.fetchData(); err != nil {
214 i.logger.Printf("[ERROR] Failed to fetch data: %s", err)
215 return false
216 }
217 if len(i.page) != 0 {
218 // We have data on the page to read. Stop the iteration.
219 break
220 }
221
222 if len(i.route.PrimaryOwners) == 0 && len(i.route.ReplicaOwners) == 0 {
223 // We completed scanning all the owners. Stop the iteration.
224 break
225 }
226 }
227
228 if len(i.page) == 0 && len(i.route.PrimaryOwners) == 0 && len(i.route.ReplicaOwners) == 0 {
229 i.partID++
230 if i.partID >= i.partitionCount {
231 return false
232 }
233 i.reset()
234 return i.next()
235 }
236 i.pos = 1
237 return true
238}
239
240// Next returns true if there is more key in the iterator implementation.
241// Otherwise, it returns false

Callers 1

NextMethod · 0.95

Calls 4

resetPageMethod · 0.95
fetchDataMethod · 0.95
resetMethod · 0.95
PrintfMethod · 0.80

Tested by

no test coverage detected