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:
@@ -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<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user