from template.db import Database
from template.query import Query
from template.transaction import Transaction
from template.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 = {}
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())
Exemple #2
0
from template.db import Database
from template.query import Query
#from template.config import init

from random import choice, randint, sample, seed
#init()

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

# Simulate updates
keys = sorted(list(records.keys()))
for _ in range(10):
    for key in keys:
        for j in range(1, grades_table.num_columns):
from template.db import Database
from template.query import Query
import os
'''
READ ME!!
    Before using this demo, be sure that the Tail_Const is set to a value high enough
    to guaranteed that all updates are contained within the same block.
        config.py -> TAIL_CONST = 4

    This program is meant to run sequentially through all parts starting with an empty ECS165
    directory.
'''
db2 = Database()
db2.open("ECS165")
#db2.open()
print(db2)
g_table = db2.get_table('Grades')
q = Query(g_table)
rec3 = q.select(92106429, 0, [1, 1, 1, 1, 1])[0]
rec4 = q.select(92106430, 0, [1, 1, 1, 1, 1])[0]
print("Rec = ", rec3)
print("Rec2 = ", rec4)
rec3f = q.selectFull(92106429, 0)
rec4f = q.selectFull(92106430, 0)
print("Rec_full = ", rec3f)
print("Rec2_full = ", rec4f)
db2.close()
Exemple #4
0
from template.db import Database
from template.query import Query
from template.transaction import Transaction
from template.transaction_worker import TransactionWorker

from random import choice, randint, sample, seed
from threading import Thread, Lock

db = Database()
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())
#
Exemple #5
0
from template.db import Database
from template.query import Query
from template.transaction import Transaction
from template.transaction_worker import TransactionWorker

from random import choice, randint, sample, seed

db = Database()
db.open('/home/pkhorsand/165a-winter-2020-private/db')
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):
from template.db import Database
from template.query import Query
from template.index import *
import time

db = Database()
db.open("./ECS165")
grades_table = db.create_table('QueryTester', 5, 0)

#index = Index(grades_table)

query = Query(grades_table)
# print("Inserting 1M items")
for i in range(1_001):
    query.insert(*[i, i, i + 1, i + 2, i + 3])
for record in query.select_range(500, 525, 0, [1, 1, 1, 1, 1]):
    print(record.columns)
#query.insert(*[1, 2, 3, 4, 5]) # <-
#query.insert(*[1, 3, 4, 5, 6])
#query.insert(*[2, 1, 3, 3, 4])
# query.select(2, 1, [None, None, None, None, 1])[0].columns
#index.drop_index(1)
#print(query.select(2, 1, [1, 1, 1, 1, 1])[0].columns)
#print(query.select(4, 2, [1, None, None, None, None])[0].columns[0])
"""print(query.delete(1))
print(query.select(2, 1, [None, None, None, None, 1]))
print(query.select(3, 1, [None, None, None, None, 1]))
print(query.select(2,0,[None, None, None, None, 1]))"""

query.insert(*[42, 42, 3, 4, 5])
from template.db import Database
from template.query import Query
import os
'''
READ ME!!
    Before using this demo, be sure that the Tail_Const is set to a value high enough
    to guaranteed that all updates are contained within the same block.
        config.py -> TAIL_CONST = 4

    This program is meant to run sequentially through all parts starting with an empty ECS165
    directory.
'''
db = Database()
db.open("ECS165")
print(db)
g_table = db.get_table('Grades')
q = Query(g_table)

print("Merge Start")
q.table.merge(0)
print("Merge End")

db.close()