Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(snomed.datastore): Flush pending expand requests in request cache... #1351

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
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
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
Loading