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))

db.close()
Ejemplo n.º 2
0
#db.open('/home/pkhorsand/165a-winter-2020-private/db')
db.open('~/ECS165')
grades_table = db.create_table('Grades', 5, 0)

keys = []
records = {}
seed(3562901)
num_threads = 8

# 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 transactions and assign them to workers
transactions = []
transaction_workers = []
for i in range(num_threads):
    transaction_workers.append(TransactionWorker())

for i in range(10000):
    key = choice(keys)
    record = records[key]
    c = record[1]
    transaction = Transaction()
    for i in range(5):
        c += 1
        q = Query(grades_table)
Ejemplo n.º 3
0
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):
Ejemplo n.º 4
0
from lstore.config import init

from random import choice, randint, sample, seed
from colorama import Fore, Back, Style

# Student Id and 4 grades
init()
db = Database()
grades_table = db.create_table('Grades', 5, 0)
query = Query(grades_table)

record1 = [1, 10, 20, 30, 40]
record2 = [2, 10, 22, 33, 44]
record3 = [2, 11, 22, 55, 66]

query.insert(*record1)
query.insert(*record2)
query.insert(*record3)

print("original data:")
print(record1)
print(record2)
print(record3)
print("\n")

key = 2
print("demo duplicate key selection, where key = " + str(key) + "\n")
record = query.select(key, [1, 1, 1, 1, 1])
for r in record:
    print(r)