-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryStatusesCount.py
43 lines (27 loc) · 903 Bytes
/
QueryStatusesCount.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 riak
import time
start_time=time.time()
client=riak.RiakClient()
bucket=client.bucket('posts')
# # Query the indexes. The return value is a list of ``RiakLink`` objects.
resultsAll = client.index('posts', 'all_int', 1).run()
# results = client.index('posts', 'statuses_count_int', 400,500).run()
query = client.index("posts",'statuses_count_int', 400,500)
query.map("""
function(v, kd, args) {
var obj = Riak.mapValuesJson(v)[0]["user_name"];
return [ {
'key': v.key,
'data': obj,
} ];
}"""
)
results = query.run()
for i in results:
print i.get("key")
print i.get("data")
# print bucket.get(i[1]).data["user_name"]
print "........................................................................."
print "Total:"+str(len(resultsAll))
print "Match: "+str(len(results))
print "Time: "+str((time.time()-start_time))