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 2013/03/23 12:39:01 UTC
svn commit: r1460130 [2/2] - in /mahout/trunk: ./
core/src/main/java/org/apache/mahout/cf/taste/impl/common/
core/src/main/java/org/apache/mahout/cf/taste/impl/model/
core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/knn/
core/src/main/jav...
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTestVs.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTestVs.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTestVs.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthRetailDataTestVs.java Sat Mar 23 11:38:59 2013
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.mahout.common.MahoutTestCase;
import org.apache.mahout.common.Pair;
@@ -81,7 +82,7 @@ public final class FPGrowthRetailDataTes
public void collect(String key, List<Pair<List<String>,Long>> value) {
for (Pair<List<String>,Long> v : value) {
List<String> l = v.getFirst();
- results.put(new HashSet<String>(l), v.getSecond());
+ results.put(Sets.newHashSet(l), v.getSecond());
log.info("found pat ["+v.getSecond()+"]: "+ v.getFirst());
}
}
@@ -96,7 +97,7 @@ public final class FPGrowthRetailDataTes
public void testVsWithRetailData() throws IOException {
String inputFilename = "retail.dat";
int minSupport = 500;
- Collection<String> returnableFeatures = new HashSet<String>();
+ Collection<String> returnableFeatures = Sets.newHashSet();
org.apache.mahout.fpm.pfpgrowth.fpgrowth.
FPGrowth<String> fp1 = new org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth<String>();
@@ -117,8 +118,8 @@ public final class FPGrowthRetailDataTes
new StringRecordIterator(new FileLineIterable(Resources.getResource(inputFilename).openStream()), "\\s+"),
fp2.generateFList(new StringRecordIterator(new FileLineIterable(Resources.getResource(inputFilename)
- .openStream()), "\\s+"), minSupport), minSupport, 100000,
- new HashSet<String>(),
+ .openStream()), "\\s+"), minSupport), minSupport, 100000,
+ Sets.<String>newHashSet(),
new MapCollector(initialResults2), new DummyUpdater());
Map<Set<String>, Long> results2;
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthSyntheticDataTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthSyntheticDataTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthSyntheticDataTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthSyntheticDataTest.java Sat Mar 23 11:38:59 2013
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.mahout.common.MahoutTestCase;
import org.apache.mahout.common.Pair;
@@ -70,11 +71,11 @@ public final class FPGrowthSyntheticData
final Map<Set<String>,Long> results = Maps.newHashMap();
- Set<String> features_10_13 = new HashSet<String>();
+ Set<String> features_10_13 = Sets.newHashSet();
features_10_13.add("10");
features_10_13.add("13");
- Set<String> returnableFeatures = new HashSet<String>();
+ Set<String> returnableFeatures = Sets.newHashSet();
returnableFeatures.add("10");
returnableFeatures.add("13");
returnableFeatures.add("1669");
@@ -91,7 +92,7 @@ public final class FPGrowthSyntheticData
for (Pair<List<String>,Long> v : value) {
List<String> l = v.getFirst();
- results.put(new HashSet<String>(l), v.getSecond());
+ results.put(Sets.newHashSet(l), v.getSecond());
System.out.println("found pat ["+v.getSecond()+"]: "+ v.getFirst());
}
}
@@ -135,7 +136,7 @@ public final class FPGrowthSyntheticData
@Test
public void testVsWithSynthData() throws IOException {
- Collection<String> returnableFeatures = new HashSet<String>();
+ Collection<String> returnableFeatures = Sets.newHashSet();
// not limiting features (or including too many) can cause
// the test to run a very long time
@@ -161,7 +162,7 @@ public final class FPGrowthSyntheticData
for (Pair<List<String>,Long> v : value) {
List<String> l = v.getFirst();
- results1.put(new HashSet<String>(l), v.getSecond());
+ results1.put(Sets.newHashSet(l), v.getSecond());
System.out.println("found pat ["+v.getSecond()+"]: "+ v.getFirst());
}
}
@@ -177,8 +178,8 @@ public final class FPGrowthSyntheticData
fp2.generateTopKFrequentPatterns(new StringRecordIterator(new FileLineIterable(Resources.getResource(inputFilename).openStream()), "\\s+"),
fp2.generateFList(new StringRecordIterator(new FileLineIterable(Resources.getResource(inputFilename)
- .openStream()), "\\s+"), minSupport), minSupport, 1000000,
- new HashSet<String>(),
+ .openStream()), "\\s+"), minSupport), minSupport, 1000000,
+ Sets.<String>newHashSet(),
new OutputCollector<String,List<Pair<List<String>,Long>>>() {
@Override
@@ -186,7 +187,7 @@ public final class FPGrowthSyntheticData
for (Pair<List<String>,Long> v : value) {
List<String> l = v.getFirst();
- initialResults2.put(new HashSet<String>(l), v.getSecond());
+ initialResults2.put(Sets.newHashSet(l), v.getSecond());
System.out.println("found pat ["+v.getSecond()+"]: "+ v.getFirst());
}
}
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest.java Sat Mar 23 11:38:59 2013
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.List;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -68,7 +69,7 @@ public final class FPGrowthTest extends
fp.generateFList(transactions.iterator(), 3),
3,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
@@ -111,7 +112,7 @@ public final class FPGrowthTest extends
fp.generateFList(transactions.iterator(), 2),
2,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
@@ -149,7 +150,7 @@ public final class FPGrowthTest extends
fp.generateFList(transactions.iterator(), 2),
2,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest2.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest2.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest2.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthTest2.java Sat Mar 23 11:38:59 2013
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.List;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -68,7 +69,7 @@ public final class FPGrowthTest2 extends
fp.generateFList(transactions.iterator(), 3),
3,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
@@ -111,7 +112,7 @@ public final class FPGrowthTest2 extends
fp.generateFList(transactions.iterator(), 2),
2,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
@@ -149,7 +150,7 @@ public final class FPGrowthTest2 extends
fp.generateFList(transactions.iterator(), 2),
2,
100,
- new HashSet<String>(),
+ Sets.<String>newHashSet(),
new StringOutputConverter(new SequenceFileOutputCollector<Text,TopKStringPatterns>(writer)),
new ContextStatusUpdater(null));
} finally {
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest.java Sat Mar 23 11:38:59 2013
@@ -30,6 +30,7 @@ import java.util.Set;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.hadoop.conf.Configuration;
@@ -101,7 +102,7 @@ public class PFPGrowthRetailDataTest ext
List<String> items = Lists.newArrayList(next.getFirst());
String supportString = items.remove(items.size() - 1);
Long support = Long.parseLong(supportString.substring(1, supportString.length() - 1));
- expectedResults.put(new HashSet<String>(items), support);
+ expectedResults.put(Sets.newHashSet(items), support);
}
PFPGrowth.runPFPGrowth(params);
@@ -113,7 +114,7 @@ public class PFPGrowthRetailDataTest ext
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
@@ -154,7 +155,7 @@ public class PFPGrowthRetailDataTest ext
List<String> items = Lists.newArrayList(next.getFirst());
String supportString = items.remove(items.size() - 1);
Long support = Long.parseLong(supportString.substring(1, supportString.length() - 1));
- expectedResults.put(new HashSet<String>(items), support);
+ expectedResults.put(Sets.newHashSet(items), support);
}
Configuration conf = new Configuration();
log.info("Starting Parallel Counting Test: {}", params.get(PFPGrowth.MAX_HEAPSIZE));
@@ -180,7 +181,7 @@ public class PFPGrowthRetailDataTest ext
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest2.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest2.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest2.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTest2.java Sat Mar 23 11:38:59 2013
@@ -30,6 +30,7 @@ import java.util.Set;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.hadoop.conf.Configuration;
@@ -101,7 +102,7 @@ public class PFPGrowthRetailDataTest2 ex
List<String> items = Lists.newArrayList(next.getFirst());
String supportString = items.remove(items.size() - 1);
Long support = Long.parseLong(supportString.substring(1, supportString.length() - 1));
- expectedResults.put(new HashSet<String>(items), support);
+ expectedResults.put(Sets.newHashSet(items), support);
}
PFPGrowth.runPFPGrowth(params);
@@ -113,7 +114,7 @@ public class PFPGrowthRetailDataTest2 ex
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
@@ -153,7 +154,7 @@ public class PFPGrowthRetailDataTest2 ex
List<String> items = Lists.newArrayList(next.getFirst());
String supportString = items.remove(items.size() - 1);
Long support = Long.parseLong(supportString.substring(1, supportString.length() - 1));
- expectedResults.put(new HashSet<String>(items), support);
+ expectedResults.put(Sets.newHashSet(items), support);
}
Configuration conf = new Configuration();
log.info("Starting Parallel Counting Test: {}", params.get(PFPGrowth.MAX_HEAPSIZE));
@@ -181,7 +182,7 @@ public class PFPGrowthRetailDataTest2 ex
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTestVs.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTestVs.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTestVs.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthRetailDataTestVs.java Sat Mar 23 11:38:59 2013
@@ -29,6 +29,7 @@ import java.util.Set;
import com.google.common.collect.Maps;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import org.apache.mahout.common.MahoutTestCase;
import org.apache.mahout.common.Pair;
import org.apache.mahout.common.Parameters;
@@ -113,7 +114,7 @@ public final class PFPGrowthRetailDataTe
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results1.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results1.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
@@ -125,7 +126,7 @@ public final class PFPGrowthRetailDataTe
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- results2.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ results2.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthSynthDataTest2.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthSynthDataTest2.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthSynthDataTest2.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthSynthDataTest2.java Sat Mar 23 11:38:59 2013
@@ -30,6 +30,7 @@ import java.util.Set;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.hadoop.mapred.OutputCollector;
@@ -103,7 +104,7 @@ public class PFPGrowthSynthDataTest2 ext
Iterator<Pair<List<String>,Long>> topKIt = topK.getSecond().iterator();
while (topKIt.hasNext()) {
Pair<List<String>,Long> entry = topKIt.next();
- parallelResult.put(new HashSet<String>(entry.getFirst()), entry.getSecond());
+ parallelResult.put(Sets.newHashSet(entry.getFirst()), entry.getSecond());
}
}
@@ -126,7 +127,7 @@ public class PFPGrowthSynthDataTest2 ext
for (Pair<List<String>,Long> v : value) {
List<String> l = v.getFirst();
- seqResult.put(new HashSet<String>(l), v.getSecond());
+ seqResult.put(Sets.newHashSet(l), v.getSecond());
}
}
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeapTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeapTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeapTest.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth/FrequentPatternMaxHeapTest.java Sat Mar 23 11:38:59 2013
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Random;
+import com.google.common.collect.Sets;
import org.apache.mahout.common.MahoutTestCase;
import org.apache.mahout.common.RandomUtils;
import org.junit.Test;
@@ -48,7 +49,7 @@ public final class FrequentPatternMaxHea
private static Pattern generateRandomPattern(Random gen) {
int length = 1 + Math.abs(gen.nextInt() % 6);
Pattern p = new Pattern();
- Collection<Integer> set = new HashSet<Integer>();
+ Collection<Integer> set = Sets.newHashSet();
for (int i = 0; i < length; i++) {
int id = Math.abs(gen.nextInt() % 20);
while (set.contains(id)) {
Modified: mahout/trunk/core/src/test/java/org/apache/mahout/math/hadoop/similarity/TestVectorDistanceSimilarityJob.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/math/hadoop/similarity/TestVectorDistanceSimilarityJob.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/math/hadoop/similarity/TestVectorDistanceSimilarityJob.java (original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/math/hadoop/similarity/TestVectorDistanceSimilarityJob.java Sat Mar 23 11:38:59 2013
@@ -87,7 +87,7 @@ public class TestVectorDistanceSimilarit
VectorDistanceMapper mapper = new VectorDistanceMapper();
setField(mapper, "measure", new EuclideanDistanceMeasure());
- Collection<NamedVector> seedVectors = new ArrayList<NamedVector>();
+ Collection<NamedVector> seedVectors = Lists.newArrayList();
Vector seed1 = new RandomAccessSparseVector(2);
seed1.set(0, 1);
seed1.set(1, 1);
@@ -117,7 +117,7 @@ public class TestVectorDistanceSimilarit
VectorDistanceInvertedMapper mapper = new VectorDistanceInvertedMapper();
setField(mapper, "measure", new EuclideanDistanceMeasure());
- Collection<NamedVector> seedVectors = new ArrayList<NamedVector>();
+ Collection<NamedVector> seedVectors = Lists.newArrayList();
Vector seed1 = new RandomAccessSparseVector(2);
seed1.set(0, 1);
seed1.set(1, 1);
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/kddcup/track2/Track2Callable.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/kddcup/track2/Track2Callable.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/kddcup/track2/Track2Callable.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/kddcup/track2/Track2Callable.java Sat Mar 23 11:38:59 2013
@@ -26,6 +26,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import org.apache.mahout.cf.taste.common.NoSuchItemException;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.model.PreferenceArray;
@@ -79,7 +80,7 @@ final class Track2Callable implements Ca
} else if (topThree.size() < 3) {
log.warn("Unable to recommend three items for {}", userID);
// Some NaNs - just guess at the rest then
- Collection<Long> newItemIDs = new HashSet<Long>(3);
+ Collection<Long> newItemIDs = Sets.newHashSetWithExpectedSize(3);
newItemIDs.addAll(itemIDs);
int i = 0;
while (i < testSize && newItemIDs.size() < 3) {
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/df/mapreduce/TestForest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/df/mapreduce/TestForest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/df/mapreduce/TestForest.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/df/mapreduce/TestForest.java Sat Mar 23 11:38:59 2013
@@ -25,6 +25,7 @@ import java.util.Random;
import java.util.Scanner;
import java.util.Arrays;
+import com.google.common.collect.Lists;
import com.google.common.io.Closeables;
import org.apache.commons.cli2.CommandLine;
import org.apache.commons.cli2.Group;
@@ -226,7 +227,7 @@ public class TestForest extends Configur
Random rng = RandomUtils.getRandom();
- List<double[]> resList = new ArrayList<double[]>();
+ List<double[]> resList = Lists.newArrayList();
if (dataFS.getFileStatus(dataPath).isDir()) {
//the input is a directory of files
testDirectory(outputPath, converter, forest, dataset, resList, rng);
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticModelParameters.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticModelParameters.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticModelParameters.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/sgd/AdaptiveLogisticModelParameters.java Sat Mar 23 11:38:59 2013
@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import com.google.common.collect.Lists;
import com.google.common.io.Closeables;
import org.apache.mahout.math.stats.GlobalOnlineAuc;
import org.apache.mahout.math.stats.GroupedOnlineAuc;
@@ -155,7 +156,7 @@ public class AdaptiveLogisticModelParame
setNumFeatures(in.readInt());
setMaxTargetCategories(in.readInt());
int targetCategoriesSize = in.readInt();
- List<String> targetCategories = new ArrayList<String>(targetCategoriesSize);
+ List<String> targetCategories = Lists.newArrayListWithCapacity(targetCategoriesSize);
for (int i = 0; i < targetCategoriesSize; i++) {
targetCategories.add(in.readUTF());
}
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMinHash.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMinHash.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMinHash.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/display/DisplayMinHash.java Sat Mar 23 11:38:59 2013
@@ -39,6 +39,7 @@ import java.util.Random;
import javax.swing.Timer;
+import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
@@ -351,7 +352,7 @@ public class DisplayMinHash extends Disp
String key = next.getFirst().toString();
List<Vector> list = clusters.get(key);
if (list == null) {
- list = new ArrayList<Vector>();
+ list = Lists.newArrayList();
clusters.put(key, list);
}
list.add(next.getSecond().get());
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/minhash/LastfmClusterEvaluator.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/minhash/LastfmClusterEvaluator.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/minhash/LastfmClusterEvaluator.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/minhash/LastfmClusterEvaluator.java Sat Mar 23 11:38:59 2013
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.HashSet;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
@@ -49,16 +50,16 @@ public final class LastfmClusterEvaluato
* Computer Jaccard coefficient over two sets. (A intersect B) / (A union B)
*/
private static double computeSimilarity(Iterable<Integer> listenerVector1, Iterable<Integer> listenerVector2) {
- Set<Integer> first = new HashSet<Integer>();
+ Set<Integer> first = Sets.newHashSet();
for (Integer ele : listenerVector1) {
first.add(ele);
}
- Collection<Integer> second = new HashSet<Integer>();
+ Collection<Integer> second = Sets.newHashSet();
for (Integer ele : listenerVector2) {
second.add(ele);
}
- Collection<Integer> intersection = new HashSet<Integer>(first);
+ Collection<Integer> intersection = Sets.newHashSet();
intersection.retainAll(second);
double intersectSize = intersection.size();
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleCombiner.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleCombiner.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleCombiner.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleCombiner.java Sat Mar 23 11:38:59 2013
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
+import com.google.common.collect.Sets;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.mahout.common.StringTuple;
@@ -31,7 +32,7 @@ public class KeyBasedStringTupleCombiner
protected void reduce(Text key,
Iterable<StringTuple> values,
Context context) throws IOException, InterruptedException {
- Set<String> outputValues = new HashSet<String>();
+ Set<String> outputValues = Sets.newHashSet();
for (StringTuple value : values) {
outputValues.addAll(value.getEntries());
}
Modified: mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleReducer.java
URL: http://svn.apache.org/viewvc/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleReducer.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleReducer.java (original)
+++ mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/dataset/KeyBasedStringTupleReducer.java Sat Mar 23 11:38:59 2013
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
+import com.google.common.collect.Sets;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.mahout.common.Parameters;
@@ -33,7 +34,7 @@ public class KeyBasedStringTupleReducer
@Override
protected void reduce(Text key, Iterable<StringTuple> values, Context context)
throws IOException, InterruptedException {
- Collection<String> items = new HashSet<String>();
+ Collection<String> items = Sets.newHashSet();
for (StringTuple value : values) {
for (String field : value.getEntries()) {
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java Sat Mar 23 11:38:59 2013
@@ -144,7 +144,7 @@ public class VectorBenchmarks {
}
int implId = implType.get(implName);
if (!statsMap.containsKey(benchmarkName)) {
- statsMap.put(benchmarkName, new ArrayList<String[]>());
+ statsMap.put(benchmarkName, Lists.<String[]>newArrayList());
}
List<String[]> implStats = statsMap.get(benchmarkName);
while (implStats.size() < implId + 1) {
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/hbase/HBaseDataModel.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/hbase/HBaseDataModel.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/hbase/HBaseDataModel.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/hbase/HBaseDataModel.java Sat Mar 23 11:38:59 2013
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
+import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -344,7 +345,7 @@ public final class HBaseDataModel implem
Result[] results;
try {
HTableInterface table = pool.getTable(tableName);
- List<Get> gets = new ArrayList<Get>(2);
+ List<Get> gets = Lists.newArrayListWithCapacity(2);
gets.add(new Get(itemToBytes(itemID1)));
gets.add(new Get(itemToBytes(itemID2)));
gets.get(0).addFamily(USERS_CF);
@@ -385,7 +386,7 @@ public final class HBaseDataModel implem
public void setPreference(long userID, long itemID, float value) throws TasteException {
try {
HTableInterface table = pool.getTable(tableName);
- List<Put> puts = new ArrayList<Put>(2);
+ List<Put> puts = Lists.newArrayListWithCapacity(2);
puts.add(new Put(userToBytes(userID)));
puts.add(new Put(itemToBytes(itemID)));
puts.get(0).add(ITEMS_CF, Bytes.toBytes(itemID), Bytes.toBytes(value));
@@ -401,7 +402,7 @@ public final class HBaseDataModel implem
public void removePreference(long userID, long itemID) throws TasteException {
try {
HTableInterface table = pool.getTable(tableName);
- List<Delete> deletes = new ArrayList<Delete>(2);
+ List<Delete> deletes = Lists.newArrayListWithCapacity(2);
deletes.add(new Delete(userToBytes(userID)));
deletes.add(new Delete(itemToBytes(itemID)));
deletes.get(0).deleteColumns(ITEMS_CF, Bytes.toBytes(itemID));
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/mongodb/MongoDBDataModel.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/mongodb/MongoDBDataModel.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/mongodb/MongoDBDataModel.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/impl/model/mongodb/MongoDBDataModel.java Sat Mar 23 11:38:59 2013
@@ -554,7 +554,7 @@ public final class MongoDBDataModel impl
DB db = mongoDDBB.getDB(mongoDB);
mongoTimestamp = new Date(0);
FastByIDMap<Collection<Preference>> userIDPrefMap = new FastByIDMap<Collection<Preference>>();
- if (!mongoAuth || (mongoAuth && db.authenticate(mongoUsername, mongoPassword.toCharArray()))) {
+ if (!mongoAuth || db.authenticate(mongoUsername, mongoPassword.toCharArray())) {
collection = db.getCollection(mongoCollection);
collectionMap = db.getCollection(mongoMapCollection);
DBObject indexObj = new BasicDBObject();
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/text/SequenceFilesFromMailArchives.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/text/SequenceFilesFromMailArchives.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/text/SequenceFilesFromMailArchives.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/text/SequenceFilesFromMailArchives.java Sat Mar 23 11:38:59 2013
@@ -16,6 +16,7 @@
*/
package org.apache.mahout.text;
+import com.google.common.collect.Lists;
import com.google.common.io.Closeables;
import org.apache.commons.cli2.builder.ArgumentBuilder;
@@ -207,7 +208,7 @@ public final class SequenceFilesFromMail
options.setChunkSize(chunkSize);
options.setCharset(charset);
- List<Pattern> patterns = new ArrayList<Pattern>(5);
+ List<Pattern> patterns = Lists.newArrayListWithCapacity(5);
// patternOrder is used downstream so that we can know what order the text
// is in instead
// of encoding it in the string, which
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/text/WikipediaToSequenceFile.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/text/WikipediaToSequenceFile.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/text/WikipediaToSequenceFile.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/text/WikipediaToSequenceFile.java Sat Mar 23 11:38:59 2013
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
+import com.google.common.collect.Sets;
import org.apache.commons.cli2.CommandLine;
import org.apache.commons.cli2.Group;
import org.apache.commons.cli2.Option;
@@ -178,7 +179,7 @@ public final class WikipediaToSequenceFi
*/
HadoopUtil.delete(conf, outPath);
- Set<String> categories = new HashSet<String>();
+ Set<String> categories = Sets.newHashSet();;
if (!catFile.isEmpty()) {
for (String line : new FileLineIterable(new File(catFile))) {
categories.add(line.trim().toLowerCase(Locale.ENGLISH));
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorDriver.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorDriver.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorDriver.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorDriver.java Sat Mar 23 11:38:59 2013
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
+import com.google.common.collect.Sets;
import org.apache.commons.cli2.CommandLine;
import org.apache.commons.cli2.Group;
import org.apache.commons.cli2.Option;
@@ -153,7 +154,7 @@ public final class WikipediaDatasetCreat
// Dont ever forget this. People should keep track of how hadoop conf
// parameters can make or break a piece of code
- Set<String> categories = new HashSet<String>();
+ Set<String> categories = Sets.newHashSet();
for (String line : new FileLineIterable(new File(catFile))) {
categories.add(line.trim().toLowerCase(Locale.ENGLISH));
}
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorMapper.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorMapper.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaDatasetCreatorMapper.java Sat Mar 23 11:38:59 2013
@@ -25,6 +25,7 @@ import java.util.Locale;
import java.util.Set;
import java.util.regex.Pattern;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
@@ -89,7 +90,7 @@ public class WikipediaDatasetCreatorMapp
Configuration conf = context.getConfiguration();
if (inputCategories == null) {
- Set<String> newCategories = new HashSet<String>();
+ Set<String> newCategories = Sets.newHashSet();
DefaultStringifier<Set<String>> setStringifier =
new DefaultStringifier<Set<String>>(conf, GenericsUtil.getClass(newCategories));
String categoriesStr = conf.get("wikipedia.categories", setStringifier.toString(newCategories));
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaMapper.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaMapper.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/text/wikipedia/WikipediaMapper.java Sat Mar 23 11:38:59 2013
@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.google.common.collect.Sets;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.DefaultStringifier;
@@ -91,7 +92,7 @@ public class WikipediaMapper extends Map
super.setup(context);
Configuration conf = context.getConfiguration();
if (inputCategories == null) {
- Set<String> newCategories = new HashSet<String>();
+ Set<String> newCategories = Sets.newHashSet();
DefaultStringifier<Set<String>> setStringifier =
new DefaultStringifier<Set<String>>(conf, GenericsUtil.getClass(newCategories));
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java Sat Mar 23 11:38:59 2013
@@ -18,6 +18,7 @@
package org.apache.mahout.utils;
import com.google.common.base.Charsets;
+import com.google.common.collect.Lists;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.hadoop.conf.Configuration;
@@ -137,7 +138,7 @@ public final class SequenceFileDumper ex
}
}
if (facets != null) {
- List<String> keyList = new ArrayList<String>(facets.size());
+ List<String> keyList = Lists.newArrayListWithCapacity(facets.size());
IntArrayList valueList = new IntArrayList(facets.size());
facets.pairsSortedByKey(keyList, valueList);
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/ChainTransformer.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/ChainTransformer.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/ChainTransformer.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/ChainTransformer.java Sat Mar 23 11:38:59 2013
@@ -17,6 +17,8 @@
package org.apache.mahout.utils.regex;
+import com.google.common.collect.Lists;
+
import java.util.ArrayList;
import java.util.List;
@@ -26,7 +28,7 @@ import java.util.List;
*/
public class ChainTransformer implements RegexTransformer {
- private List<RegexTransformer> chain = new ArrayList<RegexTransformer>();
+ private List<RegexTransformer> chain = Lists.newArrayList();
public ChainTransformer() {
}
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/RegexMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/RegexMapper.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/RegexMapper.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/utils/regex/RegexMapper.java Sat Mar 23 11:38:59 2013
@@ -17,6 +17,7 @@
package org.apache.mahout.utils.regex;
+import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
@@ -45,7 +46,7 @@ public class RegexMapper extends Mapper<
@Override
protected void setup(Context context) throws IOException, InterruptedException {
- groupsToKeep = new ArrayList<Integer>();
+ groupsToKeep = Lists.newArrayList();
Configuration config = context.getConfiguration();
String regexStr = config.get(REGEX);
regex = Pattern.compile(regexStr);
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java Sat Mar 23 11:38:59 2013
@@ -18,6 +18,7 @@
package org.apache.mahout.utils.vectors;
import com.google.common.base.Charsets;
+import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.hadoop.conf.Configuration;
@@ -132,7 +133,7 @@ public final class VectorDumper extends
Set<String> filters;
if (hasOption("filter")) {
- filters = new HashSet<String>(getOptions("filter"));
+ filters = Sets.newHashSet(getOptions("filter"));
} else {
filters = null;
}
Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java (original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java Sat Mar 23 11:38:59 2013
@@ -29,6 +29,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import com.google.common.collect.Sets;
import org.apache.lucene.util.BytesRef;
import com.google.common.base.Charsets;
import com.google.common.io.Closeables;
@@ -162,7 +163,7 @@ public class ClusterLabels {
log.info("# of documents in the index {}", reader.numDocs());
- Collection<String> idSet = new HashSet<String>();
+ Collection<String> idSet = Sets.newHashSet();
for (WeightedVectorWritable wvw : wvws) {
Vector vector = wvw.getVector();
if (vector instanceof NamedVector) {
Modified: mahout/trunk/integration/src/test/java/org/apache/mahout/utils/regex/RegexUtilsTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/test/java/org/apache/mahout/utils/regex/RegexUtilsTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/integration/src/test/java/org/apache/mahout/utils/regex/RegexUtilsTest.java (original)
+++ mahout/trunk/integration/src/test/java/org/apache/mahout/utils/regex/RegexUtilsTest.java Sat Mar 23 11:38:59 2013
@@ -17,6 +17,7 @@
package org.apache.mahout.utils.regex;
+import com.google.common.collect.Lists;
import org.apache.mahout.common.MahoutTestCase;
import org.junit.Test;
@@ -53,7 +54,7 @@ public final class RegexUtilsTest extend
assertEquals(res, "import statement 1", res);
pattern = Pattern.compile("(start=1) HTTP");
- Collection<Integer> groupsToKeep = new ArrayList<Integer>();
+ Collection<Integer> groupsToKeep = Lists.newArrayList();
groupsToKeep.add(1);
res = RegexUtils.extract(line, pattern, groupsToKeep, " ", RegexUtils.IDENTITY_TRANSFORMER);
assertEquals(res, "start=1", res);
Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java?rev=1460130&r1=1460129&r2=1460130&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java Sat Mar 23 11:38:59 2013
@@ -17,6 +17,7 @@
package org.apache.mahout.math;
+import com.google.common.collect.Sets;
import org.apache.mahout.math.function.Functions;
import org.junit.Test;
@@ -340,7 +341,7 @@ public final class VectorTest extends Ma
@Test
public void testIterator() {
- Collection<Integer> expectedIndices = new HashSet<Integer>();
+ Collection<Integer> expectedIndices = Sets.newHashSet();
int i = 1;
while (i <= 20) {
expectedIndices.add(i * (i + 1) / 2);
@@ -367,7 +368,7 @@ public final class VectorTest extends Ma
}
private static void doTestIterators(Vector vector, Collection<Integer> expectedIndices) {
- expectedIndices = new HashSet<Integer>(expectedIndices);
+ expectedIndices = Sets.newHashSet(expectedIndices);
Iterator<Vector.Element> allIterator = vector.iterator();
int index = 0;
while (allIterator.hasNext()) {