first moves the cursor to the first leaf element under the last page in the stack.
()
| 167 | |
| 168 | // first moves the cursor to the first leaf element under the last page in the stack. |
| 169 | func (c *Cursor) goToFirstElementOnTheStack() { |
| 170 | for { |
| 171 | // Exit when we hit a leaf page. |
| 172 | var ref = &c.stack[len(c.stack)-1] |
| 173 | if ref.isLeaf() { |
| 174 | break |
| 175 | } |
| 176 | |
| 177 | // Keep adding pages pointing to the first element to the stack. |
| 178 | var pgId common.Pgid |
| 179 | if ref.node != nil { |
| 180 | pgId = ref.node.inodes[ref.index].Pgid() |
| 181 | } else { |
| 182 | pgId = ref.page.BranchPageElement(uint16(ref.index)).Pgid() |
| 183 | } |
| 184 | p, n := c.bucket.pageNode(pgId) |
| 185 | c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | // last moves the cursor to the last leaf element under the last page in the stack. |
| 190 | func (c *Cursor) last() { |