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

Method ValueCopy

iterator.go:122–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
122func (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
132func (item *Item) hasValue() bool {
133 if item.meta == 0 && item.vptr == nil {

Callers 15

BackupMethod · 0.45
TestWriteBatchFunction · 0.45
TestWriteBatchManagedFunction · 0.45
ToListMethod · 0.45
iterateAndMergeMethod · 0.45
getItemValueFunction · 0.45
TestWriteDeadlockFunction · 0.45
TestSequence_ReleaseFunction · 0.45
TestReadOnlyFunction · 0.45

Calls 4

yieldItemValueMethod · 0.95
SafeCopyFunction · 0.92
runCallbackFunction · 0.85
WaitMethod · 0.45

Tested by 15

TestWriteBatchFunction · 0.36
TestWriteBatchManagedFunction · 0.36
getItemValueFunction · 0.36
TestWriteDeadlockFunction · 0.36
TestSequence_ReleaseFunction · 0.36
TestReadOnlyFunction · 0.36
ExampleOpenFunction · 0.36
TestTxnReadAfterWriteFunction · 0.36
TestTxnCommitAsyncFunction · 0.36