You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2009/10/20 16:04:58 UTC
svn commit: r827468 [2/2] - in /lucene/mahout/trunk: ./ core/
core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/
core/src/main/java/org/apache/mahout/classifier/
core/src/main/java/org/apache/mahout/classifier/bayes/datastore/
core/src/mai...
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/MatrixView.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/MatrixView.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/MatrixView.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/MatrixView.java Tue Oct 20 14:04:55 2009
@@ -158,10 +158,8 @@
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
- int[] o = {in.readInt(), in.readInt()};
- this.offset = o;
- int[] c = {in.readInt(), in.readInt()};
- this.cardinality = c;
+ this.offset = new int[]{in.readInt(), in.readInt()};
+ this.cardinality = new int[]{in.readInt(), in.readInt()};
this.matrix = readMatrix(in);
}
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseMatrix.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseMatrix.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseMatrix.java Tue Oct 20 14:04:55 2009
@@ -190,8 +190,7 @@
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
- int[] card = {in.readInt(), in.readInt()};
- this.cardinality = card;
+ this.cardinality = new int[]{in.readInt(), in.readInt()};
int rowsize = in.readInt();
this.rows = new HashMap<Integer, Vector>();
for (int row = 0; row < rowsize; row++) {
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/JsonModelHolderAdapter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/JsonModelHolderAdapter.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/JsonModelHolderAdapter.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/dirichlet/JsonModelHolderAdapter.java Tue Oct 20 14:04:55 2009
@@ -32,7 +32,6 @@
import java.lang.reflect.Type;
-@SuppressWarnings("unchecked")
public class JsonModelHolderAdapter implements JsonSerializer<ModelHolder<?>>,
JsonDeserializer<ModelHolder<?>> {
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapred/partial/PartitionBugTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapred/partial/PartitionBugTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapred/partial/PartitionBugTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapred/partial/PartitionBugTest.java Tue Oct 20 14:04:55 2009
@@ -138,13 +138,11 @@
@Override
public long maxDepth() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public long nbNodes() {
- // TODO Auto-generated method stub
return 0;
}
@@ -163,7 +161,6 @@
@Override
public Node build(Random rng, Data data) {
- // TODO Auto-generated method stub
return new MockLeaf();
}
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialBuilderTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialBuilderTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialBuilderTest.java Tue Oct 20 14:04:55 2009
@@ -71,11 +71,8 @@
Writer writer = SequenceFile.createWriter(fs, conf, outputFile,
TreeID.class, MapredOutput.class);
- try {
- for (int index = 0; index < numTrees; index++) {
- writer.append(keys[index], values[index]);
- }
- } finally {
+ for (int index = 0; index < numTrees; index++) {
+ writer.append(keys[index], values[index]);
}
writer.close();
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialSequentialBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialSequentialBuilder.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialSequentialBuilder.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartialSequentialBuilder.java Tue Oct 20 14:04:55 2009
@@ -206,9 +206,6 @@
/**
* The second step uses the trees to predict the rest of the instances outside
* their own partition
- *
- * @throws Exception
- *
*/
protected void secondStep(Configuration conf, Path forestPath, PredictionCallback callback)
throws IOException, InterruptedException {
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartitionBugTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartitionBugTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartitionBugTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/df/mapreduce/partial/PartitionBugTest.java Tue Oct 20 14:04:55 2009
@@ -48,9 +48,6 @@
/**
* Make sure that the correct instance ids are being computed
- *
- * @throws Exception
- *
*/
public void testProcessOutput() throws Exception {
Random rng = RandomUtils.getRandom();
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowthTest.java Tue Oct 20 14:04:55 2009
@@ -41,8 +41,9 @@
private static final Logger log = LoggerFactory
.getLogger(PFPGrowthTest.class);
- protected Parameters params = new Parameters();
+ private final Parameters params = new Parameters();
+ @Override
protected void setUp() throws Exception {
super.setUp();
params.set("minSupport", "3");
@@ -61,24 +62,27 @@
}
BufferedWriter writer = new BufferedWriter(new FileWriter(
"testdata/transactions/test.txt"));
- Collection<List<String>> transactions = new ArrayList<List<String>>();
- transactions.add(Arrays.asList("E", "A", "D", "B"));
- transactions.add(Arrays.asList("D", "A", "C", "E", "B"));
- transactions.add(Arrays.asList("C", "A", "B", "E"));
- transactions.add(Arrays.asList("B", "A", "D"));
- transactions.add(Arrays.asList("D"));
- transactions.add(Arrays.asList("D", "B"));
- transactions.add(Arrays.asList("A", "D", "E"));
- transactions.add(Arrays.asList("B", "C"));
- for (List<String> transaction : transactions) {
- String sep = "";
- for (String item : transaction) {
- writer.write(sep + item);
- sep = ",";
+ try {
+ Collection<List<String>> transactions = new ArrayList<List<String>>();
+ transactions.add(Arrays.asList("E", "A", "D", "B"));
+ transactions.add(Arrays.asList("D", "A", "C", "E", "B"));
+ transactions.add(Arrays.asList("C", "A", "B", "E"));
+ transactions.add(Arrays.asList("B", "A", "D"));
+ transactions.add(Arrays.asList("D"));
+ transactions.add(Arrays.asList("D", "B"));
+ transactions.add(Arrays.asList("A", "D", "E"));
+ transactions.add(Arrays.asList("B", "C"));
+ for (List<String> transaction : transactions) {
+ String sep = "";
+ for (String item : transaction) {
+ writer.write(sep + item);
+ sep = ",";
+ }
+ writer.write("\n");
}
- writer.write("\n");
+ } finally {
+ writer.close();
}
- writer.close();
}
Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java Tue Oct 20 14:04:55 2009
@@ -37,7 +37,7 @@
public static double getFitness(Integer key) {
if (!evaluations.containsKey(key)) {
- throw new RuntimeException("Fitness not found");
+ throw new IllegalArgumentException("Fitness not found");
}
return evaluations.get(key);
}
@@ -50,7 +50,7 @@
public double getFitness(DummyCandidate candidate,
List<? extends DummyCandidate> population) {
if (evaluations.containsKey(candidate.getIndex())) {
- throw new RuntimeException("Duplicate Fitness");
+ throw new IllegalArgumentException("Duplicate Fitness");
}
double fitness = rng.nextDouble();
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TestClassifier.java Tue Oct 20 14:04:55 2009
@@ -68,9 +68,7 @@
// do nothing
}
- public static void main(String[] args) throws IOException, OptionException,
- InvalidDatastoreException, ClassNotFoundException,
- InstantiationException, IllegalAccessException {
+ public static void main(String[] args) throws IOException, InvalidDatastoreException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
GroupBuilder gbuilder = new GroupBuilder();
@@ -157,7 +155,7 @@
if (cmdLine.hasOption(helpOpt)) {
CommandLineUtil.printHelp(group);
- System.exit(0);
+ return;
}
int gramSize = 1;
@@ -208,7 +206,7 @@
classifyParallel(params);
} catch (OptionException e) {
CommandLineUtil.printHelp(group);
- System.exit(0);
+ return;
}
}
@@ -224,8 +222,8 @@
}
});
- Algorithm algorithm = null;
- Datastore datastore = null;
+ Algorithm algorithm;
+ Datastore datastore;
if (params.get("dataSource").equals("hdfs")) {
if (params.get("classifierType").equalsIgnoreCase("bayes")) {
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/TrainClassifier.java Tue Oct 20 14:04:55 2009
@@ -63,7 +63,7 @@
driver.runJob(dir, outputDir, params);
}
- public static void main(String[] args) throws IOException, OptionException,
+ public static void main(String[] args) throws IOException,
NumberFormatException, IllegalStateException, InterruptedException,
ClassNotFoundException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
@@ -123,7 +123,7 @@
CommandLine cmdLine = parser.parse(args);
if (cmdLine.hasOption(helpOpt)) {
CommandLineUtil.printHelp(group);
- System.exit(0);
+ return;
}
String classifierType = (String) cmdLine.getValue(typeOpt);
@@ -158,7 +158,7 @@
} catch (OptionException e) {
log.info("{}", e);
CommandLineUtil.printHelp(group);
- System.exit(0);
+ return;
}
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreatorMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreatorMapper.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreatorMapper.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/classifier/bayes/WikipediaDatasetCreatorMapper.java Tue Oct 20 14:04:55 2009
@@ -119,13 +119,13 @@
analyzer = analyzerClass.newInstance();
}
} catch(IOException ex){
- throw new RuntimeException(ex);
+ throw new IllegalStateException(ex);
} catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (InstantiationException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
log.info("Configure: Input Categories size: " + inputCategories.size() + " Exact Match: " + exactMatchOnly +
" Analyzer: " + analyzer.getClass().getName());
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/meanshift/DisplayMeanShift.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/meanshift/DisplayMeanShift.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/meanshift/DisplayMeanShift.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/meanshift/DisplayMeanShift.java Tue Oct 20 14:04:55 2009
@@ -82,9 +82,9 @@
while (!done) {// shift canopies to their centroids
done = true;
List<MeanShiftCanopy> migratedCanopies = new ArrayList<MeanShiftCanopy>();
- List<Vector> centers = new ArrayList<Vector>();
+ //List<Vector> centers = new ArrayList<Vector>();
for (MeanShiftCanopy canopy : canopies) {
- centers.add(canopy.getCenter());
+ //centers.add(canopy.getCenter());
done = canopy.shiftToMean() && done;
MeanShiftCanopy.mergeCanopy(canopy, migratedCanopies);
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java Tue Oct 20 14:04:55 2009
@@ -58,11 +58,11 @@
output.collect(new Text(String.valueOf(index)), result);
} catch (InstantiationException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@@ -73,7 +73,7 @@
try {
constructor = outputClass.getConstructor(int.class);
} catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java Tue Oct 20 14:04:55 2009
@@ -17,8 +17,6 @@
package org.apache.mahout.clustering.syntheticcontrol.meanshift;
-import static org.apache.mahout.clustering.syntheticcontrol.Constants.DIRECTORY_CONTAINING_CONVERTED_INPUT;
-
import java.io.IOException;
import org.apache.commons.cli2.CommandLine;
@@ -36,6 +34,7 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.log4j.Logger;
import org.apache.mahout.clustering.meanshift.MeanShiftCanopyJob;
+import org.apache.mahout.clustering.syntheticcontrol.Constants;
import org.apache.mahout.common.CommandLineUtil;
import org.apache.mahout.common.commandline.DefaultOptionCreator;
@@ -131,7 +130,7 @@
if (dfs.exists(outPath)) {
dfs.delete(outPath, true);
}
- final String directoryContainingConvertedInput = output + DIRECTORY_CONTAINING_CONVERTED_INPUT;
+ final String directoryContainingConvertedInput = output + Constants.DIRECTORY_CONTAINING_CONVERTED_INPUT;
InputDriver.runJob(input, directoryContainingConvertedInput);
MeanShiftCanopyJob.runJob(directoryContainingConvertedInput, output + "/meanshift",
measureClassName, t1, t2, convergenceDelta, maxIterations);
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/BreimanExample.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/BreimanExample.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/BreimanExample.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/BreimanExample.java Tue Oct 20 14:04:55 2009
@@ -45,6 +45,7 @@
import org.slf4j.LoggerFactory;
import org.uncommons.maths.Maths;
+import java.io.IOException;
import java.util.Random;
/**
@@ -80,8 +81,8 @@
*/
protected static void runIteration(Data data, int m, int nbtrees) {
- final int dataSize = data.size();
- final int nblabels = data.getDataset().nblabels();
+ int dataSize = data.size();
+ int nblabels = data.getDataset().nblabels();
Random rng = RandomUtils.getRandom();
@@ -139,12 +140,11 @@
}
public static void main(String[] args) throws Exception {
- int res = ToolRunner.run(new Configuration(), new BreimanExample(), args);
- System.exit(res);
+ ToolRunner.run(new Configuration(), new BreimanExample(), args);
}
@Override
- public int run(String[] args) throws Exception {
+ public int run(String[] args) throws IOException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapred/BuildForest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapred/BuildForest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapred/BuildForest.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapred/BuildForest.java Tue Oct 20 14:04:55 2009
@@ -45,6 +45,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
import java.util.Random;
/**
@@ -70,7 +71,7 @@
boolean isOob; // estimate oob error;
@Override
- public int run(String[] args) throws Exception {
+ public int run(String[] args) throws IOException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
@@ -157,7 +158,7 @@
return 0;
}
- private DecisionForest buildForest() throws Exception {
+ private DecisionForest buildForest() throws IOException {
DefaultTreeBuilder treeBuilder = new DefaultTreeBuilder();
treeBuilder.setM(m);
@@ -218,8 +219,7 @@
* @throws Exception
*/
public static void main(String[] args) throws Exception {
- int res = ToolRunner.run(new Configuration(), new BuildForest(), args);
- System.exit(res);
+ ToolRunner.run(new Configuration(), new BuildForest(), args);
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapreduce/BuildForest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapreduce/BuildForest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapreduce/BuildForest.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/df/mapreduce/BuildForest.java Tue Oct 20 14:04:55 2009
@@ -17,6 +17,7 @@
package org.apache.mahout.df.mapreduce;
+import java.io.IOException;
import java.util.Random;
import org.apache.commons.cli2.CommandLine;
@@ -70,7 +71,7 @@
boolean isOob; // estimate oob error;
@Override
- public int run(String[] args) throws Exception {
+ public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
@@ -172,7 +173,7 @@
return 0;
}
- private DecisionForest buildForest() throws Exception {
+ private DecisionForest buildForest() throws IOException, ClassNotFoundException, InterruptedException {
DefaultTreeBuilder treeBuilder = new DefaultTreeBuilder();
treeBuilder.setM(m);
@@ -216,8 +217,7 @@
return forest;
}
- protected Data loadData(Configuration conf, Path dataPath, Dataset dataset)
- throws Exception {
+ protected Data loadData(Configuration conf, Path dataPath, Dataset dataset) throws IOException {
log.info("Loading the data...");
FileSystem fs = dataPath.getFileSystem(conf);
Data data = DataLoader.loadData(dataset, fs, dataPath);
@@ -231,8 +231,7 @@
* @throws Exception
*/
public static void main(String[] args) throws Exception {
- int res = ToolRunner.run(new Configuration(), new BuildForest(), args);
- System.exit(res);
+ ToolRunner.run(new Configuration(), new BuildForest(), args);
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthJob.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthJob.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthJob.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/fpm/pfpgrowth/FPGrowthJob.java Tue Oct 20 14:04:55 2009
@@ -54,6 +54,9 @@
private static final Logger log = LoggerFactory.getLogger(FPGrowthJob.class);
+ private FPGrowthJob() {
+ }
+
/**
* Run TopK FPGrowth given the input file,
*
@@ -104,7 +107,7 @@
abuilder.withName("numGroups").withMinimum(1).withMaximum(1)
.create())
.withDescription(
- "(Optional) Number of groups the features should be divided in the map-reduce version. Doesnt work in sequential verion Default Value:1000")
+ "(Optional) Number of groups the features should be divided in the map-reduce version. Doesn't work in sequential version Default Value:1000")
.withShortName("g").create();
Option recordSplitterOpt = obuilder
@@ -149,7 +152,7 @@
if (cmdLine.hasOption(helpOpt)) {
CommandLineUtil.printHelp(group);
- System.exit(0);
+ return;
}
Parameters params = new Parameters();
@@ -188,15 +191,14 @@
params.set("input", inputDir);
params.set("output", outputDir);
- String classificationMethod = "sequential";
- classificationMethod = (String) cmdLine.getValue(methodOpt);
+ String classificationMethod = (String) cmdLine.getValue(methodOpt);
if (classificationMethod.equalsIgnoreCase("sequential"))
runFPGrowth(params);
else if (classificationMethod.equalsIgnoreCase("mapreduce"))
PFPGrowth.runPFPGrowth(params);
}
- static void runFPGrowth(Parameters params) throws IOException {
+ private static void runFPGrowth(Parameters params) throws IOException {
log.info("Starting Sequential FPGrowth");
int maxHeapSize = Integer.valueOf(params.get("maxHeapSize", "50"));
int minSupport = Integer.valueOf(params.get("minSupport", "3"));
@@ -229,7 +231,6 @@
List<Pair<String, TopKStringPatterns>> frequentPatterns = FPGrowth
.readFrequentPattern(fs, conf, path);
for (Pair<String, TopKStringPatterns> entry : frequentPatterns)
- log.info("Dumping Patterns for Feature: {} \n{}", entry.getFirst()
- .toString(), entry.getSecond().toString());
+ log.info("Dumping Patterns for Feature: {} \n{}", entry.getFirst(), entry.getSecond().toString());
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitnessEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitnessEvaluator.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitnessEvaluator.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitnessEvaluator.java Tue Oct 20 14:04:55 2009
@@ -64,7 +64,7 @@
try {
CDMahoutEvaluator.evaluate(population, target, dataset, evals, split);
} catch (IOException e) {
- throw new RuntimeException("Exception while evaluating the population", e);
+ throw new IllegalStateException("Exception while evaluating the population", e);
}
for (CDFitness fitness : evals)
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDMutation.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDMutation.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDMutation.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDMutation.java Tue Oct 20 14:04:55 2009
@@ -63,7 +63,6 @@
}
@Override
- @SuppressWarnings("unchecked")
public List<CDRule> apply(List<CDRule> selectedCandidates, Random rng) {
List<CDRule> mutatedPopulation = new ArrayList<CDRule>(selectedCandidates.size());
for (CDRule ind : selectedCandidates) {
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java Tue Oct 20 14:04:55 2009
@@ -61,7 +61,7 @@
return index;
}
- throw new RuntimeException("Value (" + value + ") not found");
+ throw new IllegalArgumentException("Value (" + value + ") not found");
}
}
@@ -110,7 +110,7 @@
*/
public static DataSet getDataSet() {
if (dataset == null)
- throw new RuntimeException("DataSet not initialized");
+ throw new IllegalStateException("DataSet not initialized");
return dataset;
}
@@ -152,7 +152,7 @@
*/
public double getMax(int index) {
if (!isNumerical(index))
- throw new RuntimeException("Nominal Attribute");
+ throw new IllegalArgumentException("Nominal Attribute");
return ((NumericalAttr) attributes.get(index)).getMax();
}
@@ -165,7 +165,7 @@
*/
public double getMin(int index) {
if (!isNumerical(index))
- throw new RuntimeException("Nominal Attribute");
+ throw new IllegalArgumentException("Nominal Attribute");
return ((NumericalAttr) attributes.get(index)).getMin();
}
@@ -178,7 +178,7 @@
*/
public int getNbValues(int index) {
if (isNumerical(index))
- throw new RuntimeException("Numerical Attribute");
+ throw new IllegalArgumentException("Numerical Attribute");
return ((NominalAttr) attributes.get(index)).getNbvalues();
}
@@ -203,7 +203,7 @@
*/
public int valueIndex(int index, String value) {
if (isNumerical(index))
- throw new RuntimeException("Numerical Attribute");
+ throw new IllegalArgumentException("Numerical Attribute");
return ((NominalAttr) attributes.get(index)).valueIndex(value);
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java Tue Oct 20 14:04:55 2009
@@ -92,7 +92,7 @@
} else if (NUMERICAL_TOKEN.equals(token)) {
attributes.add(parseNumerical(tokenizer));
} else {
- throw new RuntimeException("Unknown token (" + token
+ throw new IllegalArgumentException("Unknown token (" + token
+ ") encountered while parsing the info file");
}
}
@@ -100,7 +100,7 @@
reader.close();
if (labelIndex == -1)
- throw new RuntimeException("Info file does not contain a LABEL");
+ throw new IllegalStateException("Info file does not contain a LABEL");
return new DataSet(attributes, ignored, labelIndex);
@@ -117,14 +117,14 @@
throws IOException {
assert inpath != null : "null inpath parameter";
if (!fs.exists(inpath))
- throw new RuntimeException("Input path does not exist");
+ throw new IllegalArgumentException("Input path does not exist");
if (!fs.getFileStatus(inpath).isDir())
- throw new RuntimeException("Input path should be a directory");
+ throw new IllegalArgumentException("Input path should be a directory");
// info file name
Path infoPath = new Path(inpath.getParent(), inpath.getName() + ".infos");
if (!fs.exists(infoPath))
- throw new RuntimeException("Info file does not exist");
+ throw new IllegalArgumentException("Info file does not exist");
return infoPath;
}
@@ -165,7 +165,7 @@
try {
value = Double.parseDouble(token);
} catch (NumberFormatException e) {
- throw new RuntimeException("Exception while parsing info file", e);
+ throw new IllegalArgumentException("Exception while parsing info file", e);
}
return value;
@@ -176,7 +176,7 @@
try {
token = tokenizer.nextToken();
} catch (NoSuchElementException e) {
- throw new RuntimeException("Exception while parsing info file", e);
+ throw new IllegalArgumentException("Exception while parsing info file", e);
}
return token;
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java Tue Oct 20 14:04:55 2009
@@ -70,7 +70,7 @@
// check the input
if (!fs.exists(inpath) || !fs.getFileStatus(inpath).isDir())
- throw new RuntimeException("Input path not found or is not a directory");
+ throw new IllegalArgumentException("Input path not found or is not a directory");
Path outpath = OutputUtils.prepareOutput(fs);
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java Tue Oct 20 14:04:55 2009
@@ -54,17 +54,17 @@
public void configure(JobConf job) {
String rstr = job.get(CLASSDISCOVERY_RULES);
if (rstr == null)
- throw new RuntimeException("Job Parameter (" + CLASSDISCOVERY_RULES
+ throw new IllegalArgumentException("Job Parameter (" + CLASSDISCOVERY_RULES
+ ") not found!");
String datastr = job.get(CLASSDISCOVERY_DATASET);
if (datastr == null)
- throw new RuntimeException("Job Parameter (" + CLASSDISCOVERY_DATASET
+ throw new IllegalArgumentException("Job Parameter (" + CLASSDISCOVERY_DATASET
+ ") not found!");
int target = job.getInt(CLASSDISCOVERY_TARGET_LABEL, -1);
if (target == -1)
- throw new RuntimeException("Job Parameter ("
+ throw new IllegalArgumentException("Job Parameter ("
+ CLASSDISCOVERY_TARGET_LABEL + ") not found!");
initializeDataSet((DataSet) StringUtils.fromString(datastr));
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java Tue Oct 20 14:04:55 2009
@@ -96,7 +96,7 @@
static byte[] getSeed(JobConf conf) {
String seedstr = conf.get(SEED);
if (seedstr == null)
- throw new RuntimeException("SEED job parameter not found");
+ throw new IllegalArgumentException("SEED job parameter not found");
return (byte[]) StringUtils.fromString(seedstr);
}
@@ -104,14 +104,14 @@
static double getThreshold(JobConf conf) {
String thrstr = conf.get(THRESHOLD);
if (thrstr == null)
- throw new RuntimeException("THRESHOLD job parameter not found");
+ throw new IllegalArgumentException("THRESHOLD job parameter not found");
return Double.parseDouble(thrstr);
}
static boolean isTraining(JobConf conf) {
if (conf.get(TRAINING) == null)
- throw new RuntimeException("TRAINING job parameter not found");
+ throw new IllegalArgumentException("TRAINING job parameter not found");
return conf.getBoolean(TRAINING, true);
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosTool.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosTool.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosTool.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/CDInfosTool.java Tue Oct 20 14:04:55 2009
@@ -82,7 +82,7 @@
// check the input
if (!fs.exists(inpath) || !fs.getFileStatus(inpath).isDir())
- throw new RuntimeException("Input path not found or is not a directory");
+ throw new IllegalArgumentException("Input path not found or is not a directory");
Path outpath = OutputUtils.prepareOutput(fs);
@@ -173,7 +173,7 @@
}
if (descriptors.isEmpty()) {
- throw new RuntimeException("Infos file is empty");
+ throw new IllegalArgumentException("Infos file is empty");
}
char[] desc = new char[descriptors.size()];
@@ -231,7 +231,7 @@
Parser parser = new Parser();
parser.setGroup(group);
- CommandLine cmdLine = null;
+ CommandLine cmdLine;
try {
cmdLine = parser.parse(args);
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java Tue Oct 20 14:04:55 2009
@@ -41,7 +41,7 @@
// check that all the descriptors are correct ('I', 'N' 'L' or 'C')
for (int index = 0; index < descriptors.length; index++) {
if (!isIgnored(index) && !isNumerical(index) && !isNominal(index))
- throw new RuntimeException("Bad descriptor value : "
+ throw new IllegalArgumentException("Bad descriptor value : "
+ descriptors[index]);
}
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolCombiner.java Tue Oct 20 14:04:55 2009
@@ -61,7 +61,7 @@
void configure(char[] descriptors) {
if (descriptors == null || descriptors.length == 0)
- throw new RuntimeException("Descriptors's array not found or is empty");
+ throw new IllegalArgumentException("Descriptors's array not found or is empty");
this.descriptors = new Descriptors(descriptors);
}
@@ -88,7 +88,7 @@
else if (descriptors.isNumerical(index))
return numericalDescription(values);
else
- throw new RuntimeException(
+ throw new IllegalArgumentException(
"An ignored attribute should never reach the Combiner");
}
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolMapper.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolMapper.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolMapper.java Tue Oct 20 14:04:55 2009
@@ -68,7 +68,7 @@
void configure(char[] descriptors) {
if (descriptors == null || descriptors.length == 0)
- throw new RuntimeException("Descriptors's array not found or is empty");
+ throw new IllegalArgumentException("Descriptors's array not found or is empty");
this.descriptors = new Descriptors(descriptors);
}
@@ -79,7 +79,7 @@
throws IOException {
extractAttributes(value, attributes);
if (attributes.size() != descriptors.size())
- throw new RuntimeException(
+ throw new IllegalArgumentException(
"Attributes number should be equal to the descriptors's array length");
// output non ignored attributes
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolReducer.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolReducer.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/ToolReducer.java Tue Oct 20 14:04:55 2009
@@ -62,7 +62,7 @@
void configure(char[] descriptors) {
if (descriptors == null || descriptors.length == 0)
- throw new RuntimeException("Descriptors's array not found or is empty");
+ throw new IllegalArgumentException("Descriptors's array not found or is empty");
this.descriptors = new Descriptors(descriptors);
}
@@ -88,7 +88,7 @@
else if (descriptors.isNominal(index))
return nominalDescription(values);
else
- throw new RuntimeException("");
+ throw new IllegalArgumentException();
}
static String numericDescription(Iterator<Text> values) {
Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/StrategyPanel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/StrategyPanel.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/StrategyPanel.java (original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/StrategyPanel.java Tue Oct 20 14:04:55 2009
@@ -163,8 +163,8 @@
SelectionStrategy<?>[] selectionStrategies = {
new RankSelection(), new RouletteWheelSelection(),
- new StochasticUniversalSampling(), new TournamentSelection(new Probability(0.95d)),
- new TruncationSelection(0.5d)};
+ new StochasticUniversalSampling(), new TournamentSelection(new Probability(0.95)),
+ new TruncationSelection(0.5)};
selectionCombo = new JComboBox(selectionStrategies);
selectionCombo.setRenderer(new DefaultListCellRenderer() {
@@ -209,7 +209,6 @@
super.setEnabled(b);
}
- @SuppressWarnings("unchecked")
public TravellingSalesmanStrategy getStrategy() {
return new EvolutionaryTravellingSalesman(distances,
(SelectionStrategy<? super List<String>>) selectionCombo
Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDMutationTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDMutationTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDMutationTest.java (original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDMutationTest.java Tue Oct 20 14:04:55 2009
@@ -17,6 +17,7 @@
package org.apache.mahout.ga.watchmaker.cd;
+import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.mahout.ga.watchmaker.cd.utils.MockDataSet;
import org.apache.mahout.common.RandomUtils;
@@ -83,7 +84,7 @@
}
private static void assertInRange(double value, double min, double max) {
- TestCase.assertTrue("value < min", value >= min);
- TestCase.assertTrue("value > max", value <= max);
+ Assert.assertTrue("value < min", value >= min);
+ Assert.assertTrue("value > max", value <= max);
}
}
Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDRuleTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDRuleTest.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDRuleTest.java (original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/CDRuleTest.java Tue Oct 20 14:04:55 2009
@@ -120,7 +120,7 @@
// the dataline has all its attributes set to 1d
DataLine dl = EasyMock.createMock(DataLine.class);
- EasyMock.expect(dl.getAttribut(EasyMock.anyInt())).andReturn(1.0d).atLeastOnce();
+ EasyMock.expect(dl.getAttribut(EasyMock.anyInt())).andReturn(1.0).atLeastOnce();
EasyMock.replay(dl);
int n = 100; // repeat the test n times
@@ -156,7 +156,7 @@
// the dataline has all its attributes set to 1d
DataLine dl = EasyMock.createMock(DataLine.class);
- EasyMock.expect(dl.getAttribut(EasyMock.anyInt())).andReturn(1.0d).atLeastOnce();
+ EasyMock.expect(dl.getAttribut(EasyMock.anyInt())).andReturn(1.0).atLeastOnce();
EasyMock.replay(dl);
int n = 100; // repeat the test n times
Modified: lucene/mahout/trunk/pom.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/pom.xml?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/pom.xml (original)
+++ lucene/mahout/trunk/pom.xml Tue Oct 20 14:04:55 2009
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -15,6 +16,14 @@
<name>Apache Lucene Mahout</name>
<description>Scalable machine learning libraries</description>
+ <url>http://lucene.apache.org/mahout</url>
+ <inceptionYear>2008</inceptionYear>
+ <licenses>
+ <license>
+ <name>Apache 2</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
<modules>
<module>maven</module>
@@ -30,7 +39,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
- <configuration>
+ <configuration>
<resourceBundles>
<resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
</resourceBundles>
@@ -38,7 +47,7 @@
<supplementalModel>supplemental-models.xml</supplementalModel>
</supplementalModels>
</configuration>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
@@ -46,73 +55,77 @@
<downloadJavadocs>true</downloadJavadocs>
<downloadSources>true</downloadSources>
<additionalConfig>
- <file>
- <name>.checkstyle</name>
- <location>maven/src/main/resources/mahout-eclipse-checkstyle</location>
- </file>
+ <file>
+ <name>.checkstyle</name>
+ <location>maven/src/main/resources/mahout-eclipse-checkstyle</location>
+ </file>
</additionalConfig>
</configuration>
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>project</descriptorRef>
- </descriptorRefs>
-
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id> <!-- this is used for inheritance merges -->
- <phase>package</phase> <!-- append to the packaging phase. -->
- <goals>
- <goal>single</goal> <!-- goals == mojos -->
- </goals>
- </execution>
- </executions>
- </plugin>
- <!--<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-doap-plugin</artifactId>
- <version>1.0</version>
- <configuration>
- <about>Apache Mahout is a machine learning library written in Java and designed to scale by using Apache Hadoop and other high performance techniques.</about>
- <doapOptions>
- <programmingLanguage>java</programmingLanguage>
- <category>library</category>
-
- </doapOptions>
-
- <asfExtOptions>
- <included>true</included>
- <charter>Apache Mahout is a machine learning library written in Java and designed to scale by using Apache Hadoop and other high performance techniques.</charter>
- <pmc>http://lucene.apache.org</pmc>
- </asfExtOptions>
-
- </configuration>
- <executions>
- <execution>
- <id>gen</id>
- <phase>package</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>-->
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <!-- this is used for inheritance merges -->
+ <phase>package</phase>
+ <!-- append to the packaging phase. -->
+ <goals>
+ <goal>single</goal>
+ <!-- goals == mojos -->
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!--<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-doap-plugin</artifactId>
+ <version>1.0</version>
+ <configuration>
+ <about>Apache Mahout is a machine learning library written in Java and designed to scale by using Apache Hadoop and other high performance techniques.</about>
+ <doapOptions>
+ <programmingLanguage>java</programmingLanguage>
+ <category>library</category>
+
+ </doapOptions>
+
+ <asfExtOptions>
+ <included>true</included>
+ <charter>Apache Mahout is a machine learning library written in Java and designed to scale by using Apache Hadoop and other high performance techniques.</charter>
+ <pmc>http://lucene.apache.org</pmc>
+ </asfExtOptions>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>gen</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>-->
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
- </plugins>
- </build>
- </profile>
-</profiles>
<scm>
<connection>scm:svn:https://svn.apache.org/repos/asf/lucene/mahout/tags/mahout-0.1</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/lucene/mahout/tags/mahout-0.1</developerConnection>
Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterable.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterable.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterable.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterable.java Tue Oct 20 14:04:55 2009
@@ -49,9 +49,9 @@
try {
return new SeqFileIterator();
} catch (IllegalAccessException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (InstantiationException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@@ -60,26 +60,28 @@
private final Writable value;
private SeqFileIterator() throws IllegalAccessException, InstantiationException {
- if (transpose == false){
+ if (transpose) {
+ value = (Writable) reader.getValueClass().newInstance();
key = (Writable) reader.getKeyClass().newInstance();
- value = (Vector) reader.getValueClass().newInstance();
} else {
- value = (Vector) reader.getValueClass().newInstance();
key = (Writable) reader.getKeyClass().newInstance();
+ value = (Writable) reader.getValueClass().newInstance();
}
}
@Override
public boolean hasNext() {
+ // TODO this doesn't work with the Iterator contract -- hasNext() cannot have a side effect
try {
return reader.next(key, value);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@Override
public Vector next() {
+
return transpose ? (Vector)key : (Vector)value;
}
Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java Tue Oct 20 14:04:55 2009
@@ -176,8 +176,7 @@
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
SequenceFile.Writer seqWriter = SequenceFile.createWriter(fs, conf, path, LongWritable.class, SparseVector.class);
- VectorWriter sfWriter = new SequenceFileVectorWriter(seqWriter);
- return sfWriter;
+ return new SequenceFileVectorWriter(seqWriter);
}
Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/MapBackedARFFModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/MapBackedARFFModel.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/MapBackedARFFModel.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/MapBackedARFFModel.java Tue Oct 20 14:04:55 2009
@@ -115,10 +115,10 @@
if (ord != null) {
result = ord;
} else {
- throw new RuntimeException("Invalid nominal: " + data + " for label: " + label);
+ throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label);
}
} else {
- throw new RuntimeException("Invalid nominal label: " + label + " Data: " + data);
+ throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data);
}
return result;
@@ -159,7 +159,7 @@
}
result = date.getTime();// hmmm, what kind of loss casting long to double?
} catch (ParseException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
return result;
}
Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterable.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterable.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterable.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/LuceneIterable.java Tue Oct 20 14:04:55 2009
@@ -74,7 +74,7 @@
try {
return new TDIterator();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@@ -88,10 +88,11 @@
@Override
public boolean hasNext() {
+ // TODO this doesn't work with the Iterator contract -- hasNext() cannot have a side effect
try {
return termDocs.next();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@@ -114,7 +115,7 @@
}
} catch (IOException e) {
//Log?
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
return result;
Modified: lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/RandomVectorIterable.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/RandomVectorIterable.java?rev=827468&r1=827467&r2=827468&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/RandomVectorIterable.java (original)
+++ lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/RandomVectorIterable.java Tue Oct 20 14:04:55 2009
@@ -24,6 +24,7 @@
import org.apache.mahout.common.RandomUtils;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import java.util.Random;
public class RandomVectorIterable implements Iterable<Vector>{
@@ -51,8 +52,8 @@
}
private class VectIterator implements Iterator<Vector>{
- int count = 0;
- final Random random = RandomUtils.getRandom();
+ private int count = 0;
+ private final Random random = RandomUtils.getRandom();
@Override
public boolean hasNext() {
return count < numItems;
@@ -60,6 +61,9 @@
@Override
public Vector next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
Vector result = type == VectorType.SPARSE ? new SparseVector(numItems) : new DenseVector(numItems);
result.assign(new UnaryFunction(){
@Override