cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [4/9] git commit: reformat
Date Mon, 23 Jan 2012 22:04:52 GMT
reformat


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e31879e5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e31879e5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e31879e5

Branch: refs/heads/trunk
Commit: e31879e595a71e08519f94408be7eac069dd2096
Parents: 5409af4
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri Jan 20 17:40:21 2012 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Jan 23 16:02:44 2012 -0600

----------------------------------------------------------------------
 examples/hadoop_word_count/src/WordCountSetup.java |   56 +++++----
 .../org/apache/cassandra/db/ColumnFamilyStore.java |   90 +++++++-------
 2 files changed, 75 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e31879e5/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 dd3c824..0139ea4 100644
--- a/examples/hadoop_word_count/src/WordCountSetup.java
+++ b/examples/hadoop_word_count/src/WordCountSetup.java
@@ -28,6 +28,7 @@ import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,7 +46,7 @@ public class WordCountSetup
 
         client.set_keyspace(WordCount.KEYSPACE);
 
-        Map<ByteBuffer, Map<String,List<Mutation>>> mutationMap;
+        Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap;
         Column c;
 
         // text0: no rows
@@ -69,8 +70,8 @@ public class WordCountSetup
         logger.info("added text2");
 
         // text3: 1000 rows, 1 word
-        mutationMap = new HashMap<ByteBuffer,Map<String,List<Mutation>>>();
-        for (int i=0; i<1000; i++)
+        mutationMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
+        for (int i = 0; i < 1000; i++)
         {
             c = new Column()
                 .setName(ByteBufferUtil.bytes("text3"))
@@ -89,35 +90,37 @@ public class WordCountSetup
             client.add(key,
                        colParent,
                        new CounterColumn(ByteBufferUtil.bytes(sentence),
-                       (long)sentence.split("\\s").length),
-                       ConsistencyLevel.ONE );
+                                         (long) sentence.split("\\s").length),
+                       ConsistencyLevel.ONE);
         }
         logger.info("added key-if-verse1");
 
         System.exit(0);
     }
 
-    private static Map<ByteBuffer,Map<String,List<Mutation>>> getMutationMap(ByteBuffer
key, String cf, Column c)
+    private static Map<ByteBuffer, Map<String, List<Mutation>>> getMutationMap(ByteBuffer
key, String cf, Column c)
     {
-        Map<ByteBuffer,Map<String,List<Mutation>>> mutationMap = new HashMap<ByteBuffer,Map<String,List<Mutation>>>();
+        Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap = new
HashMap<ByteBuffer, Map<String, List<Mutation>>>();
         addToMutationMap(mutationMap, key, cf, c);
         return mutationMap;
     }
 
-    private static void addToMutationMap(Map<ByteBuffer,Map<String,List<Mutation>>>
mutationMap, ByteBuffer key, String cf, Column c)
+    private static void addToMutationMap(Map<ByteBuffer, Map<String, List<Mutation>>>
mutationMap, ByteBuffer key, String cf, Column c)
     {
         Map<String, List<Mutation>> cfMutation = mutationMap.get(key);
-        if (cfMutation == null) {
+        if (cfMutation == null)
+        {
             cfMutation = new HashMap<String, List<Mutation>>();
             mutationMap.put(key, cfMutation);
         }
-        
+
         List<Mutation> mutationList = cfMutation.get(cf);
-        if (mutationList == null) {
+        if (mutationList == null)
+        {
             mutationList = new ArrayList<Mutation>();
-            cfMutation.put(cf,  mutationList);
+            cfMutation.put(cf, mutationList);
         }
-        
+
         ColumnOrSuperColumn cc = new ColumnOrSuperColumn();
         Mutation m = new Mutation();
 
@@ -126,7 +129,8 @@ public class WordCountSetup
         mutationList.add(m);
     }
 
-    private static void setupKeyspace(Cassandra.Iface client) throws TException, InvalidRequestException,
SchemaDisagreementException {
+    private static void setupKeyspace(Cassandra.Iface client) throws TException, InvalidRequestException,
SchemaDisagreementException
+    {
         List<CfDef> cfDefList = new ArrayList<CfDef>();
         CfDef input = new CfDef(WordCount.KEYSPACE, WordCount.COLUMN_FAMILY);
         input.setComparator_type("AsciiType");
@@ -161,11 +165,11 @@ public class WordCountSetup
     {
         if (System.getProperty("cassandra.host") == null || System.getProperty("cassandra.port")
== null)
         {
-           logger.warn("cassandra.host or cassandra.port is not defined, using default");
+            logger.warn("cassandra.host or cassandra.port is not defined, using default");
         }
-        return createConnection( System.getProperty("cassandra.host","localhost"),
-                                 Integer.valueOf(System.getProperty("cassandra.port","9160")),
-                                 Boolean.valueOf(System.getProperty("cassandra.framed", "true"))
);
+        return createConnection(System.getProperty("cassandra.host", "localhost"),
+                                Integer.valueOf(System.getProperty("cassandra.port", "9160")),
+                                Boolean.valueOf(System.getProperty("cassandra.framed", "true")));
     }
 
     private static Cassandra.Client createConnection(String host, Integer port, boolean framed)
throws TTransportException
@@ -181,14 +185,14 @@ public class WordCountSetup
     private static String[] sentenceData()
     {   // Public domain context, source http://en.wikisource.org/wiki/If%E2%80%94
         return new String[]{
-            "If you can keep your head when all about you",
-            "Are losing theirs and blaming it on you",
-            "If you can trust yourself when all men doubt you,",
-            "But make allowance for their doubting too:",
-            "If you can wait and not be tired by waiting,",
-            "Or being lied about, don’t deal in lies,",
-            "Or being hated, don’t give way to hating,",
-            "And yet don’t look too good, nor talk too wise;"
+                "If you can keep your head when all about you",
+                "Are losing theirs and blaming it on you",
+                "If you can trust yourself when all men doubt you,",
+                "But make allowance for their doubting too:",
+                "If you can wait and not be tired by waiting,",
+                "Or being lied about, don’t deal in lies,",
+                "Or being hated, don’t give way to hating,",
+                "And yet don’t look too good, nor talk too wise;"
         };
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e31879e5/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 7ff46c9..0edae3f 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1306,51 +1306,51 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
     {
         if (logger.isDebugEnabled())
             logger.debug("Filtering {} for rows matching {}", rowIterator, filter);
-         List<Row> rows = new ArrayList<Row>();
-         int columnsCount = 0;
-         try
-         {
-             while (rowIterator.hasNext() && rows.size() < filter.maxRows() &&
columnsCount < filter.maxColumns())
-             {
-                 // get the raw columns requested, and additional columns for the expressions
if necessary
-                 Row rawRow = rowIterator.next();
-                 ColumnFamily data = rawRow.cf;
-
-                 // roughtly
-                 IFilter extraFilter = filter.getExtraFilter(data);
-                 if (extraFilter != null)
-                 {
-                     QueryPath path = new QueryPath(columnFamily);
-                     ColumnFamily cf = filter.cfs.getColumnFamily(new QueryFilter(rawRow.key,
path, extraFilter));
-                     if (cf != null)
-                         data.addAll(cf, HeapAllocator.instance);
-                 }
-
-                 if (!filter.isSatisfiedBy(data))
-                     continue;
-
-                 logger.debug("{} satisfies all filter expressions", data);
-                 // cut the resultset back to what was requested, if necessary
-                 data = filter.prune(data);
-                 rows.add(new Row(rawRow.key, data));
-                 if (data != null)
-                     columnsCount += data.getLiveColumnCount();
-                 // Update the underlying filter to avoid querying more columns per slice
than necessary
-                 filter.updateColumnsLimit(columnsCount);
-             }
-             return rows;
-         }
-         finally
-         {
-             try
-             {
-                 rowIterator.close();
-             }
-             catch (IOException e)
-             {
-                 throw new IOError(e);
-             }
-         }
+        List<Row> rows = new ArrayList<Row>();
+        int columnsCount = 0;
+        try
+        {
+            while (rowIterator.hasNext() && rows.size() < filter.maxRows() &&
columnsCount < filter.maxColumns())
+            {
+                // get the raw columns requested, and additional columns for the expressions
if necessary
+                Row rawRow = rowIterator.next();
+                ColumnFamily data = rawRow.cf;
+
+                // roughtly
+                IFilter extraFilter = filter.getExtraFilter(data);
+                if (extraFilter != null)
+                {
+                    QueryPath path = new QueryPath(columnFamily);
+                    ColumnFamily cf = filter.cfs.getColumnFamily(new QueryFilter(rawRow.key,
path, extraFilter));
+                    if (cf != null)
+                        data.addAll(cf, HeapAllocator.instance);
+                }
+
+                if (!filter.isSatisfiedBy(data))
+                    continue;
+
+                logger.debug("{} satisfies all filter expressions", data);
+                // cut the resultset back to what was requested, if necessary
+                data = filter.prune(data);
+                rows.add(new Row(rawRow.key, data));
+                if (data != null)
+                    columnsCount += data.getLiveColumnCount();
+                // Update the underlying filter to avoid querying more columns per slice
than necessary
+                filter.updateColumnsLimit(columnsCount);
+            }
+            return rows;
+        }
+        finally
+        {
+            try
+            {
+                rowIterator.close();
+            }
+            catch (IOException e)
+            {
+                throw new IOError(e);
+            }
+        }
     }
 
     public AbstractType<?> getComparator()


Mime
View raw message