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

Merge Release #3481

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
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 @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -14,8 +15,6 @@
import com.bakdata.conquery.models.datasets.concepts.filters.specific.SelectFilter;
import com.bakdata.conquery.util.search.TrieSearch;
import com.fasterxml.jackson.annotation.JsonIgnore;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -35,7 +34,7 @@ public class FilterSearch {
*/
@JsonIgnore
private Map<Searchable, TrieSearch<FrontendValue>> searchCache = new HashMap<>();
private Object2LongMap<SelectFilter<?>> totals = new Object2LongOpenHashMap<>();
private Map<SelectFilter<?>, Integer> totals = new HashMap<>();

/**
* From a given {@link FrontendValue} extract all relevant keywords.
Expand Down Expand Up @@ -69,12 +68,16 @@ public final List<TrieSearch<FrontendValue>> getSearchesFor(SelectFilter<?> sear
.collect(Collectors.toList());
}

public long getTotal(SelectFilter<?> filter) {
return totals.computeIfAbsent(filter, (f) -> filter.getSearchReferences().stream()
.map(searchCache::get)
.flatMap(TrieSearch::stream)
.distinct()
.count());
public int getTotal(SelectFilter<?> filter) {
return totals.computeIfAbsent(filter, (f) -> {
HashSet<FrontendValue> count = new HashSet<>();

for (TrieSearch<FrontendValue> search : getSearchesFor(filter)) {
search.iterator().forEachRemaining(count::add);
}

return count.size();
});
}


Expand Down Expand Up @@ -116,7 +119,7 @@ public void shrinkSearch(Searchable searchable) {
}

public synchronized void clearSearch() {
totals = new Object2LongOpenHashMap<>();
totals = new HashMap<>();
searchCache = new HashMap<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private Cursor<FrontendValue> listAllValues(SelectFilter<?> searchable) {
return new Cursor<>(Iterators.filter(iterators, seen::add));
}

private long countAllValues(SelectFilter<?> searchable) {
private int countAllValues(SelectFilter<?> searchable) {
final Namespace namespace = namespaces.get(searchable.getDataset().getId());

return namespace.getFilterSearch().getTotal(searchable);
Expand Down Expand Up @@ -313,10 +313,10 @@ public ResolvedConceptsResult resolveConceptElements(TreeConcept concept, List<S
/**
* Container class to pair number of available values and Cursor for those values.
*/
private record CursorAndLength(Cursor<FrontendValue> values, long size) {
private record CursorAndLength(Cursor<FrontendValue> values, int size) {
}

public record AutoCompleteResult(List<FrontendValue> values, long total) {
public record AutoCompleteResult(List<FrontendValue> values, int total) {
}

public record ResolvedFilterResult(ConnectorId tableId, String filterId, Collection<FrontendValue> value) {
Expand Down
Loading