mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r1296412 - in /mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth: PFPGrowth.java TransactionTree.java convertors/TransactionIterator.java fpgrowth2/FPGrowthIds.java fpgrowth2/FPGrowthObj.java fpgrowth2/FPTree.java
Date Fri, 02 Mar 2012 19:46:18 GMT
Author: tcp
Date: Fri Mar  2 19:46:17 2012
New Revision: 1296412

URL: http://svn.apache.org/viewvc?rev=1296412&view=rev
Log:
a few more cleanups to make Jenkins happier

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowth.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/TransactionTree.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/convertors/TransactionIterator.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthIds.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthObj.java
    mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPTree.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowth.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowth.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowth.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/PFPGrowth.java Fri Mar
 2 19:46:17 2012
@@ -179,11 +179,11 @@ public final class PFPGrowth {
     return fList;
   }
 
-  public static final int getGroup(int itemId, int maxPerGroup) {
+  public static int getGroup(int itemId, int maxPerGroup) {
     return itemId / maxPerGroup;
   }
 
-  public static final IntArrayList getGroupMembers(int groupId, 
+  public static IntArrayList getGroupMembers(int groupId, 
                                                    int maxPerGroup, 
                                                    int numFeatures) {
     IntArrayList ret = new IntArrayList();

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/TransactionTree.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/TransactionTree.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/TransactionTree.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/TransactionTree.java Fri
Mar  2 19:46:17 2012
@@ -195,7 +195,6 @@ public final class TransactionTree imple
   public TransactionTree getCompressedTree() {
     TransactionTree ctree = new TransactionTree();
     Iterator<Pair<IntArrayList,Long>> it = iterator();
-    final Map<Integer,MutableLong> fList = generateFList();
     int node = 0;
     int size = 0;
     List<Pair<IntArrayList,Long>> compressedTransactionSet = Lists.newArrayList();

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/convertors/TransactionIterator.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/convertors/TransactionIterator.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/convertors/TransactionIterator.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/convertors/TransactionIterator.java
Fri Mar  2 19:46:17 2012
@@ -43,6 +43,9 @@ public class TransactionIterator<T> exte
           @Override
           public Pair<int[],Long> apply(Pair<List<T>,Long> from) {
             int index = 0;
+	    if (from == null) {
+	      return null;
+	    }
             for (T attribute : from.getFirst()) {
               if (attributeIdMapping.containsKey(attribute)) {
                 transactionBuffer[index++] = attributeIdMapping.get(attribute);

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthIds.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthIds.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthIds.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthIds.java
Fri Mar  2 19:46:17 2012
@@ -19,18 +19,13 @@ package org.apache.mahout.fpm.pfpgrowth.
 
 import java.io.IOException;
 import java.util.AbstractMap;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 
 import org.apache.commons.lang.mutable.MutableLong;
 import org.apache.hadoop.conf.Configuration;
@@ -39,14 +34,11 @@ import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.mahout.common.Pair;
 import org.apache.mahout.common.iterator.sequencefile.SequenceFileIterable;
-import org.apache.mahout.fpm.pfpgrowth.CountDescendingPairComparator;
 import org.apache.mahout.fpm.pfpgrowth.convertors.StatusUpdater;
 import org.apache.mahout.fpm.pfpgrowth.convertors.TopKPatternsOutputConverter;
-import org.apache.mahout.fpm.pfpgrowth.convertors.TransactionIterator;
 import org.apache.mahout.fpm.pfpgrowth.convertors.string.TopKStringPatterns;
 import org.apache.mahout.math.list.LongArrayList;
 import org.apache.mahout.math.list.IntArrayList;
-import org.apache.mahout.math.map.OpenIntIntHashMap;
 import org.apache.mahout.math.set.OpenIntHashSet;
 
 import org.slf4j.Logger;
@@ -110,7 +102,6 @@ public class FPGrowthIds {
 
     log.info("Number of unique items {}", attributeFrequency.size());
 
-    OpenIntHashSet returnFeatures = new OpenIntHashSet();
     if (returnableFeatures == null || returnableFeatures.isEmpty()) {
       returnableFeatures = new IntArrayList();
       for (int j = 0; j < attributeFrequency.size(); j++) {
@@ -120,7 +111,7 @@ public class FPGrowthIds {
 
     log.info("Number of unique pruned items {}", attributeFrequency.size());
     generateTopKFrequentPatterns(transactionStream, attributeFrequency,
-        minSupport, k, attributeFrequency.size(), returnableFeatures,
+        minSupport, k, returnableFeatures,
         new TopKPatternsOutputConverter<Integer>(output, new IdentityMapping()), updater);
   }
 
@@ -206,7 +197,6 @@ public class FPGrowthIds {
     LongArrayList attributeFrequency,
     long minSupport,
     int k,
-    int featureSetSize,
     IntArrayList returnFeatures, 
     TopKPatternsOutputConverter<Integer> topKPatternsOutputCollector,
     StatusUpdater updater) throws IOException {
@@ -271,8 +261,7 @@ public class FPGrowthIds {
     }
 
     if (prefixPats != null) {
-      FrequentPatternMaxHeap toRet = cross(prefixPats, suffixPats, k);
-      return toRet;
+      return cross(prefixPats, suffixPats, k);
     }
 
     return suffixPats;

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthObj.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthObj.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthObj.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPGrowthObj.java
Fri Mar  2 19:46:17 2012
@@ -18,7 +18,6 @@
 package org.apache.mahout.fpm.pfpgrowth.fpgrowth2;
 
 import java.io.IOException;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -42,7 +41,6 @@ import org.apache.mahout.fpm.pfpgrowth.c
 import org.apache.mahout.fpm.pfpgrowth.convertors.TopKPatternsOutputConverter;
 import org.apache.mahout.fpm.pfpgrowth.convertors.TransactionIterator;
 import org.apache.mahout.fpm.pfpgrowth.convertors.string.TopKStringPatterns;
-import org.apache.mahout.math.map.OpenIntIntHashMap;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -176,8 +174,8 @@ public class FPGrowthObj<A extends Compa
 
     log.info("Number of unique pruned items {}", attributeIdMapping.size());
     generateTopKFrequentPatterns(new TransactionIterator<A>(transactionStream,
-        attributeIdMapping), attributeFrequency, minSupport, k, reverseMapping
-        .size(), returnFeatures, new TopKPatternsOutputConverter<A>(output,
+        attributeIdMapping), attributeFrequency, minSupport, k, 
+        returnFeatures, new TopKPatternsOutputConverter<A>(output,
             reverseMapping), updater);
   }
 
@@ -250,7 +248,7 @@ public class FPGrowthObj<A extends Compa
     long[] attributeFrequency,
     long minSupport,
     int k,
-    int featureSetSize,
+    //int featureSetSize,
     Collection<Integer> returnFeatures, TopKPatternsOutputConverter<A> topKPatternsOutputCollector,
     StatusUpdater updater) throws IOException {
 
@@ -317,8 +315,7 @@ public class FPGrowthObj<A extends Compa
     }
 
     if (prefixPats != null) {
-      FrequentPatternMaxHeap toRet = cross(prefixPats, suffixPats, k);
-      return toRet;
+      return cross(prefixPats, suffixPats, k);
     }
 
     return suffixPats;

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPTree.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPTree.java?rev=1296412&r1=1296411&r2=1296412&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPTree.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/fpm/pfpgrowth/fpgrowth2/FPTree.java
Fri Mar  2 19:46:17 2012
@@ -113,8 +113,8 @@ public class FPTree {
     this.attrCountList = new LongArrayList();
     for (int i = 0; i < attrCounts.length; i++) 
       if (attrCounts[i] > 0) {
-        if (attrCountList.size() < (i+1)) {
-          attrCountList.setSize(i+1);
+        if (attrCountList.size() < (i + 1)) {
+          attrCountList.setSize(i + 1);
         }
         attrCountList.set(i, attrCounts[i]);
       }
@@ -248,7 +248,7 @@ public class FPTree {
       while (currNode != root) {
         int currAttr = currNode.attribute();
         if (counts.size() <= currAttr) {
-          counts.setSize(currAttr+1);
+          counts.setSize(currAttr + 1);
         }
         long count = counts.get(currAttr);
         counts.set(currNode.attribute(), count + pathCount);
@@ -257,9 +257,9 @@ public class FPTree {
     }
     if (counts.get(targetAttr) != attrCountList.get(targetAttr))
       throw new IllegalStateException("mismatched counts for targetAttr="
-                                      +targetAttr+", ("+counts.get(targetAttr)
-                                      +" != "+attrCountList.get(targetAttr)+"); "
-                                      +"thisTree="+this+"\n");
+                                      + targetAttr + ", (" + counts.get(targetAttr)
+                                      + " != " + attrCountList.get(targetAttr) + "); "
+                                      + "thisTree=" + this + "\n");
     counts.set(targetAttr, 0L);
 
     FPTree toRet = new FPTree(counts, minSupport);
@@ -280,7 +280,7 @@ public class FPTree {
   }
 
   // biggest count or smallest attr number goes first
-  private class AttrComparator implements Comparator<Integer>{
+  private class AttrComparator implements Comparator<Integer> {
     public int compare(Integer a, Integer b) {
 
       long aCnt = 0;
@@ -310,7 +310,7 @@ public class FPTree {
     while (currNode.numChildren() == 1) {
       currNode = currNode.children().iterator().next();
       if (pAttrCountList.size() <= currNode.attribute())
-        pAttrCountList.setSize(currNode.attribute()+1);
+        pAttrCountList.setSize(currNode.attribute() + 1);
       pAttrCountList.set(currNode.attribute(), currNode.count());
       qAttrCountList.set(currNode.attribute(), 0);
     }
@@ -336,13 +336,13 @@ public class FPTree {
       items.add(attribute);
     }
     for (FPNode child : node.children()) {
-      added+= recursivelyAddPrefixPats(pTree, qTree, child, items);
+      added += recursivelyAddPrefixPats(pTree, qTree, child, items);
     }
     if (added < count) {
       long toAdd = count - added;
       pTree.accumulate(items, toAdd);
       qTree.accumulate(items, toAdd);
-      added+= toAdd;
+      added += toAdd;
     }
     if (!(node == root)) {
       int lastIdx = items.size() - 1;



Mime
View raw message