Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Java
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Mar 28, 2022
commit 05b393e12443b86e38b0f25f0f60e84d60f3ae3f
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ public ServingAPIProto.GetOnlineFeaturesResponse getOnlineFeatures(
.collect(Collectors.toList());

// ToDo (pyalex): refactor transformation service to delete unused left part of the returned
// Pair from extractRequestDataFeatureNamesAndOnDemandFeatureInputs.
// Pair from extractRequestDataFeatureNamesAndOnDemandFeatureSources.
// Currently, we can retrieve context variables directly from GetOnlineFeaturesRequest.
List<FeatureReferenceV2> onDemandFeatureInputs =
List<FeatureReferenceV2> onDemandFeatureSources =
this.onlineTransformationService.extractOnDemandFeaturesDependencies(
onDemandFeatureReferences);

// Add on demand feature inputs to list of feature references to retrieve.
for (FeatureReferenceV2 onDemandFeatureInput : onDemandFeatureInputs) {
if (!retrievedFeatureReferences.contains(onDemandFeatureInput)) {
retrievedFeatureReferences.add(onDemandFeatureInput);
// Add on demand feature sources to list of feature references to retrieve.
for (FeatureReferenceV2 onDemandFeatureSource : onDemandFeatureSources) {
if (!retrievedFeatureReferences.contains(onDemandFeatureSource)) {
retrievedFeatureReferences.add(onDemandFeatureSource);
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public ServingAPIProto.GetOnlineFeaturesResponse getOnlineFeatures(
// data.
this.populateOnDemandFeatures(
onDemandFeatureReferences,
onDemandFeatureInputs,
onDemandFeatureSources,
retrievedFeatureReferences,
request,
features,
Expand Down Expand Up @@ -257,7 +257,7 @@ private List<Map<String, ValueProto.Value>> getEntityRows(

private void populateOnDemandFeatures(
List<FeatureReferenceV2> onDemandFeatureReferences,
List<FeatureReferenceV2> onDemandFeatureInputs,
List<FeatureReferenceV2> onDemandFeatureSources,
List<FeatureReferenceV2> retrievedFeatureReferences,
ServingAPIProto.GetOnlineFeaturesRequest request,
List<List<feast.storage.api.retriever.Feature>> features,
Expand All @@ -271,7 +271,7 @@ private void populateOnDemandFeatures(
for (int featureIdx = 0; featureIdx < retrievedFeatureReferences.size(); featureIdx++) {
FeatureReferenceV2 featureReference = retrievedFeatureReferences.get(featureIdx);

if (!onDemandFeatureInputs.contains(featureReference)) {
if (!onDemandFeatureSources.contains(featureReference)) {
continue;
}

Expand All @@ -291,7 +291,7 @@ private void populateOnDemandFeatures(
valueList));
}
// Serialize the augmented values.
ValueType transformationInput =
ValueType transformationSource =
this.onlineTransformationService.serializeValuesIntoArrowIPC(onDemandContext);

// Send out requests to the FTS and process the responses.
Expand All @@ -305,7 +305,7 @@ private void populateOnDemandFeatures(
TransformFeaturesRequest transformFeaturesRequest =
TransformFeaturesRequest.newBuilder()
.setOnDemandFeatureViewName(onDemandFeatureViewName)
.setTransformationInput(transformationInput)
.setTransformationSource(transformationSource)
.build();

TransformFeaturesResponse transformFeaturesResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,55 +83,55 @@ public TransformFeaturesResponse transformFeatures(
@Override
public List<ServingAPIProto.FeatureReferenceV2> extractOnDemandFeaturesDependencies(
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureReferences) {
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureInputs = new ArrayList<>();
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureSources = new ArrayList<>();
for (ServingAPIProto.FeatureReferenceV2 featureReference : onDemandFeatureReferences) {
OnDemandFeatureViewProto.OnDemandFeatureViewSpec onDemandFeatureViewSpec =
this.registryRepository.getOnDemandFeatureViewSpec(featureReference);
Map<String, OnDemandFeatureViewProto.OnDemandInput> inputs =
onDemandFeatureViewSpec.getInputsMap();
Map<String, OnDemandFeatureViewProto.OnDemandSource> sources =
onDemandFeatureViewSpec.getSourcesMap();

for (OnDemandFeatureViewProto.OnDemandInput input : inputs.values()) {
OnDemandFeatureViewProto.OnDemandInput.InputCase inputCase = input.getInputCase();
switch (inputCase) {
for (OnDemandFeatureViewProto.OnDemandSource source : sources.values()) {
OnDemandFeatureViewProto.OnDemandSource.SourceCase sourceCase = source.getSourceCase();
switch (sourceCase) {
case REQUEST_DATA_SOURCE:
// Do nothing. The value should be provided as dedicated request parameter
break;
case FEATURE_VIEW_PROJECTION:
FeatureReferenceProto.FeatureViewProjection projection =
input.getFeatureViewProjection();
source.getFeatureViewProjection();
for (FeatureProto.FeatureSpecV2 featureSpec : projection.getFeatureColumnsList()) {
String featureName = featureSpec.getName();
ServingAPIProto.FeatureReferenceV2 onDemandFeatureInput =
ServingAPIProto.FeatureReferenceV2 onDemandFeatureSource =
ServingAPIProto.FeatureReferenceV2.newBuilder()
.setFeatureViewName(projection.getFeatureViewName())
.setFeatureName(featureName)
.build();
onDemandFeatureInputs.add(onDemandFeatureInput);
onDemandFeatureSources.add(onDemandFeatureSource);
}
break;
case FEATURE_VIEW:
FeatureViewProto.FeatureView featureView = input.getFeatureView();
FeatureViewProto.FeatureView featureView = source.getFeatureView();
FeatureViewProto.FeatureViewSpec featureViewSpec = featureView.getSpec();
String featureViewName = featureViewSpec.getName();
for (FeatureProto.FeatureSpecV2 featureSpec : featureViewSpec.getFeaturesList()) {
String featureName = featureSpec.getName();
ServingAPIProto.FeatureReferenceV2 onDemandFeatureInput =
ServingAPIProto.FeatureReferenceV2 onDemandFeatureSource =
ServingAPIProto.FeatureReferenceV2.newBuilder()
.setFeatureViewName(featureViewName)
.setFeatureName(featureName)
.build();
onDemandFeatureInputs.add(onDemandFeatureInput);
onDemandFeatureSources.add(onDemandFeatureSource);
}
break;
default:
throw Status.INTERNAL
.withDescription(
"OnDemandInput proto input field has an unexpected type: " + inputCase)
"OnDemandSource proto source field has an unexpected type: " + sourceCase)
.asRuntimeException();
}
}
}
return onDemandFeatureInputs;
return onDemandFeatureSources;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -321,8 +321,8 @@ public ValueType serializeValuesIntoArrowIPC(List<Pair<String, List<ValueProto.V
.asRuntimeException();
}
byte[] byteData = out.toByteArray();
ByteString inputData = ByteString.copyFrom(byteData);
ValueType transformationInput = ValueType.newBuilder().setArrowValue(inputData).build();
return transformationInput;
ByteString sourceData = ByteString.copyFrom(byteData);
ValueType transformationSource = ValueType.newBuilder().setArrowValue(sourceData).build();
return transformationSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public interface TransformationService {
TransformFeaturesResponse transformFeatures(TransformFeaturesRequest transformFeaturesRequest);

/**
* Extract the list of on demand feature inputs from a list of ODFV references.
* Extract the list of on demand feature sources from a list of ODFV references.
*
* @param onDemandFeatureReferences list of ODFV references to be parsed
* @return list of on demand feature inputs
* @return list of on demand feature sources
*/
List<ServingAPIProto.FeatureReferenceV2> extractOnDemandFeaturesDependencies(
List<ServingAPIProto.FeatureReferenceV2> onDemandFeatureReferences);
Expand Down