-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUpdateLocation.js
48 lines (34 loc) · 1.05 KB
/
UpdateLocation.js
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
44
45
46
47
48
// nohup bash UpdateLocation.sh &>/dev/null &
// Create 5K upserts and bulk write
var _id_min = 1;
var _id_max = 999999
var lat_min = 37.020691;
var lat_max = 40.988098;
var lon_min = -109.015325;
var lon_max = -102.101746;
function getRnd(bottom, top) {
return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom;
}
function getRndBool() {
return Math.random() >= 0.5
}
for (var times= 0; times<86400; times ++) {
var bulk = db.scooters.initializeUnorderedBulkOp();
for (var i = 0; i < 5000; i++) {
var _id = getRnd(_id_min, _id_max)|0;
var point = {
"type" : "Point",
"coordinates" : [getRnd(lon_min, lon_max), getRnd(lat_min,lat_max)]
}
bulk.find( { "_id": _id } ).upsert().update(
{
$set: { "location": point },
$set: { "is_reserved": getRndBool() },
$set: { "is_disabled": getRndBool() }
}
);
}
bulk.execute();
print(times + " iteration of 5K bulk updates DONE");
}
print("DONE!");