Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Adds Precondition to TopicModel.update(Matrix)
Browse files Browse the repository at this point in the history
This will catch poorly behaved clients who request less than one thread on TopicModel instantiation, but then attempt to use the multithreaded update method.
  • Loading branch information
sagemintblue committed Apr 13, 2012
1 parent 3624803 commit 4f74872
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.mahout.clustering.lda.cvb;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -329,6 +330,8 @@ public Vector infer(Vector original, Vector docTopicPrior, double minRelPerplexi
}

public void update(Matrix docTopicCounts) {
Preconditions.checkState(updaters.length > 0,
"Unable to update model; No threads requested during TopicModel instantiation");
for(int x = 0; x < numTopics; x++) {
updaters[x % updaters.length].update(x, docTopicCounts.viewRow(x));
}
Expand Down

0 comments on commit 4f74872

Please sign in to comment.