Java 类org.apache.lucene.util.mutable.MutableValueStr 实例源码

项目:search    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      int ord = termsIndex.getOrd(doc);
      mval.value.length = 0;
      mval.exists = ord >= 0;
      if (mval.exists) {
        mval.value.copyBytes(termsIndex.lookupOrd(ord));
      }
    }
  };
}
项目:search    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:search    文件:TestGrouping.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value.copyChars(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目: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    文件:TestGrouping.java   
@SuppressWarnings({"unchecked", "rawtypes"})
private TopGroups<BytesRef> getTopGroups(AbstractSecondPassGroupingCollector c, int withinGroupOffset) {
  if (c.getClass().isAssignableFrom(TermSecondPassGroupingCollector.class)) {
    return ((TermSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
  } else if (c.getClass().isAssignableFrom(FunctionSecondPassGroupingCollector.class)) {
    TopGroups<MutableValue> mvalTopGroups = ((FunctionSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
    List<GroupDocs<BytesRef>> groups = new ArrayList<>(mvalTopGroups.groups.length);
    for (GroupDocs<MutableValue> mvalGd : mvalTopGroups.groups) {
      BytesRef groupValue = mvalGd.groupValue.exists() ? ((MutableValueStr) mvalGd.groupValue).value : null;
      groups.add(new GroupDocs<>(Float.NaN, mvalGd.maxScore, mvalGd.totalHits, mvalGd.scoreDocs, groupValue, mvalGd.groupSortValues));
    }
    return new TopGroups<>(mvalTopGroups.groupSort, mvalTopGroups.withinGroupSort, mvalTopGroups.totalHitCount, mvalTopGroups.totalGroupedHitCount, groups.toArray(new GroupDocs[groups.size()]), Float.NaN);
  }
  fail();
  return null;
}
项目:search    文件:GroupingSearchTest.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value.copyChars(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目:NYBC    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      termsIndex.get(doc, mval.value);
      mval.exists = mval.value.bytes != SortedDocValues.MISSING;
    }
  };
}
项目:NYBC    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:NYBC    文件:TestGrouping.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value = new BytesRef(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目: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    文件:TestGrouping.java   
@SuppressWarnings({"unchecked", "rawtypes"})
private TopGroups<BytesRef> getTopGroups(AbstractSecondPassGroupingCollector c, int withinGroupOffset) {
  if (c.getClass().isAssignableFrom(TermSecondPassGroupingCollector.class)) {
    return ((TermSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
  } else if (c.getClass().isAssignableFrom(FunctionSecondPassGroupingCollector.class)) {
    TopGroups<MutableValue> mvalTopGroups = ((FunctionSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
    List<GroupDocs<BytesRef>> groups = new ArrayList<GroupDocs<BytesRef>>(mvalTopGroups.groups.length);
    for (GroupDocs<MutableValue> mvalGd : mvalTopGroups.groups) {
      BytesRef groupValue = mvalGd.groupValue.exists() ? ((MutableValueStr) mvalGd.groupValue).value : null;
      groups.add(new GroupDocs<BytesRef>(Float.NaN, mvalGd.maxScore, mvalGd.totalHits, mvalGd.scoreDocs, groupValue, mvalGd.groupSortValues));
    }
    return new TopGroups<BytesRef>(mvalTopGroups.groupSort, mvalTopGroups.withinGroupSort, mvalTopGroups.totalHitCount, mvalTopGroups.totalGroupedHitCount, groups.toArray(new GroupDocs[groups.size()]), Float.NaN);
  }
  fail();
  return null;
}
项目:NYBC    文件:GroupingSearchTest.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value = new BytesRef(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目:read-open-source-code    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      int ord = termsIndex.getOrd(doc);
      if (ord == -1) {
        mval.value.bytes = BytesRef.EMPTY_BYTES;
        mval.value.offset = 0;
        mval.value.length = 0;
        mval.exists = false;
      } else {
        termsIndex.lookupOrd(ord, mval.value);
        mval.exists = true;
      }
    }
  };
}
项目:read-open-source-code    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:read-open-source-code    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      int ord = termsIndex.getOrd(doc);
      if (ord == -1) {
        mval.value.bytes = BytesRef.EMPTY_BYTES;
        mval.value.offset = 0;
        mval.value.length = 0;
        mval.exists = false;
      } else {
        termsIndex.lookupOrd(ord, mval.value);
        mval.exists = true;
      }
    }
  };
}
项目:read-open-source-code    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:read-open-source-code    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      int ord = termsIndex.getOrd(doc);
      mval.value.length = 0;
      mval.exists = ord >= 0;
      if (mval.exists) {
        mval.value.copyBytes(termsIndex.lookupOrd(ord));
      }
    }
  };
}
项目:read-open-source-code    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:Maskana-Gestor-de-Conocimiento    文件:DocTermsIndexDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      int ord = termsIndex.getOrd(doc);
      if (ord == -1) {
        mval.value.bytes = BytesRef.EMPTY_BYTES;
        mval.value.offset = 0;
        mval.value.length = 0;
        mval.exists = false;
      } else {
        termsIndex.lookupOrd(ord, mval.value);
        mval.exists = true;
      }
    }
  };
}
项目:Maskana-Gestor-de-Conocimiento    文件:StrDocValues.java   
@Override
public ValueFiller getValueFiller() {
  return new ValueFiller() {
    private final MutableValueStr mval = new MutableValueStr();

    @Override
    public MutableValue getValue() {
      return mval;
    }

    @Override
    public void fillValue(int doc) {
      mval.exists = bytesVal(doc, mval.value);
    }
  };
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestGrouping.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value = new BytesRef(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目: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    文件:TestGrouping.java   
@SuppressWarnings({"unchecked", "rawtypes"})
private TopGroups<BytesRef> getTopGroups(AbstractSecondPassGroupingCollector c, int withinGroupOffset) {
  if (c.getClass().isAssignableFrom(TermSecondPassGroupingCollector.class)) {
    return ((TermSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
  } else if (c.getClass().isAssignableFrom(FunctionSecondPassGroupingCollector.class)) {
    TopGroups<MutableValue> mvalTopGroups = ((FunctionSecondPassGroupingCollector) c).getTopGroups(withinGroupOffset);
    List<GroupDocs<BytesRef>> groups = new ArrayList<GroupDocs<BytesRef>>(mvalTopGroups.groups.length);
    for (GroupDocs<MutableValue> mvalGd : mvalTopGroups.groups) {
      BytesRef groupValue = mvalGd.groupValue.exists() ? ((MutableValueStr) mvalGd.groupValue).value : null;
      groups.add(new GroupDocs<BytesRef>(Float.NaN, mvalGd.maxScore, mvalGd.totalHits, mvalGd.scoreDocs, groupValue, mvalGd.groupSortValues));
    }
    return new TopGroups<BytesRef>(mvalTopGroups.groupSort, mvalTopGroups.withinGroupSort, mvalTopGroups.totalHitCount, mvalTopGroups.totalGroupedHitCount, groups.toArray(new GroupDocs[groups.size()]), Float.NaN);
  }
  fail();
  return null;
}
项目:Maskana-Gestor-de-Conocimiento    文件:GroupingSearchTest.java   
private void compareGroupValue(String expected, GroupDocs<?> group) {
  if (expected == null) {
    if (group.groupValue == null) {
      return;
    } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
      return;
    } else if (((BytesRef) group.groupValue).length == 0) {
      return;
    }
    fail();
  }

  if (group.groupValue.getClass().isAssignableFrom(BytesRef.class)) {
    assertEquals(new BytesRef(expected), group.groupValue);
  } else if (group.groupValue.getClass().isAssignableFrom(MutableValueStr.class)) {
    MutableValueStr v = new MutableValueStr();
    v.value = new BytesRef(expected);
    assertEquals(v, group.groupValue);
  } else {
    fail();
  }
}
项目: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    文件:DistinctValuesCollectorTest.java   
private void compare(String expected, Object groupValue) {
  if (BytesRef.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(expected, ((BytesRef) groupValue).utf8ToString());
  } else if (Double.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Double.parseDouble(expected), groupValue);
  } else if (Long.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Long.parseLong(expected), groupValue);
  } else if (MutableValue.class.isAssignableFrom(groupValue.getClass())) {
    MutableValueStr mutableValue = new MutableValueStr();
    mutableValue.value.copyChars(expected);
    assertEquals(mutableValue, groupValue);
  } else {
    fail();
  }
}
项目: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    文件:DistinctValuesCollectorTest.java   
private void compare(String expected, Object groupValue) {
  if (BytesRef.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(expected, ((BytesRef) groupValue).utf8ToString());
  } else if (Double.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Double.parseDouble(expected), groupValue);
  } else if (Long.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Long.parseLong(expected), groupValue);
  } else if (MutableValue.class.isAssignableFrom(groupValue.getClass())) {
    MutableValueStr mutableValue = new MutableValueStr();
    mutableValue.value = new BytesRef(expected);
    assertEquals(mutableValue, groupValue);
  } else {
    fail();
  }
}
项目: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    文件:DistinctValuesCollectorTest.java   
private void compare(String expected, Object groupValue) {
  if (BytesRef.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(expected, ((BytesRef) groupValue).utf8ToString());
  } else if (Double.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Double.parseDouble(expected), groupValue);
  } else if (Long.class.isAssignableFrom(groupValue.getClass())) {
    assertEquals(Long.parseLong(expected), groupValue);
  } else if (MutableValue.class.isAssignableFrom(groupValue.getClass())) {
    MutableValueStr mutableValue = new MutableValueStr();
    mutableValue.value = new BytesRef(expected);
    assertEquals(mutableValue, groupValue);
  } else {
    fail();
  }
}