keyValue returns the key and value of the current leaf element.
()
| 368 | |
| 369 | // keyValue returns the key and value of the current leaf element. |
| 370 | func (c *Cursor) keyValue() ([]byte, []byte, uint32) { |
| 371 | ref := &c.stack[len(c.stack)-1] |
| 372 | |
| 373 | // If the cursor is pointing to the end of page/node then return nil. |
| 374 | if ref.count() == 0 || ref.index >= ref.count() { |
| 375 | return nil, nil, 0 |
| 376 | } |
| 377 | |
| 378 | // Retrieve value from node. |
| 379 | if ref.node != nil { |
| 380 | inode := &ref.node.inodes[ref.index] |
| 381 | return inode.Key(), inode.Value(), inode.Flags() |
| 382 | } |
| 383 | |
| 384 | // Or retrieve value from page. |
| 385 | elem := ref.page.LeafPageElement(uint16(ref.index)) |
| 386 | return elem.Key(), elem.Value(), elem.Flags() |
| 387 | } |
| 388 | |
| 389 | // node returns the node that the cursor is currently positioned on. |
| 390 | func (c *Cursor) node() *node { |