Author: srowen
Date: Fri Apr 18 17:49:44 2008
New Revision: 649734
URL: http://svn.apache.org/viewvc?rev=649734&view=rev
Log:
MAHOUT-25 changes -- miscellaneous tweaks
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/Canopy.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyClusteringJob.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyCombiner.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyDriver.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyMapper.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyReducer.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterDriver.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterMapper.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/Cluster.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansDriver.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansMapper.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopy.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCombiner.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyJob.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyMapper.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyReducer.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/AbstractMatrix.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/MatrixView.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseColumnMatrix.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseMatrix.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseRowMatrix.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/VectorView.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/Point.java
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/Canopy.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/Canopy.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/Canopy.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/Canopy.java
Fri Apr 18 17:49:44 2008
@@ -103,7 +103,7 @@
public static void configure(JobConf job) {
try {
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
- Class cl = ccl.loadClass(job.get(DISTANCE_MEASURE_KEY));
+ Class<?> cl = ccl.loadClass(job.get(DISTANCE_MEASURE_KEY));
measure = (DistanceMeasure) cl.newInstance();
measure.configure(job);
} catch (Exception e) {
@@ -145,7 +145,7 @@
double dist = measure.distance(canopy.getCenter(), point);
if (dist < t1)
canopy.addPoint(point);
- pointStronglyBound = pointStronglyBound | (dist < t2);
+ pointStronglyBound = pointStronglyBound || (dist < t2);
}
if (!pointStronglyBound)
canopies.add(new Canopy(point));
@@ -167,7 +167,7 @@
double dist = measure.distance(canopy.getCenter(), point);
if (dist < t1)
canopy.emitPoint(point, collector);
- pointStronglyBound = pointStronglyBound | (dist < t2);
+ pointStronglyBound = pointStronglyBound || (dist < t2);
}
if (!pointStronglyBound) {
Canopy canopy = new Canopy(point);
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyClusteringJob.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyClusteringJob.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyClusteringJob.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyClusteringJob.java
Fri Apr 18 17:49:44 2008
@@ -20,6 +20,9 @@
public class CanopyClusteringJob {
+ private CanopyClusteringJob() {
+ }
+
/**
* @param args
*/
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyCombiner.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyCombiner.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyCombiner.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyCombiner.java
Fri Apr 18 17:49:44 2008
@@ -33,11 +33,11 @@
public void reduce(Text key, Iterator<Text> values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
- Writable value = (Writable) values.next();
+ Writable value = values.next();
Vector center = Point.decodePoint(value.toString());
Canopy canopy = new Canopy(center);
while (values.hasNext()) {
- value = (Writable) values.next();
+ value = values.next();
Vector point = Point.decodePoint(value.toString());
canopy.addPoint(point);
}
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyDriver.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyDriver.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyDriver.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyDriver.java
Fri Apr 18 17:49:44 2008
@@ -25,6 +25,9 @@
public class CanopyDriver {
+ private CanopyDriver() {
+ }
+
public static void main(String[] args) {
String input = args[0];
String output = args[1];
@@ -49,8 +52,8 @@
JobConf conf = new JobConf(
org.apache.mahout.clustering.canopy.CanopyDriver.class);
conf.set(Canopy.DISTANCE_MEASURE_KEY, measureClassName);
- conf.set(Canopy.T1_KEY, "" + t1);
- conf.set(Canopy.T2_KEY, "" + t2);
+ conf.set(Canopy.T1_KEY, String.valueOf(t1));
+ conf.set(Canopy.T2_KEY, String.valueOf(t2));
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(Text.class);
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyMapper.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyMapper.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyMapper.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyMapper.java
Fri Apr 18 17:49:44 2008
@@ -33,7 +33,7 @@
public class CanopyMapper extends MapReduceBase implements
Mapper<WritableComparable, Text, Text, Text> {
- List<Canopy> canopies = new ArrayList<Canopy>();
+ private List<Canopy> canopies = new ArrayList<Canopy>();
/*
* (non-Javadoc)
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyReducer.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyReducer.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyReducer.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/CanopyReducer.java
Fri Apr 18 17:49:44 2008
@@ -33,7 +33,7 @@
public class CanopyReducer extends MapReduceBase implements
Reducer<Text, Text, Text, Text> {
- List<Canopy> canopies = new ArrayList<Canopy>();
+ private List<Canopy> canopies = new ArrayList<Canopy>();
/*
* (non-Javadoc)
@@ -45,7 +45,7 @@
public void reduce(Text key, Iterator<Text> values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
while (values.hasNext()) {
- Text value = (Text) values.next();
+ Text value = values.next();
Vector point = Point.decodePoint(value.toString());
Canopy.addPointToCanopies(point, canopies);
}
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterDriver.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterDriver.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterDriver.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterDriver.java
Fri Apr 18 17:49:44 2008
@@ -25,6 +25,9 @@
public class ClusterDriver {
+ private ClusterDriver() {
+ }
+
public static void main(String[] args) {
String points = args[0];
String canopies = args[1];
@@ -52,8 +55,8 @@
org.apache.mahout.clustering.canopy.ClusterDriver.class);
conf.set(Canopy.DISTANCE_MEASURE_KEY, measureClassName);
- conf.set(Canopy.T1_KEY, "" + t1);
- conf.set(Canopy.T2_KEY, "" + t2);
+ conf.set(Canopy.T1_KEY, String.valueOf(t1));
+ conf.set(Canopy.T2_KEY, String.valueOf(t2));
conf.set(Canopy.CANOPY_PATH_KEY, canopies);
conf.setOutputKeyClass(Text.class);
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterMapper.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterMapper.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterMapper.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/canopy/ClusterMapper.java
Fri Apr 18 17:49:44 2008
@@ -36,7 +36,7 @@
public class ClusterMapper extends MapReduceBase implements
Mapper<WritableComparable, Text, Text, Text> {
- List<Canopy> canopies;
+ private List<Canopy> canopies;
public void map(WritableComparable key, Text values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/Cluster.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/Cluster.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/Cluster.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/Cluster.java
Fri Apr 18 17:49:44 2008
@@ -98,7 +98,7 @@
public static void configure(JobConf job) {
try {
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
- Class cl = ccl.loadClass(job.get(DISTANCE_MEASURE_KEY));
+ Class<?> cl = ccl.loadClass(job.get(DISTANCE_MEASURE_KEY));
measure = (DistanceMeasure) cl.newInstance();
measure.configure(job);
convergenceDelta = new Double(job.get(CLUSTER_CONVERGENCE_KEY));
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansDriver.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansDriver.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansDriver.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansDriver.java
Fri Apr 18 17:49:44 2008
@@ -28,6 +28,9 @@
public class KMeansDriver {
+ private KMeansDriver() {
+ }
+
public static void main(String[] args) {
String input = args[0];
String clusters = args[1];
@@ -93,7 +96,7 @@
* @param convergenceDelta the convergence delta value
* @return true if the iteration successfully runs
*/
- static boolean runIteration(String input, String clustersIn,
+ private static boolean runIteration(String input, String clustersIn,
String clustersOut, String measureClass, String
convergenceDelta) {
JobClient client = new JobClient();
JobConf conf = new JobConf(KMeansDriver.class);
@@ -134,7 +137,7 @@
* @param measureClass the classname of the DistanceMeasure
* @param convergenceDelta the convergence delta value
*/
- static void runClustering(String input, String clustersIn, String output,
+ private static void runClustering(String input, String clustersIn, String
output,
String measureClass, String convergenceDelta) {
JobClient client = new JobClient();
JobConf conf = new JobConf(KMeansDriver.class);
@@ -169,14 +172,13 @@
* @return true if all Clusters are converged
* @throws IOException if there was an IO error
*/
- static boolean isConverged(String filePath, JobConf conf, FileSystem fs)
+ private static boolean isConverged(String filePath, JobConf conf, FileSystem
fs)
throws IOException {
- boolean converged;
Path outPart = new Path(filePath);
SequenceFile.Reader reader = new SequenceFile.Reader(fs, outPart, conf);
Text key = new Text();
Text value = new Text();
- converged = true;
+ boolean converged = true;
while (reader.next(key, value)) {
Cluster cluster = Cluster.decodeCluster(value.toString());
converged = converged && cluster.isConverged();
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansMapper.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansMapper.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansMapper.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/kmeans/KMeansMapper.java
Fri Apr 18 17:49:44 2008
@@ -36,7 +36,7 @@
public class KMeansMapper extends MapReduceBase implements
Mapper<WritableComparable, Text, Text, Text> {
- List<Cluster> clusters;
+ private List<Cluster> clusters;
public void map(WritableComparable key, Text values,
OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopy.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopy.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopy.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopy.java
Fri Apr 18 17:49:44 2008
@@ -87,7 +87,7 @@
*/
public static void configure(JobConf job) {
try {
- Class cl = Class.forName(job.get(DISTANCE_MEASURE_KEY));
+ Class<?> cl = Class.forName(job.get(DISTANCE_MEASURE_KEY));
measure = (DistanceMeasure) cl.newInstance();
measure.configure(job);
} catch (Exception e) {
@@ -105,7 +105,7 @@
* @param aMeasure
* @param aT1
* @param aT2
- * @param convergenceDelta the convergence criteria
+ * @param aDelta the convergence criteria
*/
public static void config(DistanceMeasure aMeasure, double aT1, double aT2,
double aDelta) {
@@ -226,7 +226,7 @@
/**
* Create a new Canopy with the given canopyId
*
- * @param point a Vector
+ * @param id
*/
public MeanShiftCanopy(String id) {
super();
@@ -328,8 +328,6 @@
/**
* Emit the new canopy to the collector, keyed by the canopy's Id
- *
- * @param point a Vector
*/
void emitCanopy(MeanShiftCanopy canopy,
OutputCollector<Text, WritableComparable> collector) throws IOException {
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCombiner.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCombiner.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCombiner.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyCombiner.java
Fri Apr 18 17:49:44 2008
@@ -47,7 +47,7 @@
MeanShiftCanopy canopy = new MeanShiftCanopy(key.toString());
try {
while (values.hasNext()) {
- Writable value = (Writable) values.next();
+ Writable value = values.next();
String valueStr = value.toString();
if (valueStr.startsWith("new"))
canopy.init(MeanShiftCanopy.decodeCanopy(valueStr.substring(4)));
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyDriver.java
Fri Apr 18 17:49:44 2008
@@ -68,9 +68,9 @@
conf.setInputFormat(SequenceFileInputFormat.class);
conf.setOutputFormat(SequenceFileOutputFormat.class);
conf.set(MeanShiftCanopy.DISTANCE_MEASURE_KEY, measureClassName);
- conf.set(MeanShiftCanopy.CLUSTER_CONVERGENCE_KEY, "" + convergenceDelta);
- conf.set(MeanShiftCanopy.T1_KEY, "" + t1);
- conf.set(MeanShiftCanopy.T2_KEY, "" + t2);
+ conf.set(MeanShiftCanopy.CLUSTER_CONVERGENCE_KEY,
String.valueOf(convergenceDelta));
+ conf.set(MeanShiftCanopy.T1_KEY, String.valueOf(t1));
+ conf.set(MeanShiftCanopy.T2_KEY, String.valueOf(t2));
client.setConf(conf);
try {
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyJob.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyJob.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyJob.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyJob.java
Fri Apr 18 17:49:44 2008
@@ -52,7 +52,6 @@
public static void runJob(String input, String output,
String measureClassName, double t1, double t2, double convergenceDelta,
int maxIterations) {
- int maxIter = new Integer(maxIterations);
try {
// delete the output directory
JobConf conf = new JobConf(MeanShiftCanopyDriver.class);
@@ -67,7 +66,7 @@
boolean inputIsSequenceFile = false;
int iteration = 0;
String clustersIn = input;
- while (!converged && iteration < maxIter) {
+ while (!converged && iteration < maxIterations) {
System.out.println("Iteration " + iteration);
// point the output to a new directory per iteration
String clustersOut = output + "/canopies-" + iteration;
@@ -94,14 +93,13 @@
* @return true if all canopies are converged
* @throws IOException if there was an IO error
*/
- static boolean isConverged(String filePath, JobConf conf, FileSystem fs)
+ private static boolean isConverged(String filePath, JobConf conf, FileSystem
fs)
throws IOException {
- boolean converged;
Path outPart = new Path(filePath);
SequenceFile.Reader reader = new SequenceFile.Reader(fs, outPart, conf);
Text key = new Text();
Text value = new Text();
- converged = true;
+ boolean converged = true;
while (converged && reader.next(key, value))
converged = converged && value.toString().startsWith("V");
return converged;
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyMapper.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyMapper.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyMapper.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyMapper.java
Fri Apr 18 17:49:44 2008
@@ -32,7 +32,7 @@
public class MeanShiftCanopyMapper extends MapReduceBase implements
Mapper<WritableComparable, Text, Text, WritableComparable> {
- List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
+ private List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
/*
* (non-Javadoc)
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyReducer.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyReducer.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyReducer.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/clustering/meanshift/MeanShiftCanopyReducer.java
Fri Apr 18 17:49:44 2008
@@ -33,9 +33,9 @@
public class MeanShiftCanopyReducer extends MapReduceBase implements
Reducer<Text, WritableComparable, Text, WritableComparable> {
- List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
+ private List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
- OutputCollector<Text, WritableComparable> collector;
+ private OutputCollector<Text, WritableComparable> collector;
/*
* (non-Javadoc)
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/AbstractMatrix.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/AbstractMatrix.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/AbstractMatrix.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/AbstractMatrix.java
Fri Apr 18 17:49:44 2008
@@ -204,7 +204,7 @@
* @see org.apache.mahout.matrix.Matrix#determinant()
*/
public double determinant() throws CardinalityException {
- int card[] = cardinality();
+ int[] card = cardinality();
int rowSize = card[ROW];
int columnSize = card[COL];
if(rowSize!=columnSize) throw new CardinalityException();
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/MatrixView.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/MatrixView.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/MatrixView.java
(original)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/MatrixView.java
Fri Apr 18 17:49:44 2008
@@ -34,7 +34,7 @@
/**
* Construct a view of the matrix with given offset and cardinality
- *
+ *
* @param matrix an underlying Matrix
* @param offset the int[2] offset into the underlying matrix
* @param cardinality the int[2] cardinality of the view
@@ -48,7 +48,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#asFormatString()
*/
@Override
@@ -67,7 +67,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#cardinality()
*/
@Override
@@ -77,7 +77,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#copy()
*/
@Override
@@ -87,7 +87,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#getQuick(int, int)
*/
@Override
@@ -97,7 +97,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#like()
*/
@Override
@@ -107,7 +107,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#like(int, int)
*/
@Override
@@ -118,7 +118,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#setQuick(int, int, double)
*/
@Override
@@ -128,7 +128,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#size()
*/
@Override
@@ -138,7 +138,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#toArray()
*/
@Override
@@ -152,7 +152,7 @@
}
@Override
- public Matrix viewPart(int offset[], int[] size) throws CardinalityException,
+ public Matrix viewPart(int[] offset, int[] size) throws CardinalityException,
IndexException {
if (size[ROW] > cardinality[ROW] || size[COL] > cardinality[COL])
throw new CardinalityException();
@@ -162,13 +162,12 @@
int[] origin = offset.clone();
origin[ROW] += offset[ROW];
origin[COL] += offset[COL];
- Matrix result = new MatrixView(matrix, origin, size);
- return result;
+ return new MatrixView(matrix, origin, size);
}
/*
* (non-Javadoc)
- *
+ *
* @see
org.apache.mahout.matrix.AbstractMatrix#haveSharedCells(org.apache.mahout.matrix.Matrix)
*/
@Override
@@ -181,7 +180,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#assignColumn(int,
* org.apache.mahout.vector.Vector)
*/
@@ -198,7 +197,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#assignRow(int,
* org.apache.mahout.vector.Vector)
*/
@@ -214,7 +213,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#getColumn(int)
*/
@Override
@@ -227,7 +226,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.mahout.matrix.AbstractMatrix#getRow(int)
*/
@Override
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseColumnMatrix.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseColumnMatrix.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseColumnMatrix.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseColumnMatrix.java
Fri Apr 18 17:49:44 2008
@@ -25,9 +25,9 @@
*/
public class SparseColumnMatrix extends AbstractMatrix {
- int[] cardinality;
+ private int[] cardinality;
- Vector[] columns;
+ private Vector[] columns;
/**
* Construct a matrix of the given cardinality with the given data columns
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseMatrix.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseMatrix.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseMatrix.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseMatrix.java
Fri Apr 18 17:49:44 2008
@@ -27,7 +27,7 @@
*/
public class SparseMatrix extends AbstractMatrix {
- int[] cardinality;
+ private int[] cardinality;
private Map<Integer, Vector> rows;
@@ -41,7 +41,7 @@
this.cardinality = cardinality.clone();
this.rows = new HashMap<Integer, Vector>();
for (Integer row : rows.keySet())
- this.rows.put(row, (SparseVector) rows.get(row).copy());
+ this.rows.put(row, rows.get(row).copy());
}
/**
@@ -63,7 +63,7 @@
@Override
public WritableComparable asWritableComparable() {
StringBuilder out = new StringBuilder();
- out.append("[s" + cardinality[ROW] + ", ");
+ out.append("[s").append(cardinality[ROW]).append(", ");
for (Integer row : rows.keySet())
out.append(rows.get(row).asWritableComparable());
out.append("] ");
@@ -89,7 +89,7 @@
public Matrix copy() {
SparseMatrix copy = new SparseMatrix(cardinality);
for (Integer row : rows.keySet())
- copy.rows.put(row, (SparseVector) rows.get(row).copy());
+ copy.rows.put(row, rows.get(row).copy());
return copy;
}
@@ -235,7 +235,7 @@
public Matrix assignRow(int row, Vector other) throws CardinalityException {
if (row >= cardinality[ROW] || other.cardinality() != cardinality[COL])
throw new CardinalityException();
- rows.put(new Integer(row), other);
+ rows.put(row, other);
return this;
}
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseRowMatrix.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseRowMatrix.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
---
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseRowMatrix.java
(original)
+++
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/SparseRowMatrix.java
Fri Apr 18 17:49:44 2008
@@ -25,9 +25,9 @@
*/
public class SparseRowMatrix extends AbstractMatrix {
- int[] cardinality;
+ private int[] cardinality;
- Vector[] rows;
+ private Vector[] rows;
/**
* Construct a matrix of the given cardinality with the given rows
Modified:
lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/VectorView.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/VectorView.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/VectorView.java
(original)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/matrix/VectorView.java
Fri Apr 18 17:49:44 2008
@@ -48,7 +48,7 @@
@Override
public WritableComparable asWritableComparable() {
StringBuilder out = new StringBuilder();
- out.append("[");
+ out.append('[');
for (int i = offset; i < offset + cardinality; i++)
out.append(getQuick(i)).append(", ");
out.append("] ");
@@ -105,8 +105,7 @@
throw new CardinalityException();
if (offset < 0 || offset + length > cardinality)
throw new IndexException();
- Vector result = new VectorView(vector, offset + this.offset, length);
- return result;
+ return new VectorView(vector, offset + this.offset, length);
}
@Override
Modified: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/Point.java
URL:
http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/Point.java?rev=649734&r1=649733&r2=649734&view=diff
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/Point.java
(original)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/Point.java Fri
Apr 18 17:49:44 2008
@@ -29,7 +29,7 @@
/**
* Split pattern for [EMAIL PROTECTED] #decodePoint(String)}.
*/
- private final static Pattern splitPattern = Pattern.compile("[,]");
+ private static final Pattern splitPattern = Pattern.compile("[,]");
/**
* Format the point for input to a Mapper or Reducer
@@ -55,13 +55,13 @@
/**
* Decodes a point from its string representation.
*
- * @param formattedString a comma-terminated String of the form
+ * @param formattedString a comma-terminated String of the form
* "[v1,v2,...,vn]payload". Note the payload remainder: it is optional,
* but can be present.
* @return the n-dimensional point
*/
public static Vector decodePoint(String formattedString) {
- final int closingBracketIndex = formattedString.indexOf(']');
+ final int closingBracketIndex = formattedString.indexOf(']');
if (formattedString.charAt(0) != '[' || closingBracketIndex < 0) {
throw new IllegalArgumentException(formattedString);
}
@@ -95,7 +95,7 @@
* @return a point representing [0,0,0,...,0]
*/
public static Vector origin(int length) {
-
+
Vector point = new SparseVector(length);
point.assign(0);