| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d98a80d commit fe85f18
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,8 +119,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequestV2 re | |||
| 119 | 119 | .filter(r -> this.featureSpecRetriever.isOnDemandFeatureReference(r)) | |
| 120 | 120 | .collect(Collectors.toList()); | |
| 121 | 121 | ||
| 122 | - // Get the set of request data feature names from the ODFV references. | ||
| 123 | - // Also get the batch feature view references that the ODFVs require as inputs. | ||
| 122 | + // Get the set of request data feature names and feature inputs from the ODFV references. | ||
| 124 | 123 | Pair<Set<String>, List<FeatureReferenceV2>> pair = | |
| 125 | 124 | extractRequestDataFeatureNamesAndOnDemandFeatureInputs( | |
| 126 | 125 | onDemandFeatureReferences, projectName); | |
@@ -137,38 +136,12 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequestV2 re | |||
| 137 | 136 | } | |
| 138 | 137 | ||
| 139 | 138 | // Separate entity rows into entity data and request feature data. | |
| 139 | + Pair<List<GetOnlineFeaturesRequestV2.EntityRow>, Map<String, List<ValueProto.Value>>> | ||
| 140 | + entityRowsAndRequestDataFeatures = separateEntityRows(requestDataFeatureNames, request); | ||
| 140 | 141 | List<GetOnlineFeaturesRequestV2.EntityRow> entityRows = | |
| 141 | - new ArrayList<GetOnlineFeaturesRequestV2.EntityRow>(); | ||
| 142 | + entityRowsAndRequestDataFeatures.getLeft(); | ||
| 142 | 143 | Map<String, List<ValueProto.Value>> requestDataFeatures = | |
| 143 | - new HashMap<String, List<ValueProto.Value>>(); | ||
| 144 | - | ||
| 145 | - for (GetOnlineFeaturesRequestV2.EntityRow entityRow : request.getEntityRowsList()) { | ||
| 146 | - Map<String, ValueProto.Value> fieldsMap = new HashMap<String, ValueProto.Value>(); | ||
| 147 | - | ||
| 148 | - for (Map.Entry<String, ValueProto.Value> entry : entityRow.getFieldsMap().entrySet()) { | ||
| 149 | - String key = entry.getKey(); | ||
| 150 | - ValueProto.Value value = entry.getValue(); | ||
| 151 | - | ||
| 152 | - if (requestDataFeatureNames.contains(key)) { | ||
| 153 | - if (!requestDataFeatures.containsKey(key)) { | ||
| 154 | - requestDataFeatures.put(key, new ArrayList<ValueProto.Value>()); | ||
| 155 | - } | ||
| 156 | - requestDataFeatures.get(key).add(value); | ||
| 157 | - } else { | ||
| 158 | - fieldsMap.put(key, value); | ||
| 159 | - } | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - // Construct new entity row containing the extracted entity data, if necessary. | ||
| 163 | - if (!fieldsMap.isEmpty()) { | ||
| 164 | - GetOnlineFeaturesRequestV2.EntityRow newEntityRow = | ||
| 165 | - GetOnlineFeaturesRequestV2.EntityRow.newBuilder() | ||
| 166 | - .setTimestamp(entityRow.getTimestamp()) | ||
| 167 | - .putAllFields(fieldsMap) | ||
| 168 | - .build(); | ||
| 169 | - entityRows.add(newEntityRow); | ||
| 170 | - } | ||
| 171 | - } | ||
| 144 | + entityRowsAndRequestDataFeatures.getRight(); | ||
| 172 | 145 | // TODO: error checking on lengths of lists in entityRows and requestDataFeatures | |
| 173 | 146 | ||
| 174 | 147 | // Extract values and statuses to be used later in constructing FieldValues for the response. | |
@@ -493,8 +466,6 @@ private void populateFeatureCountMetrics( | |||
| 493 | 466 | private Pair<Set<String>, List<FeatureReferenceV2>> | |
| 494 | 467 | extractRequestDataFeatureNamesAndOnDemandFeatureInputs( | |
| 495 | 468 | List<FeatureReferenceV2> onDemandFeatureReferences, String projectName) { | |
| 496 | - // Get the set of request data feature names from the ODFV references. | ||
| 497 | - // Also get the batch feature view references that the ODFVs require as inputs. | ||
| 498 | 469 | Set<String> requestDataFeatureNames = new HashSet<String>(); | |
| 499 | 470 | List<FeatureReferenceV2> onDemandFeatureInputs = new ArrayList<FeatureReferenceV2>(); | |
| 500 | 471 | for (FeatureReferenceV2 featureReference : onDemandFeatureReferences) { | |
@@ -539,6 +510,57 @@ private void populateFeatureCountMetrics( | |||
| 539 | 510 | return pair; | |
| 540 | 511 | } | |
| 541 | 512 | ||
| 513 | + /** | ||
| 514 | + * Separate the entity rows of a request into entity data and request feature data. | ||
| 515 | + * | ||
| 516 | + * @param requestDataFeatureNames set of feature names for the request data | ||
| 517 | + * @param request the GetOnlineFeaturesRequestV2 containing the entity rows | ||
| 518 | + * @return a pair containing the set of request data feature names and list of on demand feature | ||
| 519 | + * inputs | ||
| 520 | + */ | ||
| 521 | + private Pair<List<GetOnlineFeaturesRequestV2.EntityRow>, Map<String, List<ValueProto.Value>>> | ||
| 522 | + separateEntityRows(Set<String> requestDataFeatureNames, GetOnlineFeaturesRequestV2 request) { | ||
| 523 | + // Separate entity rows into entity data and request feature data. | ||
| 524 | + List<GetOnlineFeaturesRequestV2.EntityRow> entityRows = | ||
| 525 | + new ArrayList<GetOnlineFeaturesRequestV2.EntityRow>(); | ||
| 526 | + Map<String, List<ValueProto.Value>> requestDataFeatures = | ||
| 527 | + new HashMap<String, List<ValueProto.Value>>(); | ||
| 528 | + | ||
| 529 | + for (GetOnlineFeaturesRequestV2.EntityRow entityRow : request.getEntityRowsList()) { | ||
| 530 | + Map<String, ValueProto.Value> fieldsMap = new HashMap<String, ValueProto.Value>(); | ||
| 531 | + | ||
| 532 | + for (Map.Entry<String, ValueProto.Value> entry : entityRow.getFieldsMap().entrySet()) { | ||
| 533 | + String key = entry.getKey(); | ||
| 534 | + ValueProto.Value value = entry.getValue(); | ||
| 535 | + | ||
| 536 | + if (requestDataFeatureNames.contains(key)) { | ||
| 537 | + if (!requestDataFeatures.containsKey(key)) { | ||
| 538 | + requestDataFeatures.put(key, new ArrayList<ValueProto.Value>()); | ||
| 539 | + } | ||
| 540 | + requestDataFeatures.get(key).add(value); | ||
| 541 | + } else { | ||
| 542 | + fieldsMap.put(key, value); | ||
| 543 | + } | ||
| 544 | + } | ||
| 545 | + | ||
| 546 | + // Construct new entity row containing the extracted entity data, if necessary. | ||
| 547 | + if (!fieldsMap.isEmpty()) { | ||
| 548 | + GetOnlineFeaturesRequestV2.EntityRow newEntityRow = | ||
| 549 | + GetOnlineFeaturesRequestV2.EntityRow.newBuilder() | ||
| 550 | + .setTimestamp(entityRow.getTimestamp()) | ||
| 551 | + .putAllFields(fieldsMap) | ||
| 552 | + .build(); | ||
| 553 | + entityRows.add(newEntityRow); | ||
| 554 | + } | ||
| 555 | + } | ||
| 556 | + | ||
| 557 | + Pair<List<GetOnlineFeaturesRequestV2.EntityRow>, Map<String, List<ValueProto.Value>>> pair = | ||
| 558 | + new ImmutablePair< | ||
| 559 | + List<GetOnlineFeaturesRequestV2.EntityRow>, Map<String, List<ValueProto.Value>>>( | ||
| 560 | + entityRows, requestDataFeatures); | ||
| 561 | + return pair; | ||
| 562 | + } | ||
| 563 | + | ||
| 542 | 564 | /** | |
| 543 | 565 | * Process a response from the feature transformation server by augmenting the given lists of | |
| 544 | 566 | * field maps and status maps with the correct fields from the response. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments