Author: srowen
Date: Sun Apr 7 11:33:31 2013
New Revision: 1465367
URL: http://svn.apache.org/r1465367
Log:
Update versions of Maven plugins and dependencies; use primes code in Commons
Math instead of old custom code
Modified:
mahout/trunk/math/src/main/java/org/apache/mahout/common/RandomUtils.java
mahout/trunk/math/src/test/java/org/apache/mahout/common/RandomUtilsTest.java
mahout/trunk/pom.xml
Modified:
mahout/trunk/math/src/main/java/org/apache/mahout/common/RandomUtils.java
URL:
http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/common/RandomUtils.java?rev=1465367&r1=1465366&r2=1465367&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/common/RandomUtils.java
(original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/common/RandomUtils.java
Sun Apr 7 11:33:31 2013
@@ -23,16 +23,13 @@ import java.util.Random;
import java.util.WeakHashMap;
import com.google.common.primitives.Longs;
+import org.apache.commons.math3.primes.Primes;
/**
* <p>
* The source of random stuff for the whole project. This lets us make all
randomness in the project
* predictable, if desired, for when we run unit tests, which should be
repeatable.
* </p>
- *
- * <p>
- * This class is increasingly incorrectly named as it also includes other
mathematical utility methods.
- * </p>
*/
public final class RandomUtils {
@@ -93,43 +90,11 @@ public final class RandomUtils {
if (n <= 3) {
return 5;
}
- int next = nextPrime(n);
- while (isNotPrime(next + 2)) {
- next = nextPrime(next + 4);
+ int next = Primes.nextPrime(n);
+ while (!Primes.isPrime(next + 2)) {
+ next = Primes.nextPrime(next + 4);
}
return next + 2;
}
- /**
- * <p>
- * Finds smallest prime p such that p is greater than or equal to n.
- * </p>
- */
- public static int nextPrime(int n) {
- if (n <= 2) {
- return 2;
- }
- // Make sure the number is odd. Is this too clever?
- n |= 0x1;
- // There is no problem with overflow since Integer.MAX_INT is prime, as it
happens
- while (isNotPrime(n)) {
- n += 2;
- }
- return n;
- }
-
- /** @return {@code true} iff n is not a prime */
- public static boolean isNotPrime(int n) {
- if (n < 2 || (n & 0x1) == 0) { // < 2 or even
- return n != 2;
- }
- int max = 1 + (int) Math.sqrt(n);
- for (int d = 3; d <= max; d += 2) {
- if (n % d == 0) {
- return true;
- }
- }
- return false;
- }
-
}
Modified:
mahout/trunk/math/src/test/java/org/apache/mahout/common/RandomUtilsTest.java
URL:
http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/common/RandomUtilsTest.java?rev=1465367&r1=1465366&r2=1465367&view=diff
==============================================================================
---
mahout/trunk/math/src/test/java/org/apache/mahout/common/RandomUtilsTest.java
(original)
+++
mahout/trunk/math/src/test/java/org/apache/mahout/common/RandomUtilsTest.java
Sun Apr 7 11:33:31 2013
@@ -44,32 +44,6 @@ public final class RandomUtilsTest exten
}
@Test
- public void testIsNotPrime() {
- assertTrue(RandomUtils.isNotPrime(Integer.MIN_VALUE));
- assertTrue(RandomUtils.isNotPrime(-1));
- assertTrue(RandomUtils.isNotPrime(0));
- assertTrue(RandomUtils.isNotPrime(1));
- assertTrue(!RandomUtils.isNotPrime(2));
- assertTrue(!RandomUtils.isNotPrime(3));
- assertTrue(RandomUtils.isNotPrime(4));
- assertTrue(!RandomUtils.isNotPrime(5));
- assertTrue(RandomUtils.isNotPrime(Integer.MAX_VALUE - 1));
- assertTrue(!RandomUtils.isNotPrime(Integer.MAX_VALUE)); // 2^31 - 1
- }
-
- @Test
- public void testNextPrime() {
- assertEquals(2, RandomUtils.nextPrime(-1));
- assertEquals(2, RandomUtils.nextPrime(1));
- assertEquals(2, RandomUtils.nextPrime(2));
- assertEquals(3, RandomUtils.nextPrime(3));
- assertEquals(5, RandomUtils.nextPrime(4));
- assertEquals(5, RandomUtils.nextPrime(5));
- assertEquals(7, RandomUtils.nextPrime(6));
- assertEquals(Integer.MAX_VALUE, RandomUtils.nextPrime(Integer.MAX_VALUE -
1));
- }
-
- @Test
public void testNextTwinPrime() {
assertEquals(5, RandomUtils.nextTwinPrime(-1));
assertEquals(5, RandomUtils.nextTwinPrime(1));
Modified: mahout/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/mahout/trunk/pom.xml?rev=1465367&r1=1465366&r2=1465367&view=diff
==============================================================================
--- mahout/trunk/pom.xml (original)
+++ mahout/trunk/pom.xml Sun Apr 7 11:33:31 2013
@@ -97,7 +97,7 @@
<skipTests>false</skipTests>
<maven.clover.multiproject>true</maven.clover.multiproject>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <hadoop.version>1.1.1</hadoop.version>
+ <hadoop.version>1.1.2</hadoop.version>
<lucene.version>4.2.0</lucene.version>
</properties>
<issueManagement>
@@ -334,12 +334,12 @@
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
- <version>1.9.11</version>
+ <version>1.9.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.11</version>
+ <version>1.9.12</version>
</dependency>
<dependency>
@@ -357,12 +357,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.2</version>
+ <version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
- <version>1.7.2</version>
+ <version>1.7.5</version>
<scope>test</scope>
</dependency>
@@ -381,7 +381,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
- <version>3.1.1</version>
+ <version>3.2</version>
</dependency>
<dependency>
@@ -393,7 +393,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>13.0.1</version>
+ <version>14.0.1</version>
</dependency>
<dependency>
@@ -425,7 +425,7 @@
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- <versionRange>2.5.1</versionRange>
+ <versionRange>2.7</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
@@ -481,7 +481,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
- <version>2.3</version>
+ <version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -491,7 +491,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- <version>2.6</version>
+ <version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -546,7 +546,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
- <version>2.4</version>
+ <version>2.4.1</version>
<configuration>
<useReleaseProfile>true</useReleaseProfile>
<releaseProfiles>release,mahout_release</releaseProfiles>
@@ -570,7 +570,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.9.1</version>
+ <version>2.10</version>
<dependencies>
<dependency>
<groupId>org.apache.mahout</groupId>
@@ -601,7 +601,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>2.7.1</version>
+ <version>3.0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.mahout</groupId>
@@ -635,7 +635,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.13</version>
+ <version>2.14</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -660,7 +660,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
+ <version>1.8</version>
</plugin>
</plugins>
</pluginManagement>
@@ -691,7 +691,7 @@
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
- <version>3.1.7</version>
+ <version>3.1.10.1</version>
</plugin>
</plugins>
<resources>
@@ -804,12 +804,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.9.1</version>
+ <version>2.10</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>2.7.1</version>
+ <version>3.0.1</version>
</plugin>
</plugins>
</build>
@@ -860,13 +860,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.13</version>
+ <version>2.14</version>
</plugin>
<!-- checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.9.1</version>
+ <version>2.10</version>
<configuration>
<configLocation>${project.build.directory}/../../buildtools/src/main/resources/mahout-checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
@@ -876,7 +876,7 @@
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
- <version>3.1.7</version>
+ <version>3.1.10.1</version>
<configuration>
<generateHistorical>true</generateHistorical>
<licenseLocation>buildtools/clover.license</licenseLocation>
@@ -895,7 +895,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>2.7.1</version>
+ <version>3.0.1</version>
<configuration>
<rulesets>
<ruleset>../buildtools/src/main/resources/mahout-pmd-ruleset.xml</ruleset>
@@ -940,7 +940,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
- <version>2.8</version>
+ <version>2.9</version>
<configuration>
<onlyCurrentVersion>true</onlyCurrentVersion>
<columnNames>Type,Key,Summary,Status,Resolution,Assignee</columnNames>
@@ -957,7 +957,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.13</version>
+ <version>2.14</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -967,7 +967,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.5.1</version>
+ <version>2.6</version>
<reportSets>
<reportSet>
<reports>
@@ -982,7 +982,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>2.7.1</version>
+ <version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>