fetch available values for gallery via autocomplete method

We had a method that returned the values of a field
with respect to a query. That method was inefficient,
because it executed the query, fetched all Docs
and collected the values.
The autocomplete method we introduced a while back
can answer the same question but much more efficiently.
This commit is contained in:
2019-08-25 18:52:05 +02:00
parent 4f61d91c79
commit 2f35978184
4 changed files with 21 additions and 34 deletions

View File

@@ -34,6 +34,17 @@ public class CollectionUtils {
return Stream.of(input).map(mapper).collect(Collectors.toList());
}
public static <O extends Collection<R>, T, R> O map(final Collection<T> input, final O result,
final Function<T, R> mapper) {
for (final T t : input) {
final R e = mapper.apply(t);
result.add(e);
}
return result;
}
public static <T, V> Map<T, V> createMapFromValues(final Iterable<V> iterable, final Function<V, T> keyMapper) {
final Map<T, V> result = new HashMap<>();