Index: modules/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector1.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- modules/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector1.java	(revision )
+++ modules/grouping/src/java/org/apache/lucene/search/grouping/term/TermAllGroupsCollector1.java	(revision )
@@ -0,0 +1,77 @@
+package org.apache.lucene.search.grouping.term;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.grouping.AbstractAllGroupsCollector;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefHash;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @lucene.experimental
+ */
+public class TermAllGroupsCollector1 extends AbstractAllGroupsCollector<BytesRef> {
+
+  private final String groupField;
+  private final BytesRefHash groups;
+
+  private FieldCache.DocTerms index;
+  private final BytesRef spareBytesRef = new BytesRef();
+
+  /**
+   * Constructs a {@link org.apache.lucene.search.grouping.AbstractAllGroupsCollector}.
+   *
+   * @param groupField The field to group by
+   */
+  public TermAllGroupsCollector1(String groupField) {
+    this.groupField = groupField;
+    groups = new BytesRefHash();
+  }
+
+  public void collect(int doc) throws IOException {
+    groups.add(index.getTerm(doc, spareBytesRef));
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Collection<BytesRef> getGroups() {
+    int[] ords = groups.compact();
+    List<BytesRef> result = new ArrayList<BytesRef>(ords.length);
+    for (int ord : ords) {
+      result.add(groups.get(ord, new BytesRef()));
+    }
+    return result;
+  }
+
+  @Override
+  public int getGroupCount() {
+    return groups.size();
+  }
+
+  public void setNextReader(AtomicReaderContext context) throws IOException {
+    index = FieldCache.DEFAULT.getTerms(context.reader(), groupField);
+  }
+
+}
