11package feast .core .model ;
22
3+ import com .google .protobuf .Duration ;
34import com .google .protobuf .InvalidProtocolBufferException ;
45import feast .core .FeatureSetProto .EntitySpec ;
56import feast .core .FeatureSetProto .FeatureSetSpec ;
@@ -43,6 +44,10 @@ public class FeatureSet extends AbstractTimestampEntity implements Comparable<Fe
4344 @ Column (name = "version" )
4445 private int version ;
4546
47+ // Max allowed staleness for features in this featureSet.
48+ @ Column (name = "max_age" )
49+ private long maxAgeSeconds ;
50+
4651 @ OneToMany (cascade = CascadeType .ALL , fetch = FetchType .EAGER )
4752 @ Fetch (value = FetchMode .SUBSELECT )
4853 @ JoinColumn (name = "entities" )
@@ -63,25 +68,17 @@ public FeatureSet() {
6368 super ();
6469 }
6570
66- public FeatureSet (String name , int version , List <Field > entities , List <Field > features ,
71+ public FeatureSet (String name , int version , long maxAgeSeconds , List <Field > entities , List <Field > features ,
6772 Source source ) {
6873 this .id = String .format ("%s:%s" , name , version );
6974 this .name = name ;
7075 this .version = version ;
76+ this .maxAgeSeconds = maxAgeSeconds ;
7177 this .entities = entities ;
7278 this .features = features ;
7379 this .source = source ;
7480 }
7581
76- /**
77- * Updates the source of the featureset to point to the correct topic.
78- *
79- * @param topic topic to write this featureset to.
80- */
81- public void updateSourceTopic (String topic ) throws InvalidProtocolBufferException {
82- source .setTopic (topic );
83- }
84-
8582 public static FeatureSet fromProto (FeatureSetSpec featureSetSpec ) {
8683 Source source = Source .fromProto (featureSetSpec .getSource ());
8784 String id = String .format ("%s:%d" , featureSetSpec .getName (), featureSetSpec .getVersion ());
@@ -100,6 +97,7 @@ public static FeatureSet fromProto(FeatureSetSpec featureSetSpec) {
10097
10198 return new FeatureSet (featureSetSpec .getName (),
10299 featureSetSpec .getVersion (),
100+ featureSetSpec .getMaxAge ().getSeconds (),
103101 entities ,
104102 features ,
105103 source );
@@ -124,6 +122,7 @@ public FeatureSetSpec toProto() throws InvalidProtocolBufferException {
124122 return FeatureSetSpec .newBuilder ()
125123 .setName (name )
126124 .setVersion (version )
125+ .setMaxAge (Duration .newBuilder ().setSeconds (maxAgeSeconds ))
127126 .addAllEntities (entitySpecs )
128127 .addAllFeatures (featureSpecs )
129128 .setSource (source .toProto ())
0 commit comments