Skip to content

Commit

Permalink
Update _linkable_reference_index to use a normal dict
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jan 18, 2024
1 parent 6a494d4 commit bff8629
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions metricflow/model/semantics/semantic_model_lookup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import logging
from collections import defaultdict
from copy import deepcopy
from typing import Dict, List, Optional, Sequence, Set

Expand Down Expand Up @@ -59,7 +58,7 @@ def __init__( # noqa: D
self._measure_agg_time_dimension: Dict[MeasureReference, TimeDimensionReference] = {}
self._measure_non_additive_dimension_specs: Dict[MeasureReference, NonAdditiveDimensionSpec] = {}
self._dimension_index: Dict[DimensionReference, List[SemanticModel]] = {}
self._linkable_reference_index: Dict[LinkableElementReference, List[SemanticModel]] = defaultdict(list)
self._linkable_reference_index: Dict[LinkableElementReference, List[SemanticModel]] = {}
self._entity_index: Dict[EntityReference, List[SemanticModel]] = {}
self._semantic_model_names: Set[str] = set()

Expand Down Expand Up @@ -245,11 +244,10 @@ def _add_semantic_model(self, semantic_model: SemanticModel) -> None:
)
self._measure_non_additive_dimension_specs[measure.reference] = non_additive_dimension_spec
for dim in semantic_model.dimensions:
self._linkable_reference_index[dim.reference].append(semantic_model)

semantic_models_for_dimension = self._dimension_index.get(dim.reference, [])
semantic_models_for_dimension.append(semantic_model)
self._dimension_index[dim.reference] = semantic_models_for_dimension
self._linkable_reference_index[dim.reference] = semantic_models_for_dimension

self._dimension_ref_to_spec[dim.time_dimension_reference or dim.reference] = (
TimeDimensionSpec.from_name(dim.name)
Expand All @@ -261,8 +259,8 @@ def _add_semantic_model(self, semantic_model: SemanticModel) -> None:
semantic_models_for_entity = self._entity_index.get(entity.reference, [])
semantic_models_for_entity.append(semantic_model)
self._entity_index[entity.reference] = semantic_models_for_entity
self._linkable_reference_index[entity.reference] = semantic_models_for_entity

self._linkable_reference_index[entity.reference].append(semantic_model)
self._entity_ref_to_spec[entity.reference] = EntitySpec.from_name(entity.name)

self._semantic_model_reference_to_semantic_model[semantic_model.reference] = semantic_model
Expand Down

0 comments on commit bff8629

Please sign in to comment.