You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by gs...@apache.org on 2009/06/26 17:42:37 UTC

svn commit: r788745 - /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java

Author: gsingers
Date: Fri Jun 26 15:42:37 2009
New Revision: 788745

URL: http://svn.apache.org/viewvc?rev=788745&view=rev
Log:
we don't care about the key, so don't assume Text

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java?rev=788745&r1=788744&r2=788745&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/kmeans/KMeansUtil.java Fri Jun 26 15:42:37 2009
@@ -27,6 +27,7 @@
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.mahout.clustering.canopy.Canopy;
 import org.slf4j.Logger;
@@ -43,7 +44,7 @@
    * Configure the mapper with the cluster info
    */
   public static void configureWithClusterInfo(String clusterPathStr,
-      List<Cluster> clusters) {    
+      List<Cluster> clusters) {
     
     // Get the path location where the cluster Info is stored
     JobConf job = new JobConf(KMeansUtil.class);
@@ -74,7 +75,16 @@
         try {
           reader =new SequenceFile.Reader(fs, path, job);
           Class valueClass = reader.getValueClass();
-          Text key = new Text();
+          Writable key = null;
+          try {
+            key = (Writable) reader.getKeyClass().newInstance();
+          } catch (InstantiationException e) {//Should not be possible
+            log.error("Exception", e);
+            throw new RuntimeException(e);
+          } catch (IllegalAccessException e) {
+            log.error("Exception", e);
+            throw new RuntimeException(e);
+          }
           if (valueClass.equals(Cluster.class)){
             Cluster value = new Cluster();
             while (reader.next(key, value)) {