You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jo...@apache.org on 2010/02/22 18:22:45 UTC
svn commit: r912669 -
/incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java
Author: johan
Date: Mon Feb 22 17:22:44 2010
New Revision: 912669
URL: http://svn.apache.org/viewvc?rev=912669&view=rev
Log:
Fix bug to allow distributed Hadoop jobs. Patch by johan, review by jbellis. CASSANDRA-817
Modified:
incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java
Modified: incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java?rev=912669&r1=912668&r2=912669&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java (original)
+++ incubator/cassandra/branches/cassandra-0.6/contrib/word_count/src/WordCount.java Mon Feb 22 17:22:44 2010
@@ -32,7 +32,7 @@
static final String KEYSPACE = "Keyspace1";
static final String COLUMN_FAMILY = "Standard1";
- private static String columnName;
+ private static final String CONF_COLUMN_NAME = "columnname";
private static final String OUTPUT_PATH_PREFIX = "/tmp/word_count";
static final int RING_DELAY = 3000; // this is enough for testing a single server node; may need more for a real cluster
@@ -47,6 +47,7 @@
{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
+ private String columnName;
public void map(String key, SortedMap<byte[], IColumn> columns, Context context) throws IOException, InterruptedException
{
@@ -63,6 +64,13 @@
context.write(word, one);
}
}
+
+ protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context)
+ throws IOException, InterruptedException
+ {
+ this.columnName = context.getConfiguration().get(CONF_COLUMN_NAME);
+ }
+
}
public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable>
@@ -88,7 +96,8 @@
for (int i = 0; i < WordCountSetup.TEST_COUNT; i++)
{
- columnName = "text" + i;
+ String columnName = "text" + i;
+ conf.set(CONF_COLUMN_NAME, columnName);
Job job = new Job(conf, "wordcount");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);