You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ss...@apache.org on 2015/03/26 11:52:43 UTC
mahout git commit: MAHOUT-1590 Downgraded Guava even further to
11.0.2, since that's the version Hadoop is providing/using;
eliminated some usage of Guava's Closables/Closer since we're now on JDK 1.7
with try-with-resources
Repository: mahout
Updated Branches:
refs/heads/master 47790146a -> c7241d587
MAHOUT-1590 Downgraded Guava even further to 11.0.2, since that's the version Hadoop is providing/using; eliminated some usage of Guava's Closables/Closer since we're now on JDK 1.7 with try-with-resources
Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/c7241d58
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/c7241d58
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/c7241d58
Branch: refs/heads/master
Commit: c7241d5875a933a0b58cab0ceecb8962625040b7
Parents: 4779014
Author: Stevo Slavic <ss...@gmail.com>
Authored: Thu Mar 26 11:36:53 2015 +0100
Committer: Stevo Slavic <ss...@gmail.com>
Committed: Thu Mar 26 11:36:53 2015 +0100
----------------------------------------------------------------------
integration/pom.xml | 7 ++++++-
.../vectors/lucene/LuceneIterableTest.java | 22 ++++++++------------
math/pom.xml | 2 +-
mrlegacy/pom.xml | 9 ++++++--
.../sgd/OnlineLogisticRegressionTest.java | 20 ++++++------------
pom.xml | 2 +-
6 files changed, 30 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/integration/pom.xml
----------------------------------------------------------------------
diff --git a/integration/pom.xml b/integration/pom.xml
index 84317fd..bb7077c 100644
--- a/integration/pom.xml
+++ b/integration/pom.xml
@@ -107,6 +107,11 @@
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-commons-csv</artifactId>
<version>3.5.0</version>
@@ -122,7 +127,7 @@
<artifactId>lucene-analyzers-common</artifactId>
<optional>true</optional>
</dependency>
-
+
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/integration/src/test/java/org/apache/mahout/utils/vectors/lucene/LuceneIterableTest.java
----------------------------------------------------------------------
diff --git a/integration/src/test/java/org/apache/mahout/utils/vectors/lucene/LuceneIterableTest.java b/integration/src/test/java/org/apache/mahout/utils/vectors/lucene/LuceneIterableTest.java
index ddcfeae..1152936 100644
--- a/integration/src/test/java/org/apache/mahout/utils/vectors/lucene/LuceneIterableTest.java
+++ b/integration/src/test/java/org/apache/mahout/utils/vectors/lucene/LuceneIterableTest.java
@@ -22,7 +22,6 @@ import java.util.Iterator;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
-import com.google.common.io.Closeables;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
@@ -118,7 +117,7 @@ public final class LuceneIterableTest extends MahoutTestCase {
LuceneIterable iterable = new LuceneIterable(reader, "id", "content", termInfo,weight);
Iterator<Vector> iterator = iterable.iterator();
- Iterators.advance(iterator, 1);
+ Iterators.skip(iterator, 1);
}
@Test
@@ -131,7 +130,7 @@ public final class LuceneIterableTest extends MahoutTestCase {
Weight weight = new TFIDF();
TermInfo termInfo = new CachedTermInfo(reader, "content", 1, 100);
-
+
boolean exceptionThrown;
//0 percent tolerance
LuceneIterable iterable = new LuceneIterable(reader, "id", "content", termInfo, weight);
@@ -143,7 +142,7 @@ public final class LuceneIterableTest extends MahoutTestCase {
exceptionThrown = true;
}
assertTrue(exceptionThrown);
-
+
//100 percent tolerance
iterable = new LuceneIterable(reader, "id", "content", termInfo,weight, -1, 1.0);
try {
@@ -154,14 +153,14 @@ public final class LuceneIterableTest extends MahoutTestCase {
exceptionThrown = true;
}
assertFalse(exceptionThrown);
-
+
//50 percent tolerance
iterable = new LuceneIterable(reader, "id", "content", termInfo,weight, -1, 0.5);
Iterator<Vector> iterator = iterable.iterator();
- Iterators.advance(iterator, 5);
+ Iterators.skip(iterator, 5);
try {
- Iterators.advance(iterator, Iterators.size(iterator));
+ Iterators.skip(iterator, Iterators.size(iterator));
exceptionThrown = false;
}
catch(IllegalStateException ise) {
@@ -169,17 +168,16 @@ public final class LuceneIterableTest extends MahoutTestCase {
}
assertTrue(exceptionThrown);
}
-
+
static RAMDirectory createTestIndex(FieldType fieldType) throws IOException {
return createTestIndex(fieldType, new RAMDirectory(), 0);
}
-
+
static RAMDirectory createTestIndex(FieldType fieldType,
RAMDirectory directory,
int startingId) throws IOException {
- IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_46,new StandardAnalyzer(Version.LUCENE_46)));
- try {
+ try (IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_46,new StandardAnalyzer(Version.LUCENE_46)))) {
for (int i = 0; i < DOCS.length; i++) {
Document doc = new Document();
Field id = new StringField("id", "doc_" + (i + startingId), Field.Store.YES);
@@ -191,8 +189,6 @@ public final class LuceneIterableTest extends MahoutTestCase {
doc.add(text2);
writer.addDocument(doc);
}
- } finally {
- Closeables.close(writer, false);
}
return directory;
}
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/math/pom.xml
----------------------------------------------------------------------
diff --git a/math/pom.xml b/math/pom.xml
index 099d481..624f843 100644
--- a/math/pom.xml
+++ b/math/pom.xml
@@ -185,6 +185,6 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
-
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/mrlegacy/pom.xml
----------------------------------------------------------------------
diff --git a/mrlegacy/pom.xml b/mrlegacy/pom.xml
index d1d10a7..c65c89e 100644
--- a/mrlegacy/pom.xml
+++ b/mrlegacy/pom.xml
@@ -106,7 +106,7 @@
</build>
<dependencies>
-
+
<!-- our modules -->
<dependency>
<groupId>${project.groupId}</groupId>
@@ -182,6 +182,11 @@
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -227,5 +232,5 @@
</dependency>
</dependencies>
-
+
</project>
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/mrlegacy/src/test/java/org/apache/mahout/classifier/sgd/OnlineLogisticRegressionTest.java
----------------------------------------------------------------------
diff --git a/mrlegacy/src/test/java/org/apache/mahout/classifier/sgd/OnlineLogisticRegressionTest.java b/mrlegacy/src/test/java/org/apache/mahout/classifier/sgd/OnlineLogisticRegressionTest.java
index befc998..44b7525 100644
--- a/mrlegacy/src/test/java/org/apache/mahout/classifier/sgd/OnlineLogisticRegressionTest.java
+++ b/mrlegacy/src/test/java/org/apache/mahout/classifier/sgd/OnlineLogisticRegressionTest.java
@@ -21,7 +21,6 @@ import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.io.Closer;
import com.google.common.io.Resources;
import org.apache.mahout.common.RandomUtils;
import org.apache.mahout.math.DenseVector;
@@ -286,25 +285,18 @@ public final class OnlineLogisticRegressionTest extends OnlineBaseTest {
lr.close();
byte[] output;
- Closer closer = Closer.create();
- try {
- ByteArrayOutputStream byteArrayOutputStream = closer.register(new ByteArrayOutputStream());
- DataOutputStream dataOutputStream = closer.register(new DataOutputStream(byteArrayOutputStream));
+ try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream)) {
PolymorphicWritable.write(dataOutputStream, lr);
output = byteArrayOutputStream.toByteArray();
- } finally {
- closer.close();
}
OnlineLogisticRegression read;
- try {
- ByteArrayInputStream byteArrayInputStream = closer.register(new ByteArrayInputStream(output));
- DataInputStream dataInputStream = closer.register(new DataInputStream(byteArrayInputStream));
- read = closer.register(PolymorphicWritable.read(dataInputStream, OnlineLogisticRegression.class));
- } finally {
- closer.close();
+ try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(output);
+ DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream)) {
+ read = PolymorphicWritable.read(dataInputStream, OnlineLogisticRegression.class);
}
//lambda
@@ -335,4 +327,4 @@ public final class OnlineLogisticRegressionTest extends OnlineBaseTest {
double forgettingExponentVal = (Double) forgettingExponent.get(lr);
Assert.assertEquals(-0.02, forgettingExponentVal, 1.0e-7);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/mahout/blob/c7241d58/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5699b1b..2584c44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -419,7 +419,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>14.0</version>
+ <version>11.0.2</version>
</dependency>
<dependency>