Java 类org.apache.lucene.search.grouping.term.TermFirstPassGroupingCollector 实例源码

项目: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    文件:TestGrouping.java   
@SuppressWarnings("unchecked")
private AbstractSecondPassGroupingCollector<?> createSecondPassCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                                      String groupField,
                                                                      Collection<SearchGroup<BytesRef>> searchGroups,
                                                                      Sort groupSort,
                                                                      Sort sortWithinGroup,
                                                                      int maxDocsPerGroup,
                                                                      boolean getScores,
                                                                      boolean getMaxScores,
                                                                      boolean fillSortFields) throws IOException {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermSecondPassGroupingCollector(groupField, searchGroups, groupSort, sortWithinGroup, maxDocsPerGroup , getScores, getMaxScores, fillSortFields);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    List<SearchGroup<MutableValue>> mvalSearchGroups = new ArrayList<>(searchGroups.size());
    for (SearchGroup<BytesRef> mergedTopGroup : searchGroups) {
      SearchGroup<MutableValue> sg = new SearchGroup<>();
      MutableValueStr groupValue = new MutableValueStr();
      if (mergedTopGroup.groupValue != null) {
        groupValue.value.copyBytes(mergedTopGroup.groupValue);
      } else {
        groupValue.exists = false;
      }
      sg.groupValue = groupValue;
      sg.sortValues = mergedTopGroup.sortValues;
      mvalSearchGroups.add(sg);
    }

    return new FunctionSecondPassGroupingCollector(mvalSearchGroups, groupSort, sortWithinGroup, maxDocsPerGroup, getScores, getMaxScores, fillSortFields, vs, new HashMap<>());
  }
}
项目:search    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<>());
  }
}
项目: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 TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
  return firstPass;
}
项目:search    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目: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    文件:TestGrouping.java   
@SuppressWarnings("unchecked")
private AbstractSecondPassGroupingCollector<?> createSecondPassCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                                      String groupField,
                                                                      Collection<SearchGroup<BytesRef>> searchGroups,
                                                                      Sort groupSort,
                                                                      Sort sortWithinGroup,
                                                                      int maxDocsPerGroup,
                                                                      boolean getScores,
                                                                      boolean getMaxScores,
                                                                      boolean fillSortFields) throws IOException {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermSecondPassGroupingCollector(groupField, searchGroups, groupSort, sortWithinGroup, maxDocsPerGroup , getScores, getMaxScores, fillSortFields);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    List<SearchGroup<MutableValue>> mvalSearchGroups = new ArrayList<SearchGroup<MutableValue>>(searchGroups.size());
    for (SearchGroup<BytesRef> mergedTopGroup : searchGroups) {
      SearchGroup<MutableValue> sg = new SearchGroup<MutableValue>();
      MutableValueStr groupValue = new MutableValueStr();
      if (mergedTopGroup.groupValue != null) {
        groupValue.value =  mergedTopGroup.groupValue;
      } else {
        groupValue.value = new BytesRef();
        groupValue.exists = false;
      }
      sg.groupValue = groupValue;
      sg.sortValues = mergedTopGroup.sortValues;
      mvalSearchGroups.add(sg);
    }

    return new FunctionSecondPassGroupingCollector(mvalSearchGroups, groupSort, sortWithinGroup, maxDocsPerGroup, getScores, getMaxScores, fillSortFields, vs, new HashMap<Object, Object>());
  }
}
项目:NYBC    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<Object, Object>());
  }
}
项目: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 TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
  return firstPass;
}
项目:NYBC    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目: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 TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
  return firstPass;
}
项目:search-core    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目: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 TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
  return firstPass;
}
项目:read-open-source-code    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目: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 TermFirstPassGroupingCollector(groupBy, sort, actualGroupsToFind);
  return firstPass;
}
项目:read-open-source-code    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目: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    文件:TestGrouping.java   
@SuppressWarnings("unchecked")
private AbstractSecondPassGroupingCollector<?> createSecondPassCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                                      String groupField,
                                                                      Collection<SearchGroup<BytesRef>> searchGroups,
                                                                      Sort groupSort,
                                                                      Sort sortWithinGroup,
                                                                      int maxDocsPerGroup,
                                                                      boolean getScores,
                                                                      boolean getMaxScores,
                                                                      boolean fillSortFields) throws IOException {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermSecondPassGroupingCollector(groupField, searchGroups, groupSort, sortWithinGroup, maxDocsPerGroup , getScores, getMaxScores, fillSortFields);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    List<SearchGroup<MutableValue>> mvalSearchGroups = new ArrayList<SearchGroup<MutableValue>>(searchGroups.size());
    for (SearchGroup<BytesRef> mergedTopGroup : searchGroups) {
      SearchGroup<MutableValue> sg = new SearchGroup<MutableValue>();
      MutableValueStr groupValue = new MutableValueStr();
      if (mergedTopGroup.groupValue != null) {
        groupValue.value =  mergedTopGroup.groupValue;
      } else {
        groupValue.value = new BytesRef();
        groupValue.exists = false;
      }
      sg.groupValue = groupValue;
      sg.sortValues = mergedTopGroup.sortValues;
      mvalSearchGroups.add(sg);
    }

    return new FunctionSecondPassGroupingCollector(mvalSearchGroups, groupSort, sortWithinGroup, maxDocsPerGroup, getScores, getMaxScores, fillSortFields, vs, new HashMap<Object, Object>());
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<Object, Object>());
  }
}