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))
Example #2
0
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
Example #3
0
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('/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])
print("insert finshed")

# create TransactionWorkers
transaction_workers = []
for i in range(num_threads):
    transaction_workers.append(TransactionWorker([]))
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([]))
Example #5
0
import sys
sys.path.append(sys.path[0] + "/..")
from lstore.db import Database
from lstore.query import Query
from lstore.config import *
from time import process_time

import os
os.system("clear")
if (os.path.isdir('ECS165')):
    os.system("rm -rf ECS165")

# Student Id and 4 grades
db = Database()
db.open('ECS165')
grades_table = db.create_table('Grades', 2, 0)
# grades_table = db.get_table('Grades')
query = Query(grades_table)
records = {}
'''
create only one record and update the same record
for multiple times (for examples, 1200 > 2 * 512 = 1024)
to trigger merge
'''

key = 914285714
records[key] = [key, 123456]
query.insert(*records[key])
print("Insert one record")

for i in range(2000):
from lstore.db import Database
from lstore.query import Query
from lstore.config import *
from lstore.buffer_pool import BufferPool

from random import choice, randint, sample, seed
# from colorama import Fore, Back, Style
import os
os.system("clear")
# Student Id and 4 grades
# init()
db = Database()
db.open('./ECS165')
# First Time => create_table, afterwards => get_table
grades_table = db.create_table('Grades', 5, 0)
# grades_table = db.get_table('Grades')
query = Query(grades_table)

records = {}

seed(3562901)

for i in range(0, 1000):
    key = 92106429 + randint(0, 9000)
    while key in records:
        key = 92106429 + randint(0, 9000)
    records[key] = [key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20)]
    query.insert(*records[key])
    # print('inserted', records[key])

for key in records: