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 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) for i in range(0, 100): r = sorted(sample(range(0, len(keys)), 2))
keys = sorted(list(records.keys())) print("Insert finished") grades_table.index.create_index(1) grades_table.index.create_index(2) grades_table.index.create_index(3) grades_table.index.create_index(4) _records = [records[key] for key in keys] for c in range(grades_table.num_columns): _keys = list(set([record[c] for record in _records])) index = { v: [record for record in _records if record[c] == v] for v in _keys } for key in _keys: results = [r.columns for r in query.select(key, c, [1, 1, 1, 1, 1])] error = False if len(results) != len(index[key]): error = True if not error: for record in index[key]: if record not in results: error = True break if error: print('select error on', key, ', column', c, ':', results, ', correct:', index[key]) print("Select finished") exit()
t.run() db.close() exit() 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): result = 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()
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: result = query.select(key, 0, [1, 1, 1, 1, 1])[0] record = result[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.columns, ', correct:', records[key]) print("Select finished") deleted_keys = sample(keys, 100) for key in deleted_keys: query.delete(key) records.pop(key, None)
records[key] = [key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20)] query.insert(*records[key]) keys = sorted(list(records.keys())) print("Insert finished") grades_table.index.create_index(1) grades_table.index.create_index(2) grades_table.index.create_index(3) grades_table.index.create_index(4) _records = [records[key] for key in keys] for c in range(grades_table.num_columns): _keys = list(set(record[c] for record in _records)) index = {v: [record for record in _records if record[c] == v] for v in _keys} for key in _keys: results = [r.columns for r in query.select(key, c, [1, 1, 1, 1, 1])] error = False if len(results) != len(index[key]): error = True if not error: for record in index[key]: if record not in results: error = True break if error: print('select error on', key, ', column', c, ':', results, ', correct:', index[key]) print("Select finished") for _ in range(10): for key in keys: updated_columns = [None, None, None, None, None]
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) print("\n") input() updated_columns = [None, 100, 200, 300, None] key = 2 print("demo multiple column update, where key = " + str(key)) print("new column data to update: ") print(updated_columns) print("\n") query.update(key, *updated_columns) print("updated records:") record = query.select(key, [1, 1, 1, 1, 1])
key = 92106429 + i # distinct primary key records[key] = [ key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20) ] query.insert(*records[key]) insert_time_1 = process_time() print("Inserting 5k records took: \t\t\t", insert_time_1 - insert_time_0) # Measuring Select Performance select_time_0 = process_time() for key in records: query.select(key, 0, [1, 1, 1, 1, 1])[0] select_time_1 = process_time() print("Selecting 5k records took: \t\t\t", select_time_1 - select_time_0) # Measuring update Performance update_time_0 = process_time() for key in records: updated_columns = [None, None, None, None, None] for i in range(1, grades_table.num_columns): value = randint(0, 20) updated_columns[i] = value query.update(key, *updated_columns) update_time_1 = process_time() print("Updating 5k records of total 20000 times took: \t\t\t", update_time_1 - update_time_0)
seed(3562901) for i in range(0, 10000): key = 92106429 + i records[key] = [ key, randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20) ] query.insert(*records[key]) keys = sorted(list(records.keys())) print("Insert finished") 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]) # else: # print('select on', key, ':', record) print("Select finished") for i in range(0, 100): r = sorted(sample(range(0, len(keys)), 2)) column_sum = sum(map(lambda key: records[key][0], keys[r[0]:r[1] + 1])) result = query.sum(keys[r[0]], keys[r[1]], 0) if column_sum != result: