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

Method SetRange

db/string.go:139–150  ·  view source on GitHub ↗

SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.

(offset int64, value []byte)

Source from the content-addressed store, hash-verified

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) {
140 val := s.Meta.Value
141 if int64(len(val)) < offset+int64(len(value)) {
142 val = append(val, make([]byte, offset+int64(len(value))-int64(len(val)))...)
143 }
144 copy(val[offset:], value)
145 if err := s.Set(val); err != nil {
146 return nil, err
147 }
148
149 return val, nil
150}
151
152// Incr increments the integer value by the given amount
153// the old value must be integer

Callers 2

SetRangeFunction · 0.80
TestStringSetRangeFunction · 0.80

Calls 1

SetMethod · 0.95

Tested by 1

TestStringSetRangeFunction · 0.64