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 2014/08/09 22:09:41 UTC
svn commit: r1617011 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/classification/ lucene/classification/src/
lucene/classification/src/java/org/apache/lucene/classification/utils/
lucene/classification/src/test/org/apache/lucene/classificatio...
Author: tommaso
Date: Sat Aug 9 20:09:40 2014
New Revision: 1617011
URL: http://svn.apache.org/r1617011
Log:
LUCENE-5880 - merged fix for negative array size in DocToDoubleVectorUtils
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/classification/ (props changed)
lucene/dev/branches/branch_4x/lucene/classification/src/ (props changed)
lucene/dev/branches/branch_4x/lucene/classification/src/java/org/apache/lucene/classification/utils/DocToDoubleVectorUtils.java
lucene/dev/branches/branch_4x/lucene/classification/src/test/org/apache/lucene/classification/utils/DocToDoubleVectorUtilsTest.java
Modified: lucene/dev/branches/branch_4x/lucene/classification/src/java/org/apache/lucene/classification/utils/DocToDoubleVectorUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/classification/src/java/org/apache/lucene/classification/utils/DocToDoubleVectorUtils.java?rev=1617011&r1=1617010&r2=1617011&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/classification/src/java/org/apache/lucene/classification/utils/DocToDoubleVectorUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/classification/src/java/org/apache/lucene/classification/utils/DocToDoubleVectorUtils.java Sat Aug 9 20:09:40 2014
@@ -41,7 +41,7 @@ public class DocToDoubleVectorUtils {
public static Double[] toSparseLocalFreqDoubleArray(Terms docTerms, Terms fieldTerms) throws IOException {
TermsEnum fieldTermsEnum = fieldTerms.iterator(null);
Double[] freqVector = null;
- if (docTerms != null) {
+ if (docTerms != null && fieldTerms.size() > -1) {
freqVector = new Double[(int) fieldTerms.size()];
int i = 0;
TermsEnum docTermsEnum = docTerms.iterator(null);
Modified: lucene/dev/branches/branch_4x/lucene/classification/src/test/org/apache/lucene/classification/utils/DocToDoubleVectorUtilsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/classification/src/test/org/apache/lucene/classification/utils/DocToDoubleVectorUtilsTest.java?rev=1617011&r1=1617010&r2=1617011&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/classification/src/test/org/apache/lucene/classification/utils/DocToDoubleVectorUtilsTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/classification/src/test/org/apache/lucene/classification/utils/DocToDoubleVectorUtilsTest.java Sat Aug 9 20:09:40 2014
@@ -94,12 +94,14 @@ public class DocToDoubleVectorUtilsTest
@Test
public void testSparseFreqDoubleArrayConversion() throws Exception {
Terms fieldTerms = MultiFields.getTerms(index, "text");
- IndexSearcher indexSearcher = new IndexSearcher(index);
- for (ScoreDoc scoreDoc : indexSearcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs) {
- Terms docTerms = index.getTermVector(scoreDoc.doc, "text");
- Double[] vector = DocToDoubleVectorUtils.toSparseLocalFreqDoubleArray(docTerms, fieldTerms);
- assertNotNull(vector);
- assertTrue(vector.length > 0);
+ if (fieldTerms != null && fieldTerms.size() != -1) {
+ IndexSearcher indexSearcher = new IndexSearcher(index);
+ for (ScoreDoc scoreDoc : indexSearcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE).scoreDocs) {
+ Terms docTerms = index.getTermVector(scoreDoc.doc, "text");
+ Double[] vector = DocToDoubleVectorUtils.toSparseLocalFreqDoubleArray(docTerms, fieldTerms);
+ assertNotNull(vector);
+ assertTrue(vector.length > 0);
+ }
}
}
}