Commit b719c72e authored by Juan José Miranda's avatar Juan José Miranda

Cargamos proyecto final de Bases de Datos no Relacionales 2021 v1.0

parent 67399ada
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(300000, 375000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(630000, 705000):
result = tweets.find({"entities.hashtags": "BDNR_mod3"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(70000, 140000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds) + ", count: " + str(result))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(70000, 140000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds) + ", count: " + str(result))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 715000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 715000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 715000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import random
import json
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
#Generate random key 1 to 1.000.000
keylist = random.sample(range(1, 1000001), 1000000)
start = datetime.now()
for k in range(0,6):
for j in range(0,3):
json_file_path = "../../tweets_3.json"
with open(json_file_path, 'r') as data_file:
json_data = data_file.read()
arr = json.loads(json_data)
for i in range(0,333333):
tweet = arr[i]
tweet["key"] = keylist[i + (j*333333)]
if tweet["key"] % 2 == 0:
if tweet["key"] > 0 and tweet["key"] <= 333333:
tweet["entities"]["hashtags"].append("BDNR_0")
elif tweet["key"] > 333333 and tweet["key"] <= 666666:
tweet["entities"]["hashtags"].append("BDNR_1")
else:
tweet["entities"]["hashtags"].append("BDNR_2")
result = tweets.insert_one(tweet)
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import random
import json
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
#Generate random key 1 to 1.000.000
keylist = random.sample(range(1, 1000001), 1000000)
start = datetime.now()
for j in range(0,3):
json_file_path = "../../tweets_3.json"
with open(json_file_path, 'r') as data_file:
json_data = data_file.read()
arr = json.loads(json_data)
for i in range(0,333333):
tweet = arr[i]
tweet["key"] = keylist[i + (j*333333)]
if tweet["key"] % 2 == 0:
tweet["entities"]["hashtags"].append("BDNR_mod2")
if tweet["key"] > 0 and tweet["key"] <= 333333:
tweet["entities"]["hashtags"].append("BDNR_0")
elif tweet["key"] > 333333 and tweet["key"] <= 666666:
tweet["entities"]["hashtags"].append("BDNR_1")
else:
tweet["entities"]["hashtags"].append("BDNR_2")
if tweet["key"] % 3 == 0:
tweet["entities"]["hashtags"].append("BDNR_mod3")
result = tweets.insert_one(tweet)
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import random
import json
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
# Generate random key 1 to 1.000.000
keylist = random.sample(range(1, 1000001), 1000000)
start = datetime.now()
for j in range(0,3):
json_file_path = "../../tweets_3.json"
with open(json_file_path, 'r') as data_file:
json_data = data_file.read()
arr = json.loads(json_data)
for i in range(0, 333333):
tweet = arr[i]
tweet["key"] = keylist[i + (j * 333333)]
if tweet["key"] % 2 == 0:
tweet["entities"]["hashtags"].append("BDNR" + str(i))
result = tweets.insert_one(tweet)
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(630000, 670000):
result = tweets.find({"entities.hashtags": "BDNR_mod3"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(300000, 340000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(35000, 70000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(35000, 70000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 680000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 680000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(640000, 680000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(300000, 340000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
\ No newline at end of file
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(630000, 680000):
result = tweets.find({"entities.hashtags": "BDNR_mod3"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(70000, 115000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds) + ", count: " + str(result))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(70000, 115000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds) + ", count: " + str(result))
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
start = datetime.now()
for i in range(650000, 695000):
result = tweets.find({"key": f"{i:06}"})
finish = datetime.now()