Skip to content

Commit 8f41e36

Browse files
authored
Fix multi cells in bigtable retriever & type bugs (#22)
Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
1 parent 84f0d72 commit 8f41e36

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

serving/src/test/java/feast/serving/it/ServingServiceBigTableIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static void globalSetup() throws IOException {
218218
SchemaBuilder.record("DriverData")
219219
.namespace(featureTableName)
220220
.fields()
221-
.requiredInt(feature1Reference.getName())
221+
.requiredLong(feature1Reference.getName())
222222
.requiredDouble(feature2Reference.getName())
223223
.nullableString(feature3Reference.getName(), "null")
224224
.requiredString(feature4Reference.getName())
@@ -228,7 +228,7 @@ static void globalSetup() throws IOException {
228228

229229
GenericRecord record =
230230
new GenericRecordBuilder(ftSchema)
231-
.set("trip_cost", 5)
231+
.set("trip_cost", 5L)
232232
.set("trip_distance", 3.5)
233233
.set("trip_empty", null)
234234
.set("trip_wrong_type", "test")
@@ -245,7 +245,7 @@ static void globalSetup() throws IOException {
245245
SchemaBuilder.record("DriverMerchantData")
246246
.namespace(rideMerchantFeatureTableName)
247247
.fields()
248-
.requiredInt(feature1Reference.getName())
248+
.requiredLong(feature1Reference.getName())
249249
.requiredDouble(feature2Reference.getName())
250250
.nullableString(feature3Reference.getName(), "null")
251251
.requiredString(feature4Reference.getName())
@@ -256,7 +256,7 @@ static void globalSetup() throws IOException {
256256
// Entity-Feature Row
257257
GenericRecord compoundEntityRecord =
258258
new GenericRecordBuilder(compoundFtSchema)
259-
.set("trip_cost", 10)
259+
.set("trip_cost", 10L)
260260
.set("trip_distance", 5.5)
261261
.set("trip_empty", null)
262262
.set("trip_wrong_type", "wrong_type")

storage/api/src/main/java/feast/storage/api/retriever/NativeFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public ValueProto.Value getFeatureValue(ValueProto.ValueType.Enum valueType) {
5858
finalValue = ValueProto.Value.newBuilder().setInt32Val((Integer) featureValue).build();
5959
break;
6060
case INT64:
61-
finalValue = ValueProto.Value.newBuilder().setInt64Val((Integer) featureValue).build();
61+
finalValue = ValueProto.Value.newBuilder().setInt64Val((Long) featureValue).build();
6262
break;
6363
case DOUBLE:
6464
finalValue = ValueProto.Value.newBuilder().setDoubleVal((Double) featureValue).build();
6565
break;
6666
case FLOAT:
67-
finalValue = ValueProto.Value.newBuilder().setFloatVal((Long) featureValue).build();
67+
finalValue = ValueProto.Value.newBuilder().setFloatVal((Float) featureValue).build();
6868
break;
6969
case BYTES:
7070
finalValue = ValueProto.Value.newBuilder().setBytesVal((ByteString) featureValue).build();

storage/connectors/bigtable/src/main/java/feast/storage/connectors/bigtable/retriever/BigTableOnlineRetriever.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.cloud.bigtable.data.v2.models.Filters;
2121
import com.google.cloud.bigtable.data.v2.models.Query;
2222
import com.google.cloud.bigtable.data.v2.models.Row;
23+
import com.google.cloud.bigtable.data.v2.models.RowCell;
2324
import com.google.protobuf.ByteString;
2425
import com.google.protobuf.Timestamp;
2526
import feast.proto.serving.ServingAPIProto.FeatureReferenceV2;
@@ -242,9 +243,15 @@ private List<List<Feature>> convertRowToFeature(
242243
if (!rows.containsKey(rowKey)) {
243244
return Collections.<Feature>emptyList();
244245
} else {
245-
return rows.get(rowKey).getCells().stream()
246+
Row row = rows.get(rowKey);
247+
return featureReferences.stream()
248+
.map(FeatureReferenceV2::getFeatureTable)
249+
.distinct()
250+
.map(cf -> row.getCells(cf, ""))
251+
.filter(ls -> !ls.isEmpty())
246252
.flatMap(
247-
rowCell -> {
253+
rowCells -> {
254+
RowCell rowCell = rowCells.get(0); // Latest cell
248255
String family = rowCell.getFamily();
249256
ByteString value = rowCell.getValue();
250257

0 commit comments

Comments
 (0)