Skip to content

Commit

Permalink
only further process transacted elements but keep other existing info…
Browse files Browse the repository at this point in the history
… from passed in nodeChangeInfo
  • Loading branch information
Doris Lam committed Mar 31, 2024
1 parent 404ef00 commit 27f056a
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,12 @@ public void primeNodeChangeInfo(NodeChangeInfo nodeChangeInfo, Collection<Elemen
FederatedNodeChangeInfo info = (FederatedNodeChangeInfo)nodeChangeInfo;
Set<String> indexIds = Optional.ofNullable(info.getReqIndexIds()).orElse(new HashSet<>());
Map<String, Node> existingNodeMap = Optional.ofNullable(info.getExistingNodeMap()).orElse(new HashMap<>());
Map<String, ElementJson> reqElementMap = Optional.ofNullable(info.getReqElementMap()).orElse(new HashMap<>());
Map<String, ElementJson> reqElementMap = new HashMap<>(); // don't add to any existing since this change processing is only for transactedElements
Map<String, ElementJson> existingElementMap = Optional.ofNullable(info.getExistingElementMap()).orElse(new HashMap<>());

Set<String> transactedIndexIds = new HashSet<>();
for (Node node : existingNodes) {
transactedIndexIds.add(node.getDocId());
indexIds.add(node.getDocId());
existingNodeMap.put(node.getNodeId(), node);
}
Expand All @@ -279,7 +281,7 @@ public void primeNodeChangeInfo(NodeChangeInfo nodeChangeInfo, Collection<Elemen
}

// bulk read existing elements in elastic
List<ElementJson> existingElements = nodeIndex.findAllById(indexIds);
List<ElementJson> existingElements = nodeIndex.findAllById(transactedIndexIds);
existingElementMap.putAll(convertJsonToMap(existingElements));

info.setExistingElementMap(existingElementMap);
Expand Down

0 comments on commit 27f056a

Please sign in to comment.