MCPcopy Create free account
hub / github.com/apache/impala / Workload

Class Workload

tests/performance/workload.py:26–82  ·  view source on GitHub ↗

Represents a workload. A workload is the internal representation for the set of queries on a dataset. It consists of the dataset name, and a mapping of query names to query strings. Args: name (str): workload name. (Eg. tpch) query_name_filters (list of str): List of regular expressi

Source from the content-addressed store, hash-verified

24from tests.util.test_file_parser import load_tpc_queries
25
26class Workload(object):
27 """Represents a workload.
28
29 A workload is the internal representation for the set of queries on a dataset. It
30 consists of the dataset name, and a mapping of query names to query strings.
31
32 Args:
33 name (str): workload name. (Eg. tpch)
34 query_name_filters (list of str): List of regular expressions used for matching query
35 names
36
37 Attributes:
38 name (str): workload name (Eg. tpch)
39 _query_map (dict): contains a query name -> string mapping; mapping of query name to
40 section (ex. "TPCH-Q10" -> "select * from...")
41 """
42
43 WORKLOAD_DIR = os.environ['IMPALA_WORKLOAD_DIR']
44
45 def __init__(self, name, query_name_filters=None):
46 self._name = name
47 self._query_map = dict()
48 # Build the query name -> string mapping in the c'tor. We want to fail fast and early
49 # if the user input is bad.
50 self._query_map = load_tpc_queries(self._name, query_name_filters=query_name_filters)
51 assert len(self._query_map) > 0, "No matching queries found for %s" % self._name
52
53 @property
54 def name(self):
55 return self._name
56
57 @property
58 def query_map(self):
59 return self._query_map
60
61 def construct_queries(self, test_vector, scale_factor):
62 """Transform a query map into a list of query objects.
63
64 Transform all the queries in the workload's query map to query objects based on the
65 input test vector and scale factor.
66
67 Args:
68 test_vector (?): query vector
69 scale_factor (str): eg. "300gb"
70
71 Returns:
72 (list of Query): these will be consumed by ?
73 """
74
75 queries = list()
76 for query_name, query_str in self._query_map.items():
77 queries.append(Query(name=query_name,
78 query_str=query_str,
79 workload=self._name,
80 scale_factor=scale_factor,
81 test_vector=test_vector))
82 return queries
83

Callers 2

run-workload.pyFile · 0.90

Calls

no outgoing calls

Tested by 1