You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/01/05 21:00:29 UTC
[11/50] [abbrv] git commit: Fix flawed addToMutationMap in word count
example. Patch by Dave Brosius,
reviewed by Brandon Williams for CASSANDRA-3669
Fix flawed addToMutationMap in word count example.
Patch by Dave Brosius, reviewed by Brandon Williams for CASSANDRA-3669
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/de333791
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/de333791
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/de333791
Branch: refs/heads/trunk
Commit: de333791e81ae5364e2454af1e2fbf674bacb761
Parents: 190fb8c
Author: Brandon Williams <br...@apache.org>
Authored: Wed Jan 4 10:33:57 2012 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Wed Jan 4 10:33:57 2012 -0600
----------------------------------------------------------------------
examples/hadoop_word_count/src/WordCountSetup.java | 18 ++++++++++----
1 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/de333791/examples/hadoop_word_count/src/WordCountSetup.java
----------------------------------------------------------------------
diff --git a/examples/hadoop_word_count/src/WordCountSetup.java b/examples/hadoop_word_count/src/WordCountSetup.java
index 4e9fddc..7857f02 100644
--- a/examples/hadoop_word_count/src/WordCountSetup.java
+++ b/examples/hadoop_word_count/src/WordCountSetup.java
@@ -106,16 +106,24 @@ public class WordCountSetup
private static void addToMutationMap(Map<ByteBuffer,Map<String,List<Mutation>>> mutationMap, ByteBuffer key, String cf, Column c)
{
- Map<String,List<Mutation>> cfMutation = new HashMap<String,List<Mutation>>();
- List<Mutation> mList = new ArrayList<Mutation>();
+ Map<String, List<Mutation>> cfMutation = mutationMap.get(key);
+ if (cfMutation == null) {
+ cfMutation = new HashMap<String, List<Mutation>>();
+ mutationMap.put(key, cfMutation);
+ }
+
+ List<Mutation> mutationList = cfMutation.get(cf);
+ if (mutationList == null) {
+ mutationList = new ArrayList<Mutation>();
+ cfMutation.put(cf, mutationList);
+ }
+
ColumnOrSuperColumn cc = new ColumnOrSuperColumn();
Mutation m = new Mutation();
cc.setColumn(c);
m.setColumn_or_supercolumn(cc);
- mList.add(m);
- cfMutation.put(cf, mList);
- mutationMap.put(key, cfMutation);
+ mutationList.add(m);
}
private static void setupKeyspace(Cassandra.Iface client) throws TException, InvalidRequestException, SchemaDisagreementException {