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

Method Incrf

db/string.go:174–189  ·  view source on GitHub ↗

Incrf increments the float value by the given amount the old value must be float

(delta float64)

Source from the content-addressed store, hash-verified

172// Incrf increments the float value by the given amount
173// the old value must be float
174func (s *String) Incrf(delta float64) (float64, error) {
175 value := s.Meta.Value
176 if value != nil {
177 v, err := strconv.ParseFloat(string(value), 64)
178 if err != nil {
179 return 0, ErrInteger
180 }
181 delta = v + delta
182 }
183
184 vs := strconv.FormatFloat(delta, 'e', -1, 64)
185 if err := s.Set([]byte(vs)); err != nil {
186 return 0, err
187 }
188 return delta, nil
189}
190
191// SetBit key offset bitvalue
192// return the off postion of value

Callers 2

IncrByFloatFunction · 0.80
TestStringIncrfFunction · 0.80

Calls 1

SetMethod · 0.95

Tested by 1

TestStringIncrfFunction · 0.64