lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject [38/40] lucene-solr:apiv2: LUCENE-7400 - splitter should be able to group using sorted set dv
Date Tue, 02 Aug 2016 01:07:58 GMT
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/apiv2
Commit: 53a34b312e78ce6f56c0bb41304ac834b28b9534
Parents: 9554719
Author: Tommaso Teofili <tommaso@apache.org>
Authored: Sat Jul 30 07:58:02 2016 +0200
Committer: Tommaso Teofili <tommaso@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 {


Mime
View raw message