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

Method get

segment_stack.go:82–115  ·  view source on GitHub ↗

get() retrieves a val from a segmentStack, but only considers segments at or below the segStart level. The optional base segmentStack, when non-nil, is used instead of the lowerLevelSnapshot, as a form of controllable chaining.

(key []byte, segStart int, base *segmentStack,
	readOptions ReadOptions)

Source from the content-addressed store, hash-verified

80// segmentStack, when non-nil, is used instead of the
81// lowerLevelSnapshot, as a form of controllable chaining.
82func (ss *segmentStack) get(key []byte, segStart int, base *segmentStack,
83 readOptions ReadOptions) ([]byte, error) {
84 if segStart >= 0 {
85 ss.ensureSorted(0, segStart)
86
87 for seg := segStart; seg >= 0; seg-- {
88 b := ss.a[seg]
89
90 op, val, err := b.Get(key)
91 if err != nil {
92 return nil, err
93 }
94 if val != nil {
95 if op == OperationDel {
96 return nil, nil
97 }
98 if op == OperationMerge {
99 return ss.getMerged(key, val, seg-1, base, readOptions)
100 }
101 return val, nil
102 }
103 }
104 }
105
106 if base != nil {
107 return base.Get(key, readOptions)
108 }
109
110 if !readOptions.SkipLowerLevel && ss.lowerLevelSnapshot != nil {
111 return ss.lowerLevelSnapshot.Get(key, readOptions)
112 } // TODO: else add a special return error indicating cache-miss!
113
114 return nil, nil
115}
116
117// ------------------------------------------------------
118

Callers 3

GetMethod · 0.95
getMergedMethod · 0.95
mergeIntoMethod · 0.95

Calls 3

ensureSortedMethod · 0.95
getMergedMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected