bG8ddlmZddlmZddlmZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0Gd/d0Z1Gd1d2Z2Gd3d4Z3Gd5d6Z4Gd7d8Z5y9):) NEVER_DECODE) ModuleError)HIREDIS_AVAILABLEz BF.RESERVEzBF.ADDzBF.MADDz BF.INSERTz BF.EXISTSz BF.MEXISTSz BF.SCANDUMPz BF.LOADCHUNKzBF.INFOz CF.RESERVEzCF.ADDzCF.ADDNXz CF.INSERTz CF.INSERTNXz CF.EXISTSz CF.MEXISTSzCF.DELzCF.COUNTz CF.SCANDUMPz CF.LOADCHUNKzCF.INFOz CMS.INITBYDIMzCMS.INITBYPROBz CMS.INCRBYz CMS.QUERYz CMS.MERGEzCMS.INFOz TOPK.RESERVEzTOPK.ADDz TOPK.INCRBYz TOPK.QUERYz TOPK.COUNTz TOPK.LISTz TOPK.INFOzTDIGEST.CREATEz TDIGEST.RESETz TDIGEST.ADDz TDIGEST.MERGEz TDIGEST.CDFzTDIGEST.QUANTILEz TDIGEST.MINz TDIGEST.MAXz TDIGEST.INFOcTeZdZdZd dZdZdZ d dZdZdZ d Z d Z d Z y) BFCommandszBloom Filter commands.Nc|||g}|j|||j|||jtg|S)aA Create a new Bloom Filter `key` with desired probability of false positives `errorRate` expected entries to be inserted as `capacity`. Default expansion value is 2. By default, filter is auto-scaling. For more information see `BF.RESERVE `_. )append_expansionappend_no_scaleexecute_command BF_RESERVE)selfkey errorRatecapacity expansionnoScaleparamss `_. )r BF_ADDr ritems raddzBFCommands.addF ##FC66rc2|jt|g|S)z Add to a Bloom Filter `key` multiple `items`. For more information see `BF.MADD `_. )r BF_MADDr ritemss rmaddzBFCommands.maddMs $t##GS9599rc|g}|j|||j|||j|||j|||j |||j |||j tg|S)as Add to a Bloom Filter `key` multiple `items`. If `nocreate` remain `None` and `key` does not exist, a new Bloom Filter `key` will be created with desired probability of false positives `errorRate` and expected entries to be inserted as `size`. For more information see `BF.INSERT `_. )append_capacity append_errorr append_no_creater append_itemsr BF_INSERT) r rr rerrornoCreaterrrs rinsertzBFCommands.insertTs$ VX. &%( fi0 fh/ VW- &%(#t##I777rc0|jt||S)z Check whether an `item` exists in Bloom Filter `key`. For more information see `BF.EXISTS `_. )r BF_EXISTSrs rexistszBFCommands.existsp ##IsD99rc2|jt|g|S)z Check whether `items` exist in Bloom Filter `key`. For more information see `BF.MEXISTS `_. )r BF_MEXISTSrs rmexistszBFCommands.mexistsw $t##J`_. z6This command cannot be used when hiredis is available.)rrrr BF_SCANDUMP)r riterroptionss rscandumpzBFCommands.scandump~sH VW Wt " #t##KD&DGDDrc2|jt|||S)ai Restore a filter previously saved using SCANDUMP. See the SCANDUMP command for example usage. This command will overwrite any bloom filter stored under key. Ensure that the bloom filter will not be modified between invocations. For more information see `BF.LOADCHUNK `_. )r BF_LOADCHUNKr rr5datas r loadchunkzBFCommands.loadchunks##L#tTBBrc.|jt|S)z Return capacity, size, number of filters, number of items inserted, and expansion rate. For more information see `BF.INFO `_. )r BF_INFOr rs rinfozBFCommands.infos ##GS11rNN)NNNNN) __name__ __module__ __qualname____doc__rrr!r*r-r1r7r<r@rrrr6sE  97:88:=E" C2rrc`eZdZdZ ddZdZdZddZddZdZ d Z d Z d Z d Z d ZdZy) CFCommandszCuckoo Filter commands.Nc||g}|j|||j|||j|||jtg|S)z Create a new Cuckoo Filter `key` an initial `capacity` items. For more information see `CF.RESERVE `_. )r append_bucket_sizeappend_max_iterationsr CF_RESERVE)r rrr bucket_sizemax_iterationsrs rrzCFCommands.createsUx fi0  4 ""6>:#t##J888rc0|jt||S)z Add an `item` to a Cuckoo Filter `key`. For more information see `CF.ADD `_. )r CF_ADDrs rrzCFCommands.addrrc0|jt||S)z Add an `item` to a Cuckoo Filter `key` only if item does not yet exist. Command might be slower that `add`. For more information see `CF.ADDNX `_. )r CF_ADDNXrs raddnxzCFCommands.addnxs ##Hc488rc|g}|j|||j|||j|||jtg|S)a Add multiple `items` to a Cuckoo Filter `key`, allowing the filter to be created with a custom `capacity` if it does not yet exist. `items` must be provided as a list. For more information see `CF.INSERT `_. )r#r%r&r CF_INSERTr rr rnocreaters rr*zCFCommands.insertsS VX. fh/ &%(#t##I777rc|g}|j|||j|||j|||jtg|S)a@ Add multiple `items` to a Cuckoo Filter `key` only if they do not exist yet, allowing the filter to be created with a custom `capacity` if it does not yet exist. `items` must be provided as a list. For more information see `CF.INSERTNX `_. )r#r%r&r CF_INSERTNXrVs rinsertnxzCFCommands.insertnxsS VX. fh/ &%(#t##K9&99rc0|jt||S)z Check whether an `item` exists in Cuckoo Filter `key`. For more information see `CF.EXISTS `_. )r CF_EXISTSrs rr-zCFCommands.existsr.rc2|jt|g|S)z Check whether an `items` exist in Cuckoo Filter `key`. For more information see `CF.MEXISTS `_. )r CF_MEXISTSrs rr1zCFCommands.mexistsr2rc0|jt||S)zz Delete `item` from `key`. For more information see `CF.DEL `_. )r CF_DELrs rdeletezCFCommands.deleterrc0|jt||S)z Return the number of times an `item` may be in the `key`. For more information see `CF.COUNT `_. )r CF_COUNTrs rcountzCFCommands.counts ##Hc488rc0|jt||S)a Begin an incremental save of the Cuckoo filter `key`. This is useful for large Cuckoo filters which cannot fit into the normal SAVE and RESTORE model. The first time this command is called, the value of `iter` should be 0. This command will return successive (iter, data) pairs until (0, NULL) to indicate completion. For more information see `CF.SCANDUMP `_. )r CF_SCANDUMP)r rr5s rr7zCFCommands.scandumps##Kd;;rc2|jt|||S)ac Restore a filter previously saved using SCANDUMP. See the SCANDUMP command for example usage. This command will overwrite any Cuckoo filter stored under key. Ensure that the Cuckoo filter will not be modified between invocations. For more information see `CF.LOADCHUNK `_. )r CF_LOADCHUNKr:s rr<zCFCommands.loadchunks##L#tTBBrc.|jt|S)z Return size, number of buckets, number of filter, number of items inserted, number of items deleted, bucket size, expansion rate, and max iteration. For more information see `CF.INFO `_. )r CF_INFOr?s rr@zCFCommands.infos ##GS11r)NNNrA)rBrCrDrErrrSr*rZr-r1rardr7r<r@rFrrrHrHsI!OS 979 8 ::=79 <C2rrHc<eZdZdZdZdZdZdZdZd dZ dZ y ) TOPKCommandszTOP-k Filter commands.c6|jt|||||S)z Create a new Top-K Filter `key` with desired probability of false positives `errorRate` expected entries to be inserted as `size`. For more information see `TOPK.RESERVE `_. )r TOPK_RESERVE)r rkwidthdepthdecays rreservezTOPKCommands.reserves ##L#q%NNrc2|jt|g|S)z Add one `item` or more to a Top-K Filter `key`. For more information see `TOPK.ADD `_. )r TOPK_ADDrs rrzTOPKCommands.add#s $t##Hc:E::rc\|g}|j||||jtg|S)a Add/increase `items` to a Top-K Sketch `key` by ''increments''. Both `items` and `increments` are lists. For more information see `TOPK.INCRBY `_. Example: >>> topkincrby('A', ['foo'], [1]) )append_items_and_incrementsr TOPK_INCRBYr rr incrementsrs rincrbyzTOPKCommands.incrby*s5 (( C#t##K9&99rc2|jt|g|S)z Check whether one `item` or more is a Top-K item at `key`. For more information see `TOPK.QUERY `_. )r TOPK_QUERYrs rqueryzTOPKCommands.query8r2rc2|jt|g|S)z Return count for one `item` or more from `key`. For more information see `TOPK.COUNT `_. )r TOPK_COUNTrs rrdzTOPKCommands.count?r2rc\|g}|r|jd|jtg|S)a Return full list of items in Top-K list of `key`. If `withcount` set to True, return full list of items with probabilistic count in Top-K list of `key`. For more information see `TOPK.LIST `_. WITHCOUNT)appendr TOPK_LIST)r r withcountrs rlistzTOPKCommands.listFs2  MM+ &#t##I777rc.|jt|S)z Return k, width, depth and decay values of `key`. For more information see `TOPK.INFO `_. )r TOPK_INFOr?s rr@zTOPKCommands.infoRs ##Is33rN)F) rBrCrDrErsrr{r~rdrr@rFrrrlrls) O; :== 84rrlcBeZdZdZdZdZdZdZdZdZ dZ d Z y ) TDigestCommandsc0|jt||S)z Allocate the memory and initialize the t-digest. For more information see `TDIGEST.CREATE `_. )r TDIGEST_CREATE)r r compressions rrzTDigestCommands.create[s ##NCEErc.|jt|S)z Reset the sketch `key` to zero - empty out the sketch and re-initialize it. For more information see `TDIGEST.RESET `_. )r TDIGEST_RESETr?s rresetzTDigestCommands.resetbs ##M377rc\|g}|j||||jtg|S)a Add one or more samples (value with weight) to a sketch `key`. Both `values` and `weights` are lists. For more information see `TDIGEST.ADD `_. Example: >>> tdigestadd('A', [1500.0], [1.0]) )append_values_and_weightsr TDIGEST_ADD)r rvaluesweightsrs rrzTDigestCommands.addis5 &&vvw?#t##K9&99rc0|jt||S)z Merge all of the values from 'fromKey' to 'toKey' sketch. For more information see `TDIGEST.MERGE `_. )r TDIGEST_MERGE)r toKeyfromKeys rmergezTDigestCommands.mergews ##M5'BBrc.|jt|S)z Return minimum value from the sketch `key`. Will return DBL_MAX if the sketch is empty. For more information see `TDIGEST.MIN `_. )r TDIGEST_MINr?s rminzTDigestCommands.min~ ##K55rc.|jt|S)z Return maximum value from the sketch `key`. Will return DBL_MIN if the sketch is empty. For more information see `TDIGEST.MAX `_. )r TDIGEST_MAXr?s rmaxzTDigestCommands.maxrrc0|jt||S)a Return double value estimate of the cutoff such that a specified fraction of the data added to this TDigest would be less than or equal to the cutoff. For more information see `TDIGEST.QUANTILE `_. )r TDIGEST_QUANTILE)r rquantiles rrzTDigestCommands.quantiles ##$4c8DDrc0|jt||S)z Return double fraction of all points added which are <= value. For more information see `TDIGEST.CDF `_. )r TDIGEST_CDF)r rvalues rcdfzTDigestCommands.cdfs ##Ke<`_. )r TDIGEST_INFOr?s rr@zTDigestCommands.infos ##L#66rN) rBrCrDrrrrrrrrr@rFrrrrZs2F8 :C66E=7rrc8eZdZdZdZdZdZdZgfdZdZ y) CMSCommandszCount-Min Sketch Commandsc2|jt|||S)z Initialize a Count-Min Sketch `key` to dimensions (`width`, `depth`) specified by user. For more information see `CMS.INITBYDIM `_. )r CMS_INITBYDIM)r rrprqs r initbydimzCMSCommands.initbydims ##M3uEErc2|jt|||S)z Initialize a Count-Min Sketch `key` to characteristics (`error`, `probability`) specified by user. For more information see `CMS.INITBYPROB `_. )r CMS_INITBYPROB)r rr( probabilitys r initbyprobzCMSCommands.initbyprobs ##NC LLrc\|g}|j||||jtg|S)a Add/increase `items` to a Count-Min Sketch `key` by ''increments''. Both `items` and `increments` are lists. For more information see `CMS.INCRBY `_. Example: >>> cmsincrby('A', ['foo'], [1]) )rwr CMS_INCRBYrys rr{zCMSCommands.incrbys5 (( C#t##J888rc2|jt|g|S)z Return count for an `item` from `key`. Multiple items can be queried with one call. For more information see `CMS.QUERY `_. )r CMS_QUERYrs rr~zCMSCommands.querys $t##Is;U;;rcf||g}||z }|j|||jtg|S)an Merge `numKeys` of sketches into `destKey`. Sketches specified in `srcKeys`. All sketches must have identical width and depth. `Weights` can be used to multiply certain sketches. Default weight is 1. Both `srcKeys` and `weights` are lists. For more information see `CMS.MERGE `_. )append_weightsr CMS_MERGE)r destKeynumKeyssrcKeysrrs rrzCMSCommands.merges@7#' FG,#t##I777rc.|jt|S)z Return width, depth and total count of the sketch. For more information see `CMS.INFO `_. )r CMS_INFOr?s rr@zCMSCommands.infos ##Hc22rN) rBrCrDrErrr{r~rr@rFrrrrs*#FM 9<8: 83rrN)6 redis.clientrredis.exceptionsr redis.utilsrr rrr'r,r0r4r9r>rLrPrRrUrYr\r^r`rcrfrhrjrrrrrrrnrurxr}rrrrrrrrrrrrrrHrlrrrFrrrs"%()                     !          !    %   i2i2Xs2s2l?4?4DG7G7T9393r