Skip to content

Commit 935602e

Browse files
author
zhilingc
committed
Remove feature and entity references
1 parent d579424 commit 935602e

6 files changed

Lines changed: 50 additions & 218 deletions

File tree

‎core/src/main/java/feast/core/model/Entity.java‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,36 @@
1919
import feast.core.FeatureSetProto.EntitySpec;
2020
import feast.types.ValueProto.ValueType;
2121
import java.util.Objects;
22-
import javax.persistence.EmbeddedId;
23-
import javax.persistence.Table;
22+
import javax.persistence.*;
2423
import lombok.Getter;
2524
import lombok.Setter;
2625

2726
/** Feast entity object. Contains name and type of the entity. */
2827
@Getter
2928
@Setter
3029
@javax.persistence.Entity
31-
@Table(name = "entities")
30+
@Table(
31+
name = "entities",
32+
uniqueConstraints = @UniqueConstraint(columnNames = {"name", "feature_set_id"}))
3233
public class Entity {
33-
@EmbeddedId private EntityReference reference;
34+
35+
@Id @GeneratedValue private Long id;
36+
37+
private String name;
38+
39+
@ManyToOne(fetch = FetchType.LAZY)
40+
private FeatureSet featureSet;
3441

3542
/** Data type of the entity. String representation of {@link ValueType} * */
3643
private String type;
3744

3845
public Entity() {}
3946

4047
private Entity(String name, ValueType.Enum type) {
41-
this.setReference(new EntityReference(name));
48+
this.setName(name);
4249
this.setType(type.toString());
4350
}
4451

45-
public static Entity withRef(EntityReference entityRef) {
46-
Entity entity = new Entity();
47-
entity.setReference(entityRef);
48-
return entity;
49-
}
50-
5152
public static Entity fromProto(EntitySpec entitySpec) {
5253
Entity entity = new Entity(entitySpec.getName(), entitySpec.getValueType());
5354
return entity;
@@ -61,12 +62,12 @@ public boolean equals(Object o) {
6162
if (o == null || getClass() != o.getClass()) {
6263
return false;
6364
}
64-
Entity feature = (Entity) o;
65-
return getReference().equals(feature.getReference()) && getType().equals(feature.getType());
65+
Entity entity = (Entity) o;
66+
return getName().equals(entity.getName()) && getType().equals(entity.getType());
6667
}
6768

6869
@Override
6970
public int hashCode() {
70-
return Objects.hash(super.hashCode(), getReference(), getType());
71+
return Objects.hash(super.hashCode(), getName(), getType());
7172
}
7273
}

‎core/src/main/java/feast/core/model/EntityReference.java‎

Lines changed: 0 additions & 72 deletions
This file was deleted.

‎core/src/main/java/feast/core/model/Feature.java‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@
3434
@Getter
3535
@Setter
3636
@Entity
37-
@Table(name = "features")
37+
@Table(
38+
name = "features",
39+
uniqueConstraints = @UniqueConstraint(columnNames = {"name", "feature_set_id"}))
3840
public class Feature {
3941

40-
@EmbeddedId private FeatureReference reference;
42+
@Id @GeneratedValue private Long id;
43+
44+
private String name;
45+
46+
@ManyToOne(fetch = FetchType.LAZY)
47+
private FeatureSet featureSet;
4148

4249
/** Data type of the feature. String representation of {@link ValueType} * */
4350
private String type;
@@ -74,16 +81,10 @@ public class Feature {
7481
public Feature() {}
7582

7683
private Feature(String name, ValueType.Enum type) {
77-
this.setReference(new FeatureReference(name));
84+
this.setName(name);
7885
this.setType(type.toString());
7986
}
8087

81-
public static Feature withRef(FeatureReference featureRef) {
82-
Feature feature = new Feature();
83-
feature.setReference(featureRef);
84-
return feature;
85-
}
86-
8788
public static Feature fromProto(FeatureSpec featureSpec) {
8889
Feature feature = new Feature(featureSpec.getName(), featureSpec.getValueType());
8990
feature.labels = TypeConversion.convertMapToJsonString(featureSpec.getLabelsMap());
@@ -166,7 +167,7 @@ public boolean equals(Object o) {
166167
return false;
167168
}
168169
Feature feature = (Feature) o;
169-
return Objects.equals(getReference(), feature.getReference())
170+
return Objects.equals(getName(), feature.getName())
170171
&& Objects.equals(labels, feature.labels)
171172
&& Arrays.equals(getPresence(), feature.getPresence())
172173
&& Arrays.equals(getGroupPresence(), feature.getGroupPresence())
@@ -188,6 +189,6 @@ public boolean equals(Object o) {
188189

189190
@Override
190191
public int hashCode() {
191-
return Objects.hash(super.hashCode(), getReference(), getType(), labels);
192+
return Objects.hash(super.hashCode(), getName(), getType(), getLabels());
192193
}
193194
}

‎core/src/main/java/feast/core/model/FeatureReference.java‎

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)