Current returns ErrIteratorDone if the iterator is done. Otherwise, Current() returns the current key and val, which should be treated as immutable or read-only. The key and val bytes will remain available until the next call to Next() or Close().
()
| 373 | // be treated as immutable or read-only. The key and val bytes will |
| 374 | // remain available until the next call to Next() or Close(). |
| 375 | func (iter *iterator) Current() ([]byte, []byte, error) { |
| 376 | entryEx, key, val, err := iter.CurrentEx() |
| 377 | if err != nil { |
| 378 | return nil, nil, err |
| 379 | } |
| 380 | |
| 381 | op := entryEx.Operation |
| 382 | if op == OperationDel { |
| 383 | return nil, nil, nil |
| 384 | } |
| 385 | |
| 386 | if op == OperationMerge { |
| 387 | var valMerged []byte |
| 388 | valMerged, err = iter.ss.getMerged(key, val, iter.cursors[0].ssIndex-1, |
| 389 | iter.iteratorOptions.base, ReadOptions{}) |
| 390 | if err != nil { |
| 391 | return nil, nil, err |
| 392 | } |
| 393 | |
| 394 | return key, valMerged, nil |
| 395 | } |
| 396 | |
| 397 | return key, val, err |
| 398 | } |
| 399 | |
| 400 | // CurrentEx is a more advanced form of Current() that returns more |
| 401 | // metadata. It is used when IteratorOptions.IncludeDeletions is |