Skip to content

Commit

Permalink
Cleanedup rollOver a little bit for brevity
Browse files Browse the repository at this point in the history
  • Loading branch information
koushikr committed Dec 6, 2024
1 parent c6dc877 commit 616861f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import lombok.SneakyThrows;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -125,9 +126,11 @@ public void rollOverAndUpdate(SchemaDetails schema) {
SchemaDetails.class
);
final var newSchemas = storedResults.hits().hits().stream()
.map(Hit::source).collect(Collectors.toList());
newSchemas.stream().filter(each -> !each.getReferenceId().equalsIgnoreCase(schema.getReferenceId()))
.forEach(each -> each.setSchemaState(SchemaState.ROLLED));
.map(Hit::source)
.filter(Objects::nonNull)
.filter(each -> !each.getReferenceId().equalsIgnoreCase(schema.getReferenceId()))
.peek(each -> each.setSchemaState(SchemaState.ROLLED))
.collect(Collectors.toList());
newSchemas.add(schema);
final var br = new BulkRequest.Builder()
.index(SCHEMA_INDEX)
Expand Down

0 comments on commit 616861f

Please sign in to comment.