@Test public void testCombineResults() { LookupResultItem item1 = new LookupResultItem("test", "proj1", 10); LookupResultItem item2 = new LookupResultItem("test", "proj2", 10); LookupResultItem item3 = new LookupResultItem("test", "proj3", 10); LookupResultItem item4 = new LookupResultItem("test2", "proj3", 10); LookupResultItem item5 = new LookupResultItem("test3", "proj1", 15); List<LookupResultItem> res = SuggesterUtils.combineResults( Arrays.asList(item1, item2, item3, item4, item5), 2); LookupResultItem combined = new LookupResultItem("test", "proj1", 10); combined.combine(new LookupResultItem("test", "proj2", 10)); combined.combine(new LookupResultItem("test", "proj3", 10)); assertThat(res, contains(combined, item5)); }
static List<LookupResultItem> combineResults(final List<LookupResultItem> results, final int resultSize) { LookupPriorityQueue queue = new LookupPriorityQueue(resultSize); Map<String, LookupResultItem> map = new HashMap<>(); for (LookupResultItem item : results) { LookupResultItem storedItem = map.get(item.getPhrase()); if (storedItem == null) { map.put(item.getPhrase(), item); } else { storedItem.combine(item); } } map.values().forEach(queue::insertWithOverflow); return queue.getResult(); }
SuggesterUtils { static List<LookupResultItem> combineResults(final List<LookupResultItem> results, final int resultSize) { LookupPriorityQueue queue = new LookupPriorityQueue(resultSize); Map<String, LookupResultItem> map = new HashMap<>(); for (LookupResultItem item : results) { LookupResultItem storedItem = map.get(item.getPhrase()); if (storedItem == null) { map.put(item.getPhrase(), item); } else { storedItem.combine(item); } } map.values().forEach(queue::insertWithOverflow); return queue.getResult(); } }
SuggesterUtils { static List<LookupResultItem> combineResults(final List<LookupResultItem> results, final int resultSize) { LookupPriorityQueue queue = new LookupPriorityQueue(resultSize); Map<String, LookupResultItem> map = new HashMap<>(); for (LookupResultItem item : results) { LookupResultItem storedItem = map.get(item.getPhrase()); if (storedItem == null) { map.put(item.getPhrase(), item); } else { storedItem.combine(item); } } map.values().forEach(queue::insertWithOverflow); return queue.getResult(); } private  SuggesterUtils(); }
SuggesterUtils { static List<LookupResultItem> combineResults(final List<LookupResultItem> results, final int resultSize) { LookupPriorityQueue queue = new LookupPriorityQueue(resultSize); Map<String, LookupResultItem> map = new HashMap<>(); for (LookupResultItem item : results) { LookupResultItem storedItem = map.get(item.getPhrase()); if (storedItem == null) { map.put(item.getPhrase(), item); } else { storedItem.combine(item); } } map.values().forEach(queue::insertWithOverflow); return queue.getResult(); } private  SuggesterUtils(); static List<Term> intoTerms(final Query query); static List<Term> intoTermsExceptPhraseQuery(final Query query); static boolean isComplexQuery(final Query query, final SuggesterQuery suggesterQuery); }
SuggesterUtils { static List<LookupResultItem> combineResults(final List<LookupResultItem> results, final int resultSize) { LookupPriorityQueue queue = new LookupPriorityQueue(resultSize); Map<String, LookupResultItem> map = new HashMap<>(); for (LookupResultItem item : results) { LookupResultItem storedItem = map.get(item.getPhrase()); if (storedItem == null) { map.put(item.getPhrase(), item); } else { storedItem.combine(item); } } map.values().forEach(queue::insertWithOverflow); return queue.getResult(); } private  SuggesterUtils(); static List<Term> intoTerms(final Query query); static List<Term> intoTermsExceptPhraseQuery(final Query query); static boolean isComplexQuery(final Query query, final SuggesterQuery suggesterQuery); static final int NORMALIZED_DOCUMENT_FREQUENCY_MULTIPLIER; }