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

Method First

cursor.go:35–42  ·  view source on GitHub ↗

First moves the cursor to the first item in the bucket and returns its key and value. If the bucket is empty then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.

()

Source from the content-addressed store, hash-verified

33// If the bucket is empty then a nil key and value are returned.
34// The returned key and value are only valid for the life of the transaction.
35func (c *Cursor) First() (key []byte, value []byte) {
36 common.Assert(c.bucket.tx.db != nil, "tx closed")
37 k, v, flags := c.first()
38 if (flags & uint32(common.BucketLeafFlag)) != 0 {
39 return k, nil
40 }
41 return k, v
42}
43
44func (c *Cursor) first() (key []byte, value []byte, flags uint32) {
45 c.stack = c.stack[:0]

Callers 15

TestCursor_DeleteFunction · 0.80
TestCursor_EmptyBucketFunction · 0.80
TestCursor_Iterate_LeafFunction · 0.80
TestCursor_RestartFunction · 0.80
TestCursor_QuickCheckFunction · 0.80
ExampleCursorFunction · 0.80
TestBucket_Get_CapacityFunction · 0.80
ExampleDB_BeginFunction · 0.80

Calls 2

firstMethod · 0.95
AssertFunction · 0.92

Tested by 15

TestCursor_DeleteFunction · 0.64
TestCursor_EmptyBucketFunction · 0.64
TestCursor_Iterate_LeafFunction · 0.64
TestCursor_RestartFunction · 0.64
TestCursor_QuickCheckFunction · 0.64
ExampleCursorFunction · 0.64
TestBucket_Get_CapacityFunction · 0.64
ExampleDB_BeginFunction · 0.64