Search and return document features from the online document store.
(
self,
provider: Provider,
table: FeatureView,
requested_features: Optional[List[str]],
query: List[float],
top_k: int,
distance_metric: Optional[str],
)
| 3778 | ) |
| 3779 | |
| 3780 | def _retrieve_from_online_store( |
| 3781 | self, |
| 3782 | provider: Provider, |
| 3783 | table: FeatureView, |
| 3784 | requested_features: Optional[List[str]], |
| 3785 | query: List[float], |
| 3786 | top_k: int, |
| 3787 | distance_metric: Optional[str], |
| 3788 | ) -> List[ |
| 3789 | Tuple[ |
| 3790 | Timestamp, Optional[EntityKey], "FieldStatus.ValueType", Value, Value, Value |
| 3791 | ] |
| 3792 | ]: |
| 3793 | """ |
| 3794 | Search and return document features from the online document store. |
| 3795 | """ |
| 3796 | documents = provider.retrieve_online_documents( |
| 3797 | config=self.config, |
| 3798 | table=table, |
| 3799 | requested_features=requested_features, |
| 3800 | query=query, |
| 3801 | top_k=top_k, |
| 3802 | distance_metric=distance_metric, |
| 3803 | ) |
| 3804 | |
| 3805 | read_row_protos = [] |
| 3806 | row_ts_proto = Timestamp() |
| 3807 | |
| 3808 | for row_ts, entity_key, feature_val, vector_value, distance_val in documents: # type: ignore[misc] |
| 3809 | # Reset timestamp to default or update if row_ts is not None |
| 3810 | if row_ts is not None: |
| 3811 | row_ts_proto.FromDatetime(row_ts) |
| 3812 | |
| 3813 | if feature_val is None or vector_value is None or distance_val is None: |
| 3814 | feature_val = Value() |
| 3815 | vector_value = Value() |
| 3816 | distance_val = Value() |
| 3817 | status = FieldStatus.NOT_FOUND |
| 3818 | else: |
| 3819 | status = FieldStatus.PRESENT |
| 3820 | |
| 3821 | read_row_protos.append( |
| 3822 | ( |
| 3823 | row_ts_proto, |
| 3824 | entity_key, |
| 3825 | status, |
| 3826 | feature_val, |
| 3827 | vector_value, |
| 3828 | distance_val, |
| 3829 | ) |
| 3830 | ) |
| 3831 | return read_row_protos |
| 3832 | |
| 3833 | def _retrieve_from_online_store_v2( |
| 3834 | self, |
no test coverage detected