MCPcopy Index your code
hub / github.com/feast-dev/feast / _get_unique_entities_from_values

Function _get_unique_entities_from_values

sdk/python/feast/utils.py:1020–1046  ·  view source on GitHub ↗

Return the set of unique composite Entities for a Feature View and the indexes at which they appear. This method allows us to query the OnlineStore for data we need only once rather than requesting and processing data for the same combination of Entities multiple times.

(
    table_entity_values: Dict[str, List[ValueProto]],
)

Source from the content-addressed store, hash-verified

1018
1019
1020def _get_unique_entities_from_values(
1021 table_entity_values: Dict[str, List[ValueProto]],
1022) -> Tuple[Tuple[Dict[str, ValueProto], ...], Tuple[List[int], ...], int]:
1023 """Return the set of unique composite Entities for a Feature View and the indexes at which they appear.
1024
1025 This method allows us to query the OnlineStore for data we need only once
1026 rather than requesting and processing data for the same combination of
1027 Entities multiple times.
1028 """
1029 keys = table_entity_values.keys()
1030 # Sort the rowise data to allow for grouping but keep original index. This lambda is
1031 # sufficient as Entity types cannot be complex (ie. lists).
1032 rowise = list(enumerate(zip(*table_entity_values.values())))
1033 rowise.sort(key=lambda row: tuple(getattr(x, x.WhichOneof("val")) for x in row[1]))
1034
1035 # Identify unique entities and the indexes at which they occur.
1036 unique_entities: Tuple[Dict[str, ValueProto], ...]
1037 indexes: Tuple[List[int], ...]
1038 unique_entities, indexes = tuple(
1039 zip(
1040 *[
1041 (dict(zip(keys, k)), [_[0] for _ in g])
1042 for k, g in itertools.groupby(rowise, key=lambda x: x[1])
1043 ]
1044 )
1045 )
1046 return unique_entities, indexes, len(rowise)
1047
1048
1049def _drop_unneeded_columns(

Callers

nothing calls this directly

Calls 3

keysMethod · 0.80
sortMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected