Skip to content
Browse files

Added parameter for maximum iterations

  • Loading branch information...
1 parent 5f46403 commit 329b362c4cccd4d5842925e18eef4ddbb19c3188 @eljefe6a committed Dec 29, 2012
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/BoggleDriver.java
View
21 src/BoggleDriver.java
@@ -1,7 +1,6 @@
import java.io.IOException;
import java.util.ArrayList;
-import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
@@ -43,6 +42,12 @@
/** The parameter name for the roll version */
public static final String ROLL_VERSION = "rollversion";
+ /** The parameter name for the minimum word size to output */
+ public static final String MAX_ITERATIONS_PARAM = "maxiterations";
+
+ /** The default value for the minimum word size to output */
+ public static final int MAX_ITERATIONS_DEFAULT = 9;
+
@Override
public int run(String[] args) throws Exception {
if (args.length != 4) {
@@ -110,6 +115,8 @@ private int traverseGraph(String input, Configuration configuration, FileSystem
throws IOException, InterruptedException, ClassNotFoundException {
int iteration = 0;
+ int maxiterations = configuration.getInt(MAX_ITERATIONS_PARAM, MAX_ITERATIONS_DEFAULT);
+
writeRollFile(input, fileSystem, configuration, roll, iteration);
long previousWordCount = 0;
@@ -126,10 +133,9 @@ private int traverseGraph(String input, Configuration configuration, FileSystem
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
-
- FileOutputFormat.setOutputCompressorClass(job, SnappyCodec.class);
- SequenceFileOutputFormat.setOutputCompressionType(job,
- CompressionType.BLOCK);
+
+ FileOutputFormat.setOutputCompressorClass(job, SnappyCodec.class);
+ SequenceFileOutputFormat.setOutputCompressionType(job, CompressionType.BLOCK);
job.setNumReduceTasks(0);
@@ -151,7 +157,8 @@ private int traverseGraph(String input, Configuration configuration, FileSystem
logger.info("Traversed graph for " + iteration + " iterations. Found " + currentWordCount
+ " potential words. Bloom saved " + bloomSavings + " so far.");
- if (currentWordCount == previousWordCount || iteration == (roll.rollSize * roll.rollSize)) {
+ if (currentWordCount == previousWordCount
+ || iteration == (roll.rollSize * roll.rollSize) || iteration == maxiterations) {
logger.info("Finished traversing graph after " + iteration + " iterations. Found " + currentWordCount
+ " potential words. Bloom saved " + bloomSavings + ".");
break;
@@ -242,7 +249,7 @@ private void writeRollFile(String input, FileSystem fileSystem, Configuration co
// By creating a file per starting character, that can cause
// one character's file to get very little use if it's a z or x or y.
// You could work around this by rebalancing every so often.
-
+
// Mimic the adjacency matrix written by the mapper to start things off
SequenceFile.Writer writer = null;

0 comments on commit 329b362

Please sign in to comment.
Something went wrong with that request. Please try again.