ValueCopy returns a copy of the value of the item from the value log, writing it to dst slice. If nil is passed, or capacity of dst isn't sufficient, a new slice would be allocated and returned. Tip: It might make sense to reuse the returned slice as dst argument for the next call. This function is
(dst []byte)
| 120 | // This function is useful in long running iterate/update transactions to avoid a write deadlock. |
| 121 | // See Github issue: https://github.com/dgraph-io/badger/issues/315 |
| 122 | func (item *Item) ValueCopy(dst []byte) ([]byte, error) { |
| 123 | item.wg.Wait() |
| 124 | if item.status == prefetched { |
| 125 | return y.SafeCopy(dst, item.val), item.err |
| 126 | } |
| 127 | buf, cb, err := item.yieldItemValue() |
| 128 | defer runCallback(cb) |
| 129 | return y.SafeCopy(dst, buf), err |
| 130 | } |
| 131 | |
| 132 | func (item *Item) hasValue() bool { |
| 133 | if item.meta == 0 && item.vptr == nil { |