Skip to content

Commit

Permalink
Merge pull request #1351 from b2ihealthcare/issue/SO-6321-flush-cache…
Browse files Browse the repository at this point in the history
…d-expand-requests

fix(snomed.datastore): Flush pending expand requests in request cache...
  • Loading branch information
cmark authored Dec 3, 2024
2 parents 9ef4e8e + 1523345 commit 67682e6
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.SortedSet;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -44,6 +41,7 @@
import com.b2international.snowowl.snomed.datastore.internal.rf2.ComponentIdSnomedDsvExportItem;
import com.b2international.snowowl.snomed.datastore.internal.rf2.DatatypeSnomedDsvExportItem;
import com.b2international.snowowl.snomed.datastore.internal.rf2.SnomedRefSetDSVExportModel;
import com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache;
import com.b2international.snowowl.snomed.datastore.request.SnomedConceptSearchRequestBuilder;
import com.b2international.snowowl.snomed.datastore.request.SnomedRequests;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -488,7 +486,12 @@ private Map<String, String> createTypeIdMap(SnomedConcepts concepts) {

private void writeValues(IProgressMonitor monitor, BufferedWriter writer) throws IOException {
final Iterable<SnomedConcepts> chunks = () -> getConceptStream(DATA_EXPAND).iterator();
final Optional<SnomedConceptRequestCache> cache = Optional.ofNullable(context)
.flatMap(v -> v.optionalService(SnomedConceptRequestCache.class));

for (SnomedConcepts chunk : chunks) {
// make sure we compute all requested expansions before we move forward
cache.ifPresent(service -> service.compute(context));
writeValues(writer, chunk);
monitor.worked(chunk.getItems().size());
}
Expand Down

0 comments on commit 67682e6

Please sign in to comment.