You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2016/07/30 05:58:35 UTC

lucene-solr:master: LUCENE-7400 - splitter should be able to group using sorted set dv

Repository: lucene-solr
Updated Branches:
  refs/heads/master 9554719f1 -> 53a34b312


LUCENE-7400 - splitter should be able to group using sorted set dv


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/53a34b31
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/53a34b31
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/53a34b31

Branch: refs/heads/master
Commit: 53a34b312e78ce6f56c0bb41304ac834b28b9534
Parents: 9554719
Author: Tommaso Teofili <to...@apache.org>
Authored: Sat Jul 30 07:58:02 2016 +0200
Committer: Tommaso Teofili <to...@apache.org>
Committed: Sat Jul 30 07:58:25 2016 +0200

----------------------------------------------------------------------
 .../lucene/classification/utils/DatasetSplitter.java  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53a34b31/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
----------------------------------------------------------------------
diff --git a/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java b/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
index 374624b..8bb0b1d 100644
--- a/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
+++ b/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
@@ -30,6 +30,7 @@ import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.SortedDocValues;
+import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.ScoreDoc;
@@ -82,11 +83,20 @@ public class DatasetSplitter {
     // get the exact no. of existing classes
     int noOfClasses = 0;
     for (LeafReaderContext leave : originalIndex.leaves()) {
+      long valueCount = 0;
       SortedDocValues classValues = leave.reader().getSortedDocValues(classFieldName);
+      if (classValues != null) {
+        valueCount = classValues.getValueCount();
+      } else {
+        SortedSetDocValues sortedSetDocValues = leave.reader().getSortedSetDocValues(classFieldName);
+        if (sortedSetDocValues != null) {
+          valueCount = sortedSetDocValues.getValueCount();
+        }
+      }
       if (classValues == null) {
-        throw new IllegalStateException("the classFieldName \"" + classFieldName + "\" must index sorted doc values");
+        throw new IllegalStateException("field \"" + classFieldName + "\" must have sorted (set) doc values");
       }
-      noOfClasses += classValues.getValueCount();
+      noOfClasses += valueCount;
     }
 
     try {