Commit 63419240 authored by Rob Tomsick's avatar Rob Tomsick

Import kill, clean up lambda

parent 5c4ee837
......@@ -22,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......
......@@ -269,7 +269,7 @@ implements DictionaryService
final Function<NDCProduct, Pair<NDCProduct, Double>> scoreMapper =
product -> Pair.of(product, scoreProduct(product, term));
final Comparator<Pair<?, Double>> pairSort =
(a, b) -> Double.compare(a.getRight(), b.getRight());
(a, b) -> Double.compare(b.getRight(), a.getRight());
/* Establish a fallback limit. Since trivially-short strings are likely
* to produce huge numbers of mostly-irrelevant results, we limit our
......@@ -304,27 +304,28 @@ implements DictionaryService
.map(PhoneticHash :: hash)
.map(t -> field(name("phonetic_hash")).containsIgnoreCase(t))
.reduce(DSL.trueCondition(), (a, b) -> a.and(b)));
return builder
.build()
.parallel()
.flatMap(c ->
this.loadProducts(
this.ctx.select(idField)
.from(D_TABLE)
.where(c)
.limit(fbLimit)
.fetch(idField))
.stream()
.map(scoreMapper)
.sorted(pairSort)
.limit(limit)
)
.unordered()
.distinct()
.sorted(pairSort)
.limit(limit)
.map(p -> p.getLeft())
.collect(Collectors.toList());
.build()
.parallel()
.flatMap(c ->
this.loadProducts(
this.ctx.select(idField)
.from(D_TABLE)
.where(c)
.limit(fbLimit)
.fetch(idField))
.stream()
.map(scoreMapper)
.sorted(pairSort)
.limit(limit)
)
.unordered()
.distinct()
.sorted(pairSort)
.map(Pair :: getLeft)
.limit(limit)
.collect(Collectors.toList());
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment