()
| 42 | } |
| 43 | |
| 44 | func (c *Cursor) first() (key []byte, value []byte, flags uint32) { |
| 45 | c.stack = c.stack[:0] |
| 46 | p, n := c.bucket.pageNode(c.bucket.RootPage()) |
| 47 | c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) |
| 48 | c.goToFirstElementOnTheStack() |
| 49 | |
| 50 | // If we land on an empty page then move to the next value. |
| 51 | // https://github.com/boltdb/bolt/issues/450 |
| 52 | if c.stack[len(c.stack)-1].count() == 0 { |
| 53 | c.next() |
| 54 | } |
| 55 | |
| 56 | k, v, flags := c.keyValue() |
| 57 | if (flags & uint32(common.BucketLeafFlag)) != 0 { |
| 58 | return k, nil, flags |
| 59 | } |
| 60 | return k, v, flags |
| 61 | } |
| 62 | |
| 63 | // Last moves the cursor to the last item in the bucket and returns its key and value. |
| 64 | // If the bucket is empty then a nil key and value are returned. |
no test coverage detected