Skip to content

Commit f867b52

Browse files
committed
Cleanup code
Signed-off-by: Terence <terencelimxp@gmail.com>
1 parent 7220482 commit f867b52

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

common/src/main/java/feast/common/models/FeatureTable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package feast.common.models;
1818

1919
import feast.proto.core.FeatureTableProto.FeatureTableSpec;
20+
import feast.proto.serving.ServingAPIProto.FeatureReferenceV2;
2021

2122
public class FeatureTable {
2223

@@ -30,4 +31,16 @@ public class FeatureTable {
3031
public static String getFeatureTableStringRef(String project, FeatureTableSpec featureTableSpec) {
3132
return String.format("%s/%s", project, featureTableSpec.getName());
3233
}
34+
35+
/**
36+
* Accepts FeatureReferenceV2 object and returns its reference in String
37+
* "project/featuretable_name".
38+
*
39+
* @param featureReference {@link FeatureReferenceV2}
40+
* @return String format of FeatureTableReference
41+
*/
42+
public static String getFeatureTableStringRef(
43+
String project, FeatureReferenceV2 featureReference) {
44+
return String.format("%s/%s", project, featureReference.getFeatureTable());
45+
}
3346
}

serving/src/main/java/feast/serving/specs/CachedSpecService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ private Map<String, FeatureTableSpec> getFeatureTableMap() {
397397

398398
public FeatureTableSpec getFeatureTableSpec(
399399
String project, ServingAPIProto.FeatureReferenceV2 featureReference) {
400-
String featureTableRefStr = project + "/" + featureReference.getFeatureTable();
400+
String featureTableRefStr = getFeatureTableStringRef(project, featureReference);
401401
FeatureTableSpec featureTableSpec;
402402
try {
403403
featureTableSpec = featureTableCache.get(featureTableRefStr);

storage/connectors/redis/src/main/java/feast/storage/connectors/redis/common/RedisHashDecoder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public static List<Optional<Feature>> retrieveFeature(
4646
new HashMap<>();
4747
Map<String, Timestamp> featureTableTimestampMap = new HashMap<>();
4848

49-
for (int i = 0; i < redisHashValues.size(); i++) {
50-
if (redisHashValues.get(i).hasValue()) {
51-
byte[] redisValueK = redisHashValues.get(i).getKey();
52-
byte[] redisValueV = redisHashValues.get(i).getValue();
49+
for (KeyValue<byte[], byte[]> entity : redisHashValues) {
50+
if (entity.hasValue()) {
51+
byte[] redisValueK = entity.getKey();
52+
byte[] redisValueV = entity.getValue();
5353

5454
// Decode data from Redis into Feature object fields
5555
if (new String(redisValueK).startsWith(timestampPrefix)) {

0 commit comments

Comments
 (0)