cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject git commit: Fix flawed addToMutationMap in word count example. Patch by Dave Brosius, reviewed by Brandon Williams for CASSANDRA-3669
Date Wed, 04 Jan 2012 16:42:02 GMT
Updated Branches:
  refs/heads/cassandra-1.0 190fb8c8e -> de333791e


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/cassandra-1.0
Commit: de333791e81ae5364e2454af1e2fbf674bacb761
Parents: 190fb8c
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Wed Jan 4 10:33:57 2012 -0600
Committer: Brandon Williams <brandonwilliams@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 {


Mime
View raw message