Esempio n. 1
0
    def online_read(
        self,
        project: str,
        table: Union[FeatureTable, FeatureView],
        entity_key: EntityKeyProto,
    ) -> Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]:
        entity_key_bin = serialize_entity_key(entity_key)

        conn = self._get_conn()
        cur = conn.cursor()
        cur.execute(
            f"SELECT feature_name, value, event_ts FROM {_table_id(project, table)} WHERE entity_key = ?",
            (entity_key_bin, ),
        )

        res = {}
        res_ts = None
        for feature_name, val_bin, ts in cur.fetchall():
            val = ValueProto()
            val.ParseFromString(val_bin)
            res[feature_name] = val
            res_ts = ts

        if not res:
            return None, None
        else:
            return res_ts, res
Esempio n. 2
0
File: gcp.py Progetto: rikima/feast
    def online_read(
        self, project: str, table: FeatureTable, entity_key: EntityKeyProto
    ) -> Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]:
        client = self._initialize_client()

        document_id = compute_datastore_entity_id(entity_key)
        key = client.key("Project", project, "Table", table.name, "Row",
                         document_id)
        value = client.get(key)
        if value is not None:
            res = {}
            for feature_name, value_bin in value["values"].items():
                val = ValueProto()
                val.ParseFromString(value_bin)
                res[feature_name] = val
            return value["event_ts"], res
        else:
            return None, None