MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / zparseScoreRange

Function zparseScoreRange

sorted_sets.go:46–114  ·  view source on GitHub ↗
(minBuf []byte, maxBuf []byte)

Source from the content-addressed store, hash-verified

44}
45
46func zparseScoreRange(minBuf []byte, maxBuf []byte) (min int64, max int64, err error) {
47 if strings.ToLower(hack.String(minBuf)) == "-inf" {
48 min = math.MinInt64
49 } else {
50
51 if len(minBuf) == 0 {
52 err = uhaha.ErrWrongNumArgs
53 return
54 }
55
56 var lopen bool = false
57 if minBuf[0] == '(' {
58 lopen = true
59 minBuf = minBuf[1:]
60 }
61
62 min, err = ledis.StrInt64(minBuf, nil)
63 if err != nil {
64 err = uhaha.ErrInvalid
65 return
66 }
67
68 if min <= ledis.MinScore || min >= ledis.MaxScore {
69 err = uhaha.ErrWrongNumArgs
70 return
71 }
72
73 if lopen {
74 min++
75 }
76 }
77
78 if strings.ToLower(hack.String(maxBuf)) == "+inf" {
79 max = math.MaxInt64
80 } else {
81 var ropen = false
82
83 if len(maxBuf) == 0 {
84 err = uhaha.ErrWrongNumArgs
85 return
86 }
87 if maxBuf[0] == '(' {
88 ropen = true
89 maxBuf = maxBuf[1:]
90 }
91
92 if maxBuf[0] == '(' {
93 ropen = true
94 maxBuf = maxBuf[1:]
95 }
96
97 max, err = ledis.StrInt64(maxBuf, nil)
98 if err != nil {
99 err = uhaha.ErrWrongNumArgs
100 return
101 }
102
103 if max <= ledis.MinScore || max >= ledis.MaxScore {

Callers 4

cmdZCOUNTFunction · 0.85
cmdZRANGEBYSCOREFunction · 0.85
cmdZREVRANGEBYSCOREFunction · 0.85
cmdZREMRANGEBYSCOREFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected