MCPcopy
hub / github.com/dgraph-io/badger / Value

Method Value

iterator.go:95–114  ·  view source on GitHub ↗

Value retrieves the value of the item from the value log. This method must be called within a transaction. Calling it outside a transaction is considered undefined behavior. If an iterator is being used, then Item.Value() is defined in the current iteration only, because items are reused. If you n

(fn func(val []byte) error)

Source from the content-addressed store, hash-verified

93// instead, or copy it yourself. Value might change once discard or commit is called.
94// Use ValueCopy if you want to do a Set after Get.
95func (item *Item) Value(fn func(val []byte) error) error {
96 item.wg.Wait()
97 if item.status == prefetched {
98 if item.err == nil && fn != nil {
99 if err := fn(item.val); err != nil {
100 return err
101 }
102 }
103 return item.err
104 }
105 buf, cb, err := item.yieldItemValue()
106 defer runCallback(cb)
107 if err != nil {
108 return err
109 }
110 if fn != nil {
111 return fn(buf)
112 }
113 return nil
114}
115
116// ValueCopy returns a copy of the value of the item from the value log, writing it to dst slice.
117// If nil is passed, or capacity of dst isn't sufficient, a new slice would be allocated and

Callers

nothing calls this directly

Calls 3

yieldItemValueMethod · 0.95
runCallbackFunction · 0.85
WaitMethod · 0.45

Tested by

no test coverage detected