MCPcopy Create free account
hub / github.com/couchbase/moss / Current

Method Current

iterator_single.go:118–145  ·  view source on GitHub ↗

Current returns ErrIteratorDone if the iterator is done. Otherwise, Current() returns the current key and val, which should be treated as immutable or read-only. The key and val bytes will remain available until the next call to Next() or Close().

()

Source from the content-addressed store, hash-verified

116// be treated as immutable or read-only. The key and val bytes will
117// remain available until the next call to Next() or Close().
118func (iter *iteratorSingle) Current() ([]byte, []byte, error) {
119 if iter.op == 0 {
120 return nil, nil, ErrIteratorDone
121 }
122
123 if iter.op == OperationDel {
124 return nil, nil, nil
125 }
126
127 if iter.op == OperationMerge {
128 var mo MergeOperator
129 if iter.options != nil {
130 mo = iter.options.MergeOperator
131 }
132 if mo == nil {
133 return iter.k, nil, ErrMergeOperatorNil
134 }
135
136 vMerged, ok := mo.FullMerge(iter.k, nil, [][]byte{iter.v})
137 if !ok {
138 return iter.k, nil, ErrMergeOperatorFullMergeFailed
139 }
140
141 return iter.k, vMerged, nil
142 }
143
144 return iter.k, iter.v, nil
145}
146
147// CurrentEx is a more advanced form of Current() that returns more
148// metadata. It returns ErrIteratorDone if the iterator is done.

Callers 1

SeekToMethod · 0.95

Calls 1

FullMergeMethod · 0.95

Tested by

no test coverage detected