MCPcopy Create free account
hub / github.com/distributedio/titan / GetRange

Method GetRange

db/string.go:118–136  ·  view source on GitHub ↗

GetRange returns string from the absolute of start to the absolute of end

(start, end int)

Source from the content-addressed store, hash-verified

116
117// GetRange returns string from the absolute of start to the absolute of end
118func (s *String) GetRange(start, end int) []byte {
119 vlen := len(s.Meta.Value)
120 if end < 0 {
121 end = vlen + end
122 }
123 if start < 0 {
124 start = vlen + start
125 }
126 if start > end || start > vlen || end < 0 {
127 return nil
128 }
129 if end > vlen {
130 end = vlen - 1
131 }
132 if start < 0 {
133 start = 0
134 }
135 return s.Meta.Value[start : end+1]
136}
137
138// SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
139func (s *String) SetRange(offset int64, value []byte) ([]byte, error) {

Callers 2

GetRangeFunction · 0.80
TestStringGetRangeFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestStringGetRangeFunction · 0.64