MCPcopy
hub / github.com/etcd-io/bbolt / search

Method search

cursor.go:283–302  ·  view source on GitHub ↗

search recursively performs a binary search against a given page/node until it finds a given key.

(key []byte, pgId common.Pgid)

Source from the content-addressed store, hash-verified

281
282// search recursively performs a binary search against a given page/node until it finds a given key.
283func (c *Cursor) search(key []byte, pgId common.Pgid) {
284 p, n := c.bucket.pageNode(pgId)
285 if p != nil && !p.IsBranchPage() && !p.IsLeafPage() {
286 panic(fmt.Sprintf("invalid page type: %d: %x", p.Id(), p.Flags()))
287 }
288 e := elemRef{page: p, node: n}
289 c.stack = append(c.stack, e)
290
291 // If we're on a leaf page/node then find the specific node.
292 if e.isLeaf() {
293 c.nsearch(key)
294 return
295 }
296
297 if n != nil {
298 c.searchNode(key, n)
299 return
300 }
301 c.searchPage(key, p)
302}
303
304func (c *Cursor) searchNode(key []byte, n *node) {
305 var exact bool

Callers 3

seekMethod · 0.95
searchNodeMethod · 0.95
searchPageMethod · 0.95

Calls 9

isLeafMethod · 0.95
nsearchMethod · 0.95
searchNodeMethod · 0.95
searchPageMethod · 0.95
pageNodeMethod · 0.80
IsBranchPageMethod · 0.80
IsLeafPageMethod · 0.80
IdMethod · 0.80
FlagsMethod · 0.45

Tested by

no test coverage detected