from src.query import Query from src.table import Table from src.bits import Bits table = Table("test", 5, 0) query = Query(table) # record1 = [1, 90, 0, 0, 0] # record2 = [2, 91, 0, 0, 0] # record3 = [3, 92, 0, 0, 0] query.insert(1, 90, 0, 0, 0) query.insert(2, 91, 0, 0, 0) query.insert(3, 92, 0, 0, 0) r1 = table.get(1, Bits('11111')) r2 = table.get(2, Bits('11111')) r3 = table.get(3, Bits('11111')) print(r1) print(r2) print(r3) query.delete(1) query.delete(2) print("record3's LID: ", table.key_lid[3])
[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): query.update(choice(keys), *(choice(update_cols))) update_time_1 = process_time() print("Updating 10k records took: \t\t\t", update_time_1 - update_time_0) # Measuring Select Performance select_time_0 = process_time() for i in range(0, 10000): query.select(choice(keys), [1, 1, 1, 1, 1]) select_time_1 = process_time() print("Selecting 10k records took: \t\t\t", select_time_1 - select_time_0) # Measuring Aggregate Performance agg_time_0 = process_time() for i in range(0, 10000, 100): query.sum(i, 100, randrange(0, 5)) agg_time_1 = process_time() print("Aggregate 10k of 100 record batch took:\t", agg_time_1 - agg_time_0) # Measuring Delete Performance delete_time_0 = process_time() for i in range(0, 10000): query.delete(906659671 + i) delete_time_1 = process_time() print("Deleting 10k records took: \t\t\t", delete_time_1 - delete_time_0)
# print(records[key]) # print(records[key]) for key in keys: record = query.select(key, 0, [1, 1, 1, 1, 1])[0] error = False for i, column in enumerate(record.columns): if column != records[key][i]: error = True if error: print('select error on', key, ':', record, ', correct:', records[key]) print("Select finished") deleted_keys = sample(keys, 100) for key in deleted_keys: query.delete(key) records.pop(key, None) print("Delete finished") for i in range(0, 100): r = sorted(sample(range(0, len(keys)), 2)) column_sum = sum( map(lambda x: records[x][0] if x in records else 0, keys[r[0]:r[1] + 1])) result = query.sum(keys[r[0]], keys[r[1]], 0) if column_sum != result: print('sum error on [', keys[r[0]], ',', keys[r[1]], ']: ', result, ', correct: ', column_sum) print("Aggregate finished") db.close()