#transaction_workers[i].add_transaction(select_transactions[i])
    #transaction_workers[i].add_transaction(update_transactions[i])
worker_keys = [ {} for t in transaction_workers ]

'''
for i in range(0, 10000):
    key = 92106429 + i
    keys.append(key)
    i = i % num_threads
    records[key] = [key, randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20)]
    q = Query(grades_table)
    insert_transactions[i].add_query(q.insert, q.table, *records[key])
    worker_keys[i][key] = True
'''

q = Query(grades_table)
for i in range(0, 100):
    key = 92106429 + i
    keys.append(key)
    i = i % num_threads
    records[key] = [key, randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20), randint(i * 20, (i + 1) * 20)]

# test to see if the same key can be inserted twice

for i in range(0, 5):
    insert_transactions[0].add_query(q.insert, q.table, *records[keys[i]])

for i in range(6, 10):
    insert_transactions[0].add_query(q.insert, q.table, *records[keys[i]])
    
示例#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()