CMS.INITBYDIM
CMS.INITBYDIM key width depth
- Group
- Count-min sketch
- Complexity
- O(1)
- Arity
- -1 (at least 1 words, counting the command name)
- Flags
- fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
CMS.INITBYDIM creates an empty Count-min sketch at key. A Count-min
sketch counts how often items occur in a stream of events using a fixed
amount of memory. Its estimates are never lower than the true count, and can
be higher.
The sketch has depth rows of width counters. A larger width lowers the
overcount; a larger depth makes a large overcount less likely. Memory grows
with width times depth. If you would rather state
the accuracy you need, use CMS.INITBYPROB.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Created | Simple string OK |
Simple string OK |
Error replies:
CMS: key already existsif the key exists (with any type).CMS: invalid widthandCMS: invalid depthfor values that are not positive integers.CMS: invalid init argumentswhen width times depth is too large to count.CMS: Insufficient memory to create the keywhen the sketch would not fit in memory (a single sketch is limited to 4 GiB).
Examples
Section titled “Examples”127.0.0.1:6379> CMS.INITBYDIM pageviews 2000 5OK127.0.0.1:6379> CMS.INITBYDIM pageviews 2000 5(error) CMS: key already exists127.0.0.1:6379> CMS.INFO pageviews1) width2) (integer) 20003) depth4) (integer) 55) count6) (integer) 0Compatibility
Section titled “Compatibility”Same as CMS.INITBYDIM in RedisBloom. HotKV also refuses sketches larger
than 4 GiB.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.