| 261 | } |
| 262 | |
| 263 | func (it *iteratorNext) Next(ctx context.Context) bool { |
| 264 | if it.err != nil { |
| 265 | return false |
| 266 | } |
| 267 | if it.cursor == nil { |
| 268 | it.cursor, it.err = it.qs.Query(ctx, it.query) |
| 269 | } |
| 270 | // TODO(dennwc): this loop exists only because of nextPath workaround |
| 271 | for { |
| 272 | if it.err != nil { |
| 273 | return false |
| 274 | } |
| 275 | if it.nextPathRes != nil { |
| 276 | it.res = it.nextPathRes |
| 277 | it.tags = it.nextPathTags |
| 278 | it.nextPathRes = nil |
| 279 | it.nextPathTags = nil |
| 280 | return true |
| 281 | } |
| 282 | if !it.cursor.Next() { |
| 283 | it.err = it.cursor.Err() |
| 284 | it.cursor.Close() |
| 285 | return false |
| 286 | } |
| 287 | |
| 288 | prev := it.res |
| 289 | if !it.scanValue(it.cursor) { |
| 290 | return false |
| 291 | } |
| 292 | if !it.query.nextPath { |
| 293 | return true |
| 294 | } |
| 295 | if prev == nil || prev.Key() != it.res.Key() { |
| 296 | return true |
| 297 | } |
| 298 | // skip the same main key if in nextPath mode |
| 299 | // the user should receive accept those results via NextPath of the iterator |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | func (it *iteratorNext) NextPath(ctx context.Context) bool { |
| 304 | if it.err != nil { |