iterator.go
func (item *Item) ValueCopy(dst []byte) ([]byte, error) {
	item.wg.Wait()
	if item.status == prefetched {
		return y.SafeCopy(dst, item.val), item.err
	}
	buf, cb, err := item.yieldItemValue()
	defer runCallback(cb)
	return y.SafeCopy(dst, buf), err
}
func (item *Item) ValueCopy(dst []byte) ([]byte, error) {
	item.wg.Wait()
	if item.status == prefetched {
		return y.SafeCopy(dst, item.val), item.err
	}
	buf, cb, err := item.yieldItemValue()
	defer runCallback(cb)
	return y.SafeCopy(dst, buf), err
}
func ( item * Item ) ValueCopy ( dst [ ] byte ) ( [ ] byte , error ) { item . wg . Wait ( ) if item . status == prefetched { return y . SafeCopy ( dst , item . val ) , item . err } buf , cb , err := item . yieldItemValue ( ) defer runCallback ( cb ) return y . SafeCopy ( dst , buf ) , err }
// 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 useful in long running iterate/update transactions to avoid a write deadlock.
// See Github issue: https://github.com/dgraph-io/badger/issues/315
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 useful in long running iterate / update transactions to avoid a write deadlock . See Github issue : https : // github . com / dgraph - io / badger / issues / 315