from lstore.db import Database from lstore.query import Query db = Database() db.open("/Users/vsiow/Documents/UCD/W2020/ECS165/ECS165A-DBDeadbodies/") # db.open("/Users/Kurono/Documents/Junior_Year/Winter_Quarter/ECS165A/DB_Deadbodies_LStore") # Student Id and 4 grades grades_table = db.create_table('Grades', 5, 0) query = Query(grades_table) records = {} for i in range(0, 20): key = 92106429 + i if (i % 2 == 0) : records[key] = [key, i + 1, 20 + i, 30 + i, 40 + i] else : records[key] = [key, i + 1, 39 - i, 100, 50 - i] print(records[key]) query.insert(*records[key]) print("running index's locate_range(): ") print("locate_range on begin key = 20, end key = 30, column = 2 :") query.table.index.update(2) print(query.table.index.locate_range(20, 30, 2)) print() print("locate_range on begin key = 90, end key = 100, column = 3 :") query.table.index.update(3) print(query.table.index.locate_range(90, 100, 3))
from lstore.db import Database from lstore.query import Query from random import choice, randint, sample, seed # Student Id and 4 grades db = Database() db.open('~/ECS165') grades_table = db.get_table('Grades') query = Query(grades_table) # repopulate with random data records = {} seed(3562901) for i in range(0, 1000): key = 92106429 + i records[key] = [key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20)] keys = sorted(list(records.keys())) for _ in range(10): for key in keys: for j in range(1, grades_table.num_columns): value = randint(0, 20) records[key][j] = value keys = sorted(list(records.keys())) # for key in keys: # print(records[key]) # print(records[key]) for key in keys: record = query.select(key, 0, [1, 1, 1, 1, 1])[0] error = False
from lstore.db import Database from lstore.query import Query from time import process_time from random import choice, randrange # Student Id and 4 grades db = Database() grades_table = db.create_table('Grades', 5, 0) query = Query(grades_table) keys = [] # Measuring Insert Performance insert_time_0 = process_time() for i in range(0, 10000): query.insert(906659671 + i, 93, 0, 0, 0) keys.append(906659671 + i) insert_time_1 = process_time() print("Inserting 10k records took: \t\t\t", insert_time_1 - insert_time_0) # Measuring update Performance update_cols = [ [randrange(0, 100), None, None, None, None], [None, randrange(0, 100), None, None, None], [None, None, randrange(0, 100), None, None], [None, None, None, randrange(0, 100), None], [None, None, None, None, randrange(0, 100)], ] update_time_0 = process_time() for i in range(0, 10000):
from lstore.db import Database from lstore.query import Query from lstore.transaction import Transaction from time import process_time from random import choice, randrange # Student Id and 4 grades db = Database() db.open('~/ECS165') grades_table = db.create_table('Grades', 5, 0) query = Query(grades_table) keys = [] insert_time_0 = process_time() for i in range(0, 10000): query.insert(906659671 + i, 93, 0, 0, 0) keys.append(906659671 + i) insert_time_1 = process_time() print("Inserting 10k records took: \t\t\t", insert_time_1 - insert_time_0) # Measuring update Performance update_cols = [ [None, randrange(0, 100), None, None, None], [None, None, randrange(0, 100), None, None], [None, None, None, randrange(0, 100), None], [None, None, None, None, randrange(0, 100)], ] t = Transaction() for i in range(10):
from lstore.db import Database from lstore.query import Query from lstore.transaction import Transaction from lstore.transaction_worker import TransactionWorker import threading from random import choice, randint, sample, seed db = Database() db.open('/home/pkhorsand/165a-winter-2020-private/db') db.open('~/ECS165') grades_table = db.create_table('Grades', 5, 0) keys = [] records = {} num_threads = 8 seed(8739878934) # Generate random records for i in range(0, 10000): key = 92106429 + i keys.append(key) records[key] = [key, 0, 0, 0, 0] q = Query(grades_table) q.insert(*records[key]) # create TransactionWorkers transaction_workers = [] for i in range(num_threads): transaction_workers.append(TransactionWorker([]))