@Test public void combineSizeShouldDefaultToTen() throws IOException, InterruptedException { Map<Shard, List<String>> execResults = Maps.newHashMap(); execResults.put(new Shard("t1", "s1"), Lists.newArrayList("aa", "cc", "ee", "gg", "ii")); execResults.put(new Shard("t1", "s2"), Lists.newArrayList("bb", "dd", "ff", "hh", "jj")); List<String> expected = Lists.newArrayList("aa", "bb", "cc", "dd", "ee", "ff", "gg", "hh", "ii", "jj"); TermsCommand cmd = new TermsCommand(); List<String> returned = cmd.combine(new TestCombiningContext(), execResults); assertEquals(expected, returned); }
@Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t); } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); }
TermsCommand extends ClusterServerReadCommandSingleTable<List<String>> { @Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t); } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); } }
TermsCommand extends ClusterServerReadCommandSingleTable<List<String>> { @Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t); } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); }  }
TermsCommand extends ClusterServerReadCommandSingleTable<List<String>> { @Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t); } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); }  @Override List<String> execute(IndexContext context); @Override List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results); @Override String getName(); short getSize(); void setSize(short size); String getFieldName(); void setFieldName(String fieldName); String getStartWith(); void setStartWith(String startWith); }
TermsCommand extends ClusterServerReadCommandSingleTable<List<String>> { @Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t); } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); }  @Override List<String> execute(IndexContext context); @Override List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results); @Override String getName(); short getSize(); void setSize(short size); String getFieldName(); void setFieldName(String fieldName); String getStartWith(); void setStartWith(String startWith);  }