Java 类org.apache.lucene.search.grouping.function.FunctionFirstPassGroupingCollector 实例源码

项目:search    文件:TestGrouping.java   
private Collection<SearchGroup<BytesRef>> getSearchGroups(AbstractFirstPassGroupingCollector<?> c, int groupOffset, boolean fillFields) {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    return ((TermFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
  } else if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    Collection<SearchGroup<MutableValue>> mutableValueGroups = ((FunctionFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
    if (mutableValueGroups == null) {
      return null;
    }

    List<SearchGroup<BytesRef>> groups = new ArrayList<>(mutableValueGroups.size());
    for (SearchGroup<MutableValue> mutableValueGroup : mutableValueGroups) {
      SearchGroup<BytesRef> sg = new SearchGroup<>();
      sg.groupValue = mutableValueGroup.groupValue.exists() ? ((MutableValueStr) mutableValueGroup.groupValue).value : null;
      sg.sortValues = mutableValueGroup.sortValues;
      groups.add(sg);
    }
    return groups;
  }
  fail();
  return null;
}
项目:search    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T> AbstractFirstPassGroupingCollector<T> createRandomFirstPassCollector(DocValuesType dvType, Sort groupSort, String groupField, int topNGroups) throws IOException {
  Random random = random();
  if (dvType != null) {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  } else {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  }
}
项目:NYBC    文件:TestGrouping.java   
private Collection<SearchGroup<BytesRef>> getSearchGroups(AbstractFirstPassGroupingCollector<?> c, int groupOffset, boolean fillFields) {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    return ((TermFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
  } else if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    Collection<SearchGroup<MutableValue>> mutableValueGroups = ((FunctionFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
    if (mutableValueGroups == null) {
      return null;
    }

    List<SearchGroup<BytesRef>> groups = new ArrayList<SearchGroup<BytesRef>>(mutableValueGroups.size());
    for (SearchGroup<MutableValue> mutableValueGroup : mutableValueGroups) {
      SearchGroup<BytesRef> sg = new SearchGroup<BytesRef>();
      sg.groupValue = mutableValueGroup.groupValue.exists() ? ((MutableValueStr) mutableValueGroup.groupValue).value : null;
      sg.sortValues = mutableValueGroup.sortValues;
      groups.add(sg);
    }
    return groups;
  }
  fail();
  return null;
}
项目:NYBC    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T> AbstractFirstPassGroupingCollector<T> createRandomFirstPassCollector(DocValuesType dvType, Sort groupSort, String groupField, int topNGroups) throws IOException {
  Random random = random();
  if (dvType != null) {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<Object, Object>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  } else {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<Object, Object>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestGrouping.java   
private Collection<SearchGroup<BytesRef>> getSearchGroups(AbstractFirstPassGroupingCollector<?> c, int groupOffset, boolean fillFields) {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    return ((TermFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
  } else if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(c.getClass())) {
    Collection<SearchGroup<MutableValue>> mutableValueGroups = ((FunctionFirstPassGroupingCollector) c).getTopGroups(groupOffset, fillFields);
    if (mutableValueGroups == null) {
      return null;
    }

    List<SearchGroup<BytesRef>> groups = new ArrayList<SearchGroup<BytesRef>>(mutableValueGroups.size());
    for (SearchGroup<MutableValue> mutableValueGroup : mutableValueGroups) {
      SearchGroup<BytesRef> sg = new SearchGroup<BytesRef>();
      sg.groupValue = mutableValueGroup.groupValue.exists() ? ((MutableValueStr) mutableValueGroup.groupValue).value : null;
      sg.sortValues = mutableValueGroup.sortValues;
      groups.add(sg);
    }
    return groups;
  }
  fail();
  return null;
}
项目:Maskana-Gestor-de-Conocimiento    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T> AbstractFirstPassGroupingCollector<T> createRandomFirstPassCollector(DocValuesType dvType, Sort groupSort, String groupField, int topNGroups) throws IOException {
  Random random = random();
  if (dvType != null) {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<Object, Object>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  } else {
    if (random.nextBoolean()) {
      return (AbstractFirstPassGroupingCollector<T>) new FunctionFirstPassGroupingCollector(new BytesRefFieldSource(groupField), new HashMap<Object, Object>(), groupSort, topNGroups);
    } else {
      return (AbstractFirstPassGroupingCollector<T>) new TermFirstPassGroupingCollector(groupField, groupSort, topNGroups);
    }
  }
}
项目:search    文件:TestGrouping.java   
private AbstractFirstPassGroupingCollector<?> createFirstPassCollector(String groupField, Sort groupSort, int topDocs, AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector) throws IOException {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionFirstPassGroupingCollector(vs, new HashMap<>(), groupSort, topDocs);
  } else {
    return new TermFirstPassGroupingCollector(groupField, groupSort, topDocs);
  }
}
项目:search    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T extends Comparable> AbstractDistinctValuesCollector<AbstractDistinctValuesCollector.GroupCount<T>> createDistinctCountCollector(AbstractFirstPassGroupingCollector<T> firstPassGroupingCollector,
                                                                    String groupField,
                                                                    String countField,
                                                                    DocValuesType dvType) {
  Random random = random();
  Collection<SearchGroup<T>> searchGroups = firstPassGroupingCollector.getTopGroups(0, false);
  if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    return (AbstractDistinctValuesCollector) new FunctionDistinctValuesCollector(new HashMap<>(), new BytesRefFieldSource(groupField), new BytesRefFieldSource(countField), (Collection) searchGroups);
  } else {
    return (AbstractDistinctValuesCollector) new TermDistinctValuesCollector(groupField, countField, (Collection) searchGroups);
  }
}
项目:search    文件:Grouping.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collector createFirstPassCollector() throws IOException {
  // Ok we don't want groups, but do want a total count
  if (actualGroupsToFind <= 0) {
    fallBackCollector = new TotalHitCountCollector();
    return fallBackCollector;
  }

  sort = sort == null ? Sort.RELEVANCE : sort;
  firstPass = new FunctionFirstPassGroupingCollector(groupBy, context, searcher.weightSort(sort), actualGroupsToFind);
  return firstPass;
}
项目:NYBC    文件:TestGrouping.java   
private AbstractFirstPassGroupingCollector<?> createFirstPassCollector(String groupField, Sort groupSort, int topDocs, AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector) throws IOException {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionFirstPassGroupingCollector(vs, new HashMap<Object, Object>(), groupSort, topDocs);
  } else {
    return new TermFirstPassGroupingCollector(groupField, groupSort, topDocs);
  }
}
项目:NYBC    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T extends Comparable> AbstractDistinctValuesCollector<AbstractDistinctValuesCollector.GroupCount<T>> createDistinctCountCollector(AbstractFirstPassGroupingCollector<T> firstPassGroupingCollector,
                                                                    String groupField,
                                                                    String countField,
                                                                    DocValuesType dvType) {
  Random random = random();
  Collection<SearchGroup<T>> searchGroups = firstPassGroupingCollector.getTopGroups(0, false);
  if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    return (AbstractDistinctValuesCollector) new FunctionDistinctValuesCollector(new HashMap<Object, Object>(), new BytesRefFieldSource(groupField), new BytesRefFieldSource(countField), (Collection) searchGroups);
  } else {
    return (AbstractDistinctValuesCollector) new TermDistinctValuesCollector(groupField, countField, (Collection) searchGroups);
  }
}
项目:NYBC    文件:Grouping.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collector createFirstPassCollector() throws IOException {
  // Ok we don't want groups, but do want a total count
  if (actualGroupsToFind <= 0) {
    fallBackCollector = new TotalHitCountCollector();
    return fallBackCollector;
  }

  sort = sort == null ? Sort.RELEVANCE : sort;
  firstPass = new FunctionFirstPassGroupingCollector(groupBy, context, searcher.weightSort(sort), actualGroupsToFind);
  return firstPass;
}
项目:search-core    文件:Grouping.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collector createFirstPassCollector() throws IOException {
  // Ok we don't want groups, but do want a total count
  if (actualGroupsToFind <= 0) {
    fallBackCollector = new TotalHitCountCollector();
    return fallBackCollector;
  }

  sort = sort == null ? Sort.RELEVANCE : sort;
  firstPass = new FunctionFirstPassGroupingCollector(groupBy, context, searcher.weightSort(sort), actualGroupsToFind);
  return firstPass;
}
项目:read-open-source-code    文件:Grouping.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collector createFirstPassCollector() throws IOException {
  // Ok we don't want groups, but do want a total count
  if (actualGroupsToFind <= 0) {
    fallBackCollector = new TotalHitCountCollector();
    return fallBackCollector;
  }

  sort = sort == null ? Sort.RELEVANCE : sort;
  firstPass = new FunctionFirstPassGroupingCollector(groupBy, context, searcher.weightSort(sort), actualGroupsToFind);
  return firstPass;
}
项目:read-open-source-code    文件:Grouping.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collector createFirstPassCollector() throws IOException {
  // Ok we don't want groups, but do want a total count
  if (actualGroupsToFind <= 0) {
    fallBackCollector = new TotalHitCountCollector();
    return fallBackCollector;
  }

  sort = sort == null ? Sort.RELEVANCE : sort;
  firstPass = new FunctionFirstPassGroupingCollector(groupBy, context, searcher.weightSort(sort), actualGroupsToFind);
  return firstPass;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestGrouping.java   
private AbstractFirstPassGroupingCollector<?> createFirstPassCollector(String groupField, Sort groupSort, int topDocs, AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector) throws IOException {
  if (TermFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionFirstPassGroupingCollector(vs, new HashMap<Object, Object>(), groupSort, topDocs);
  } else {
    return new TermFirstPassGroupingCollector(groupField, groupSort, topDocs);
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:DistinctValuesCollectorTest.java   
@SuppressWarnings({"unchecked","rawtypes"})
private <T extends Comparable> AbstractDistinctValuesCollector<AbstractDistinctValuesCollector.GroupCount<T>> createDistinctCountCollector(AbstractFirstPassGroupingCollector<T> firstPassGroupingCollector,
                                                                    String groupField,
                                                                    String countField,
                                                                    DocValuesType dvType) {
  Random random = random();
  Collection<SearchGroup<T>> searchGroups = firstPassGroupingCollector.getTopGroups(0, false);
  if (FunctionFirstPassGroupingCollector.class.isAssignableFrom(firstPassGroupingCollector.getClass())) {
    return (AbstractDistinctValuesCollector) new FunctionDistinctValuesCollector(new HashMap<Object, Object>(), new BytesRefFieldSource(groupField), new BytesRefFieldSource(countField), (Collection) searchGroups);
  } else {
    return (AbstractDistinctValuesCollector) new TermDistinctValuesCollector(groupField, countField, (Collection) searchGroups);
  }
}