Author: eevans
Date: Wed Dec 14 22:54:15 2011
New Revision: 1214523

URL: http://svn.apache.org/viewvc?rev=1214523&view=rev
Log:
review-related code-style fixes and cleanups

Patch by eevans; reviewed by Rick Shaw for CASSANDRA-2475

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/cql/DeleteStatement.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/SelectExpression.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/Term.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/WhereClause.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/DeleteStatement.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/DeleteStatement.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/DeleteStatement.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/DeleteStatement.java Wed 
Dec 14 22:54:15 2011
@@ -92,8 +92,7 @@ public class DeleteStatement extends Abs
         CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
         QueryProcessor.validateKeyAlias(metadata, keyName);
 
-        @SuppressWarnings("rawtypes")
-        AbstractType comparator = metadata.getComparatorFor(null);
+        AbstractType<?> comparator = metadata.getComparatorFor(null);
 
         if (columns.size() < 1)
         {

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java Wed 
Dec 14 22:54:15 2011
@@ -498,9 +498,7 @@ public class QueryProcessor
     private final static void maybeAddBoundTerm(CQLStatement statement, Term 
term) throws InvalidRequestException
     {
         if (term != null && term.isBindMarker())
-        {
             term.setBindIndex(statement.boundTerms++);
-        }
     }
     
     public static void discoverBoundTerms(CQLStatement statement) throws 
InvalidRequestException
@@ -512,15 +510,15 @@ public class QueryProcessor
                 if (logger.isTraceEnabled()) logger.trace(select.toString());
                 
                 // handle the select expression first
-                if (!select.isColumnRange() )
+                if (!select.isColumnRange())
                 {
-                    List<Term> list = select.getColumnNames();
-                    for (Term term : list) maybeAddBoundTerm(statement,term);
+                    for (Term term : select.getColumnNames())
+                        maybeAddBoundTerm(statement,term);
                 }
                 else
                 {
-                    maybeAddBoundTerm(statement,select.getColumnStart());
-                    maybeAddBoundTerm(statement,select.getColumnFinish());
+                    maybeAddBoundTerm(statement, select.getColumnStart());
+                    maybeAddBoundTerm(statement, select.getColumnFinish());
                 }
                 
                 // next handle the WHERE clause NB order is VERY important
@@ -529,26 +527,26 @@ public class QueryProcessor
                 
                 if (select.isMultiKey())
                 {
-                    for (Term term : select.getKeys()) 
maybeAddBoundTerm(statement,term);
+                    for (Term term : select.getKeys()) 
maybeAddBoundTerm(statement, term);
                 }
                 else if (!select.getColumnRelations().isEmpty())
                 {
                     if (select.isKeyRange())
                     {
-                        maybeAddBoundTerm(statement,select.getKeyStart());
-                        maybeAddBoundTerm(statement,select.getKeyFinish());
+                        maybeAddBoundTerm(statement, select.getKeyStart());
+                        maybeAddBoundTerm(statement, select.getKeyFinish());
                     }
 
                     for (Relation relation : select.getColumnRelations())
                     {
-                        maybeAddBoundTerm(statement,relation.getEntity());
-                        maybeAddBoundTerm(statement,relation.getValue());
+                        maybeAddBoundTerm(statement, relation.getEntity());
+                        maybeAddBoundTerm(statement, relation.getValue());
                     }                    
                 }
                 else
                 {
                     // maybe its empty or just a simple term
-                    for (Term term : select.getKeys()) 
maybeAddBoundTerm(statement,term);                   
+                    for (Term term : select.getKeys()) 
maybeAddBoundTerm(statement, term);
                 }
 
                break;
@@ -560,13 +558,13 @@ public class QueryProcessor
                 // first handle the SET clause values that come in pairs for 
UPDATE. NB the order of the markers (?)
                 for (Map.Entry<Term, Operation> column : 
update.getColumns().entrySet())
                 {
-                    maybeAddBoundTerm(statement,column.getKey());
-                    maybeAddBoundTerm(statement,column.getValue().a);
+                    maybeAddBoundTerm(statement, column.getKey());
+                    maybeAddBoundTerm(statement, column.getValue().a);
                 }
                 
                 // now handle the key(s) in the WHERE clause
 
-                for (Term term : update.getKeys()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : update.getKeys()) 
maybeAddBoundTerm(statement, term);
                 break;
                 
             case INSERT: // insert uses UpdateStatement but with different 
marker ordering
@@ -574,11 +572,11 @@ public class QueryProcessor
                 if (logger.isTraceEnabled()) logger.trace(insert.toString());
                                 
                 // first handle the INTO..VALUES clause values that are 
grouped in order for INSERT. NB the order of the markers (?)
-                for (Term term : insert.getColumnNames()) 
maybeAddBoundTerm(statement,term);
-                for (Term term : insert.getColumnValues()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : insert.getColumnNames()) 
maybeAddBoundTerm(statement, term);
+                for (Term term : insert.getColumnValues()) 
maybeAddBoundTerm(statement, term);
 
                 // now handle the key(s) in the VALUES clause 
-                for (Term term : insert.getKeys()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : insert.getKeys()) 
maybeAddBoundTerm(statement, term);
                 break;
 
             case DELETE:
@@ -586,31 +584,31 @@ public class QueryProcessor
                 if (logger.isTraceEnabled()) logger.trace(delete.toString());
 
                 // first handle the columns list for DELETE. NB the order of 
the markers (?)
-                for (Term term : delete.getColumns()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : delete.getColumns()) 
maybeAddBoundTerm(statement, term);
 
                 // now handle the key(s) in the WHERE clause 
-                for (Term term : delete.getKeys()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : delete.getKeys()) 
maybeAddBoundTerm(statement, term);
                 break;
 
             case CREATE_COLUMNFAMILY:
                 CreateColumnFamilyStatement createCf = 
(CreateColumnFamilyStatement)statement.statement;
                 
                 // handle the left hand Terms. Not terribly useful but 
included for completeness
-                for (Term term : createCf.getColumns().keySet()) 
maybeAddBoundTerm(statement,term);
+                for (Term term : createCf.getColumns().keySet()) 
maybeAddBoundTerm(statement, term);
                 break;
 
             case CREATE_INDEX:
                 CreateIndexStatement createIdx = 
(CreateIndexStatement)statement.statement;
                 
                 // handle the column name Term. Not terribly useful but 
included for completeness
-                maybeAddBoundTerm(statement,createIdx.getColumnName());
+                maybeAddBoundTerm(statement, createIdx.getColumnName());
                 break;
                 
            default: // all other statement types are a NOOP.                   
 
         }
     }
     
-    public static CqlResult doTheStatement(CQLStatement statement,ClientState 
clientState, List<String> variables )
+    public static CqlResult processStatement(CQLStatement 
statement,ClientState clientState, List<String> variables )
     throws  UnavailableException, InvalidRequestException, TimedOutException, 
SchemaDisagreementException
     {
         String keyspace = null;
@@ -1093,33 +1091,25 @@ public class QueryProcessor
     throws RecognitionException, UnavailableException, 
InvalidRequestException, TimedOutException, SchemaDisagreementException
     {
         if (logger.isDebugEnabled()) logger.debug("CQL QUERY: {}", 
queryString);
-        
-        CQLStatement statement = getStatement(queryString);
-        
-        CqlResult result = doTheStatement(statement, clientState, new 
ArrayList<String>());
-        
-        return result;
+        return processStatement(getStatement(queryString), clientState, new 
ArrayList<String>());
     }
 
-    public static CQLStatement prepare (String queryString, ClientState 
clientState)
-                    throws RecognitionException, InvalidRequestException
+    public static CQLStatement prepare(String queryString, ClientState 
clientState)
+    throws RecognitionException, InvalidRequestException
     {
         if (logger.isDebugEnabled()) logger.debug("CQL QUERY: {}", 
queryString);
-
-        CQLStatement statement = getStatement(queryString);
-
-        return statement;
+        return getStatement(queryString);
     }
    
-    public static CqlResult process_prepared(CQLStatement statement, 
ClientState clientState, List<String> variables)
+    public static CqlResult processPrepared(CQLStatement statement, 
ClientState clientState, List<String> variables)
     throws UnavailableException, InvalidRequestException, TimedOutException, 
SchemaDisagreementException
     {
         // Check to see if there are any bound variables to verify 
-        if (!(variables.isEmpty() && (statement.boundTerms==0)))
+        if (!(variables.isEmpty() && (statement.boundTerms == 0)))
         {
             if (variables.size() != statement.boundTerms) 
                 throw new InvalidRequestException(String.format("there were %d 
markers(?) in CQL but  %d bound variables",
-                statement.boundTerms, variables.size()));
+                                                                
statement.boundTerms, variables.size()));
 
             // at this point there is a match in count between markers and 
variables that is non-zero
 
@@ -1127,9 +1117,7 @@ public class QueryProcessor
                 for (int i = 0; i < variables.size(); i++) logger.trace("[{}] 
'{}'",i+1,variables.get(i));
         }
 
-        CqlResult result = doTheStatement(statement, clientState, variables);
-
-        return result;
+        return processStatement(statement, clientState, variables);
     }
     
 

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/cql/SelectExpression.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/SelectExpression.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/SelectExpression.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/SelectExpression.java Wed 
Dec 14 22:54:15 2011
@@ -151,13 +151,13 @@ public class SelectExpression
     public String toString()
     {
         return String.format("SelectExpression [numColumns=%s, 
reverseColumns=%s, hasFirstSet=%s, wildcard=%s, start=%s, finish=%s, 
columns=%s]",
-            numColumns,
-            reverseColumns,
-            hasFirstSet,
-            wildcard,
-            start,
-            finish,
-            columns);
+                             numColumns,
+                             reverseColumns,
+                             hasFirstSet,
+                             wildcard,
+                             start,
+                             finish,
+                             columns);
     }
     
     

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java Wed 
Dec 14 22:54:15 2011
@@ -175,12 +175,12 @@ public class SelectStatement
         clause.extractKeysFromColumns(cfm);
     }
 
-    public AbstractType getComparator(String keyspace)
+    public AbstractType<?> getComparator(String keyspace)
     {
         return Schema.instance.getComparator(keyspace, columnFamily);
     }
     
-    public AbstractType getValueValidator(String keyspace, ByteBuffer column)
+    public AbstractType<?> getValueValidator(String keyspace, ByteBuffer 
column)
     {
         return Schema.instance.getValueValidator(keyspace, columnFamily, 
column);
     }
@@ -188,13 +188,13 @@ public class SelectStatement
     public String toString()
     {
         return String.format("SelectStatement [expression=%s, isCountOper=%s, 
columnFamily=%s, keyspace=%s, cLevel=%s, clause=%s, numRecords=%s]",
-            expression,
-            isCountOper,
-            columnFamily,
-            keyspace,
-            cLevel,
-            clause,
-            numRecords);
+                             expression,
+                             isCountOper,
+                             columnFamily,
+                             keyspace,
+                             cLevel,
+                             clause,
+                             numRecords);
     }
     
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/Term.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/Term.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/Term.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/Term.java Wed Dec 14 
22:54:15 2011
@@ -99,11 +99,10 @@ public class Term
             if (!isBindMarker()) return validator.fromString(text);
             
             // must be a marker term so check for a CqlBindValue stored in the 
term
-            if (bindIndex==null) throw new AssertionError("a marker Term was 
encountered with no index value");
-            
-            String bindValue = variables.get(bindIndex);
+            if (bindIndex == null)
+                throw new AssertionError("a marker Term was encountered with 
no index value");
                         
-            return validator.fromString(bindValue);
+            return validator.fromString(variables.get(bindIndex));
         }
         catch (MarshalException e)
         {

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/WhereClause.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/WhereClause.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/WhereClause.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/WhereClause.java Wed Dec 
14 22:54:15 2011
@@ -186,14 +186,14 @@ public class WhereClause
     public String toString()
     {
         return String.format("WhereClause [keys=%s, startKey=%s, finishKey=%s, 
columns=%s, includeStartKey=%s, includeFinishKey=%s, multiKey=%s, keyAlias=%s]",
-            keys,
-            startKey,
-            finishKey,
-            columns,
-            includeStartKey,
-            includeFinishKey,
-            multiKey,
-            keyAlias);
+                             keys,
+                             startKey,
+                             finishKey,
+                             columns,
+                             includeStartKey,
+                             includeFinishKey,
+                             multiKey,
+                             keyAlias);
     }
     
 

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1214523&r1=1214522&r2=1214523&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java 
Wed Dec 14 22:54:15 2011
@@ -1231,7 +1231,7 @@ public class CassandraServer implements 
    
     private static final int makeItemId(String cql)
     {
-       // use the hash of the string till something better is provided
+        // use the hash of the string till something better is provided
         return cql.hashCode();
     }
     
@@ -1253,7 +1253,8 @@ public class CassandraServer implements 
             
             // put the prepared Statement into the Map
             state().getPrepared().put(itemId, statement);
-            if (logger.isTraceEnabled()) logger.trace("Storing prepared 
statement: #"+ itemId + " count:"+state().getPrepared().size());
+            if (logger.isTraceEnabled())
+                logger.trace("Storing prepared statement: #"+ itemId + " 
count:"+state().getPrepared().size());
             return new CqlPreparedResult(itemId, statement.boundTerms);
         }
         catch (RecognitionException e)
@@ -1265,7 +1266,7 @@ public class CassandraServer implements 
     }
     
     
-   public CqlResult execute_prepared_cql_query(int itemId,List<String> 
bindVariables)
+    public CqlResult execute_prepared_cql_query(int itemId, List<String> 
bindVariables)
     throws InvalidRequestException, UnavailableException, TimedOutException, 
SchemaDisagreementException, TException
     {
         if (logger.isDebugEnabled()) 
logger.debug("execute_prepared_cql_query");
@@ -1273,8 +1274,7 @@ public class CassandraServer implements 
         CQLStatement statement = state().getPrepared().get(itemId);
         if (logger.isTraceEnabled()) logger.trace("Retreving prepared 
statement: #"+ itemId + " count:"+state().getPrepared().size());
         
-        CqlResult result = QueryProcessor.process_prepared(statement, state(), 
bindVariables);
-        return result;
+        return QueryProcessor.processPrepared(statement, state(), 
bindVariables);
     }
 
     // main method moved to CassandraDaemon


Reply via email to