Package com.gojek.feast
Class FeastClient
- java.lang.Object
-
- com.gojek.feast.FeastClient
-
- All Implemented Interfaces:
AutoCloseable
public class FeastClient extends Object implements AutoCloseable
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static FeastClient
create(String host, int port)
Create a client to access FeastServingAPIProto.GetFeastServingInfoResponse
getFeastServingInfo()
List<Row>
getOnlineFeatures(List<String> featureRefs, List<Row> rows)
Get online features from Feast from FeatureSetsList<Row>
getOnlineFeatures(List<String> featureRefs, List<Row> rows, String project)
Get online features from Feast.List<Row>
getOnlineFeatures(List<String> featureRefs, List<Row> rows, String project, boolean omitEntitiesInResponse)
Get online features from Feast.
-
-
-
Method Detail
-
create
public static FeastClient create(String host, int port)
Create a client to access Feast- Parameters:
host
- hostname or ip address of Feast serving GRPC serverport
- port number of Feast serving GRPC server- Returns:
FeastClient
-
getFeastServingInfo
public ServingAPIProto.GetFeastServingInfoResponse getFeastServingInfo()
-
getOnlineFeatures
public List<Row> getOnlineFeatures(List<String> featureRefs, List<Row> rows)
Get online features from Feast from FeatureSets- Parameters:
featureRefs
- list of string feature references to retrieve in the following format featureSet:feature, where 'featureSet' and 'feature' refer to the FeatureSet and Feature names respectively. Only the Feature name is required.rows
- list ofRow
to select the entities to retrieve the features for.- Returns:
- list of
Row
containing retrieved data fields.
-
getOnlineFeatures
public List<Row> getOnlineFeatures(List<String> featureRefs, List<Row> rows, String project)
Get online features from Feast.- Parameters:
featureRefs
- list of string feature references to retrieve in the following format featureSet:feature, where 'featureSet' and 'feature' refer to the FeatureSet and Feature names respectively. Only the Feature name is required.rows
- list ofRow
to select the entities to retrieve the features forproject
-String
Specifies the project which contains the FeatureSets which the Feature requested belong to.- Returns:
- list of
Row
containing retrieved data fields.
-
getOnlineFeatures
public List<Row> getOnlineFeatures(List<String> featureRefs, List<Row> rows, String project, boolean omitEntitiesInResponse)
Get online features from Feast.Example of retrieving online features for the driver featureset, with features driver_id and driver_name
FeastClient client = FeastClient.create("localhost", 6566); List<String> requestedFeatureIds = Arrays.asList("driver:driver_id", "driver:driver_name"); List<Row> requestedRows = Arrays.asList(Row.create().set("driver_id", 123), Row.create().set("driver_id", 456)); List<Row> retrievedFeatures = client.getOnlineFeatures(requestedFeatureIds, requestedRows); retrievedFeatures.forEach(System.out::println);
- Parameters:
featureRefs
- list of string feature references to retrieve in the following format featureSet:feature, where 'featureSet' and 'feature' refer to the FeatureSet and Feature names respectively. Only the Feature name is required.rows
- list ofRow
to select the entities to retrieve the features forproject
-String
Specifies the project which contains the FeatureSets which the Feature requested belong to.omitEntitiesInResponse
- if true, the returnedRow
will not contain field and value for the entity- Returns:
- list of
Row
containing retrieved data fields.
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-