-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.py
43 lines (31 loc) · 981 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys
from pymongo.connection import Connection
sys.path.append('./gen-py')
from bloomfilter import BloomFilterThrift
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
def GetOne():
con = Connection("219.232.242.222:20010")
col = con.friend.weiboContent
for one in col.find({},{'weiboId':1}):
yield one['weiboId']
try:
transport = TSocket.TSocket('127.0.0.1', 9090)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = BloomFilterThrift.Client(protocol)
transport.open()
total = 0
err = 0
for id in GetOne():
b = client.queryAndAdd(id)
if b:
err += 1
total += 1
if total % 1000 == 0:
print err,'/',total
transport.close()
except Thrift.TException, ex:
print "%s" % (ex.message)