-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_eab_package.py
More file actions
55 lines (39 loc) · 1.64 KB
/
test_eab_package.py
File metadata and controls
55 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
# @Project: index_test
# @Module: test_eab_package
# @Author: Wei Zhou
# @Time: 2024/1/1 0:55
import json
from index_eab.eab_utils.workload import Workload
from index_eab.eab_utils.common_utils import get_columns_from_schema, read_row_query
from index_eab.eab_utils.postgres_dbms import PostgresDatabaseConnector
from index_eab.index_advisor.extend_algorithm import ExtendAlgorithm
def test_case():
# 1. Configuration Setup
host = "-- your host --"
port = "-- your port --"
db_name = "-- your database --"
user = "-- your user --"
password = "-- your password --"
connector = PostgresDatabaseConnector(autocommit=True, host=host, port=port,
db_name=db_name, user=user, password=password)
# 2. Data Preparation
schema_load = "/path/your database schema.json"
with open(schema_load, "r") as rf:
schema_list = json.load(rf)
_, columns = get_columns_from_schema(schema_list)
work_load = "/path/testing workload.json"
with open(work_load, "r") as rf:
work_list = json.load(rf)[:1]
for work in work_list:
workload = Workload(read_row_query(work, columns,
varying_frequencies=True, seed=666))
# 3. Index Advisor Evaluation
config = {"budget_MB": 500, "max_index_width": 2, "max_indexes": 5, "constraint": "storage"}
index_advisor = ExtendAlgorithm(connector, config)
indexes = index_advisor.calculate_best_indexes(workload, columns=columns)
break
return indexes
if __name__ == "__main__":
indexes = test_case()
print(indexes)