atoti.aggregate_provider.aggregate_provider module#
- class atoti.AggregateProvider#
An aggregate provider pre-aggregates some table columns up to certain levels. If a step of a query uses a subset of the aggregate provider’s levels and measures, the provider will speed up the query.
An aggregate provider uses additional memory to store the intermediate aggregates. The more levels and measures are added, the more memory it requires.
Example
>>> df = pd.DataFrame( ... { ... "Seller": ["Seller_1", "Seller_1", "Seller_2", "Seller_2"], ... "ProductId": ["aBk3", "ceJ4", "aBk3", "ceJ4"], ... "Price": [2.5, 49.99, 3.0, 54.99], ... } ... ) >>> table = session.read_pandas(df, table_name="Seller") >>> cube = session.create_cube(table) >>> l, m = cube.levels, cube.measures >>> cube.aggregate_providers.update( ... { ... "Seller provider": tt.AggregateProvider( ... key="bitmap", ... levels=[l["Seller"], l["ProductId"]], ... measures=[m["Price.SUM"]], ... filter=l["ProductId"] == "cdJ4", ... partitioning="hash4(Seller)", ... ) ... } ... )
- filter: Optional[Condition[LevelCoordinates, Literal['eq', 'isin'], Constant, Optional[Literal['and']]]] = None#
Only compute and provide aggregates matching this condition.
The passed condition must be an equality test on a level (handled by the provider or not) or a combination of that kind of condition.