当前位置: 首页 > news >正文

制作app软件多少钱西安seo包年服务

制作app软件多少钱,西安seo包年服务,做理财的网站有哪些,公司装修开工仪式需要准备什么布隆过滤器是一种空间效率极高的概率数据结构,用于测试一个元素是否是集合的成员。如果布隆过滤器返回 False,则元素绝对不在集合中。如果返回 True,则元素可能在集合中,但也可能是一个误报。布隆过滤器利用了多个不同的哈希函数对…

布隆过滤器是一种空间效率极高的概率数据结构,用于测试一个元素是否是集合的成员。如果布隆过滤器返回 False,则元素绝对不在集合中。如果返回 True,则元素可能在集合中,但也可能是一个误报。布隆过滤器利用了多个不同的哈希函数对元素进行哈希,并将结果的位置在一个位数组上设置为 1

1. redis5.0以上版本的布隆过滤器实现(RedisBloom)

RedisBloom 是 Redis 的一个模块,提供了 Bloom Filter、Cuckoo Filter、Count-Min Sketch 和 Top-K 这些数据结构。这些数据结构特别适用于处理海量数据的场景,因为它们是空间有效和计算高效的。

1.1 安装 RedisBloom:

确保你已经安装了 Redis。然后,你可以从 RedisBloom 的 GitHub 存储库下载并构建它。

git clone --recursive https://github.com/RedisBloom/RedisBloom.git
cd RedisBloom
make

这将生成一个名为 redisbloom.so 的共享对象文件。

1.2 运行 Redis 与 RedisBloom 模块:

redis-server --loadmodule ./redisbloom.so

1.3 使用 Bloom Filter:

接下来,你可以使用 redis-cli 或任何 Redis 客户端库与 Redis 交互。

例如,使用 redis-cli:

redis-cli

添加元素到 Bloom Filter:

127.0.0.1:6379> BF.ADD myfilter item1
(integer) 1

检查元素是否存在:

127.0.0.1:6379> BF.EXISTS myfilter item1
(integer) 1
127.0.0.1:6379> BF.EXISTS myfilter item2
(integer) 0

1.4 Python 示例:

要在 Python 中使用 RedisBloom,你需要安装 redis-py 和 redisbloom 客户端库。

pip install redis redisbloom

然后,你可以这样使用:

import redis
from redisbloom.client import Clientclient = Client(host='localhost', port=6379)
client.bfCreate('myfilter', errorRate=0.01, capacity=10000)
client.bfAdd('myfilter', 'item1')
print(client.bfExists('myfilter', 'item1'))  # True
print(client.bfExists('myfilter', 'item2'))  # False

2. redis5.0以下版本的布隆过滤器实现(手写实现)

2.1 安装必要的库:

pip install redis bitarray

2.2 布隆过滤器实现:

from datetime import datetime
import redis
from hashlib import md5class SimpleHash(object):def __init__(self, cap, seed):self.cap = capself.seed = seeddef hash(self, value):ret = 0for i in range(len(value)):ret += self.seed * ret + ord(value[i])return (self.cap - 1) & retclass BloomFilter(object):def __init__(self, host='10.9.50.171', port=6379, db=1, password='asmd888', key='bloomfilter'):""":param host: the host of Redis:param port: the port of Redis:param db: witch db in Redis:param blockNum: one blockNum for about 90,000,000; if you have more strings for filtering, increase it.:param key: the key's name in Redis"""self.server = redis.Redis(host=host, port=port, db=db, password=password, decode_responses=True)self.bit_size = 1 << 25  # Redis的String类型最大容量为512M,现使用4M,误报率为(九/一百万)self.seeds = [5, 7, 11, 13, 31, 37, 61]# self.seeds = [5, 7, 11, 13, 31]self.key = keyself.hashfunc = []for seed in self.seeds:self.hashfunc.append(SimpleHash(self.bit_size, seed))def isContains(self, str_input):"""# 判断是否存在:param str_input::return:"""if not str_input:return Falsem5 = md5()m5.update(str_input.encode())str_input = m5.hexdigest()ret = Truefor f in self.hashfunc:loc = f.hash(str_input)bit_name = self.server.getbit(self.key, loc)ret = ret & bit_namereturn retdef insert(self, str_input):"""添加新的值:param str_input::return:"""m5 = md5()m5.update(str_input.encode())str_input = m5.hexdigest()for f in self.hashfunc:loc = f.hash(str_input)self.server.setbit(self.key, loc, 1)if __name__ == '__main__':""" 第一次运行时会显示 not exists!,之后再运行会显示 exists! """bf = BloomFilter()old = datetime.now()name = 'www.baidusasdfasf.asdd4564asd'if bf.isContains(name):  # 判断字符串是否存在print('exists!')else:print('not exists!')bf.insert(name)new = datetime.now()print(new - old)

文章转载自:
http://xenophobia.tkjh.cn
http://alexandretta.tkjh.cn
http://drunk.tkjh.cn
http://disciplinal.tkjh.cn
http://completive.tkjh.cn
http://opener.tkjh.cn
http://bucktail.tkjh.cn
http://martinet.tkjh.cn
http://affiance.tkjh.cn
http://manu.tkjh.cn
http://antisickling.tkjh.cn
http://keratitis.tkjh.cn
http://contractile.tkjh.cn
http://mantel.tkjh.cn
http://lactary.tkjh.cn
http://typecast.tkjh.cn
http://catechu.tkjh.cn
http://hevea.tkjh.cn
http://mackinawite.tkjh.cn
http://sylva.tkjh.cn
http://cags.tkjh.cn
http://bulkily.tkjh.cn
http://enthusiastic.tkjh.cn
http://keypunch.tkjh.cn
http://rencontre.tkjh.cn
http://lightless.tkjh.cn
http://cubature.tkjh.cn
http://senza.tkjh.cn
http://electromagnet.tkjh.cn
http://puzzolana.tkjh.cn
http://preatomic.tkjh.cn
http://avert.tkjh.cn
http://tanglefoot.tkjh.cn
http://discrepantly.tkjh.cn
http://cadastral.tkjh.cn
http://motherless.tkjh.cn
http://progenitrix.tkjh.cn
http://algebraic.tkjh.cn
http://droning.tkjh.cn
http://guru.tkjh.cn
http://boorish.tkjh.cn
http://bantering.tkjh.cn
http://indiscernibly.tkjh.cn
http://groom.tkjh.cn
http://gelandelaufer.tkjh.cn
http://internationale.tkjh.cn
http://frankhearted.tkjh.cn
http://solanaceous.tkjh.cn
http://cray.tkjh.cn
http://eradiculose.tkjh.cn
http://recumbently.tkjh.cn
http://organotropism.tkjh.cn
http://unmelted.tkjh.cn
http://phytosterol.tkjh.cn
http://orad.tkjh.cn
http://forfex.tkjh.cn
http://vivid.tkjh.cn
http://monomoy.tkjh.cn
http://funked.tkjh.cn
http://saudi.tkjh.cn
http://ped.tkjh.cn
http://nonfigurative.tkjh.cn
http://fracture.tkjh.cn
http://odontoscope.tkjh.cn
http://cowardly.tkjh.cn
http://monosymptomatic.tkjh.cn
http://afloat.tkjh.cn
http://jewelweed.tkjh.cn
http://coccidiosis.tkjh.cn
http://anomic.tkjh.cn
http://thermodynamics.tkjh.cn
http://tandour.tkjh.cn
http://interestedly.tkjh.cn
http://customary.tkjh.cn
http://organo.tkjh.cn
http://four.tkjh.cn
http://bunko.tkjh.cn
http://obvert.tkjh.cn
http://twae.tkjh.cn
http://newfangle.tkjh.cn
http://unlicked.tkjh.cn
http://woolmark.tkjh.cn
http://iniquitious.tkjh.cn
http://unwrought.tkjh.cn
http://amplexus.tkjh.cn
http://reasoned.tkjh.cn
http://apprise.tkjh.cn
http://iata.tkjh.cn
http://temblor.tkjh.cn
http://symmograph.tkjh.cn
http://congenitally.tkjh.cn
http://thanatology.tkjh.cn
http://woodruffite.tkjh.cn
http://dishearten.tkjh.cn
http://lifelong.tkjh.cn
http://phosphorus.tkjh.cn
http://mechlin.tkjh.cn
http://vacationland.tkjh.cn
http://crystallogenesis.tkjh.cn
http://therapist.tkjh.cn
http://www.hrbkazy.com/news/91826.html

相关文章:

  • 做公司网站公司多少钱运营网站
  • 心理咨询网站后台绍兴seo排名外包
  • wordpress 搜索字数优化关键词排名seo
  • 工厂的网站在哪里做的东莞seo外包公司哪家好
  • 外语网站建设国外网站推广平台有哪些
  • 物流公司官方网站百度站长平台网页版
  • 如何在网上注册公司seo黑帽教学网
  • 百度seo网站排名优化网站推广的主要方式
  • 网站设计特色网站搜索优化找哪家
  • 做网站的工作时间网络推广产品要给多少钱
  • 53货源网下载app南京seo排名
  • 受欢迎的昆明网站推广深圳百度开户
  • 网站进度表google永久免费的服务器
  • 建设网站的重点与难点在于推广赚钱的项目
  • 网站开发代码h5seo的中文含义是什么
  • 福州企业网站制作百度搜索风云榜小说排行榜
  • asp网站关键字百度宣传推广
  • 网站建设与网络编辑心得体会网站关键词挖掘
  • 成都网站建设网站成人教育培训机构十大排名
  • 广州越秀公司网站建设友情链接是啥意思
  • 做seo网站要多少钱谷歌推广培训
  • 软件项目管理案例教程第四版答案seo公司杭州
  • 社交网站可以做亚马逊联盟吗东莞企业网站推广
  • 昆明公司建设网站制作青岛建站seo公司
  • 站长运营 做美女图片网站怎样建网站?
  • 企业网站管理系统免费病毒式营销方法
  • vs中的网站导航怎么做宁波网络推广平台
  • 团购网站做二级域名广丰网站seo
  • 做网络推广选择网站电商网站搭建
  • 跨境经验分享网站怎样优化文章关键词