cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r779773 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: cql/common/ db/
Date Thu, 28 May 2009 21:15:26 GMT
Author: jbellis
Date: Thu May 28 21:15:24 2009
New Revision: 779773

URL: http://svn.apache.org/viewvc?rev=779773&view=rev
Log:
r/m Row.getColumnFamilyMap.  replaced with Row.getColumnFamily or .getColumnFamilies as appropriate.
patch by jbellis; reviewed by Sandeep Tata for CASSANDRA-198

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java
Thu May 28 21:15:24 2009
@@ -113,37 +113,33 @@
         List<Map<String, String>> rows = new LinkedList<Map<String, String>>();
         if (row != null)
         {
-            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
-            if (cfMap != null && cfMap.size() > 0)
+            ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName);
+            if (cfamily != null)
             {
-                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
-                if (cfamily != null)
+                Collection<IColumn> columns = null;
+                if (superColumnKey_ != null)
                 {
-                    Collection<IColumn> columns = null;
-                    if (superColumnKey_ != null)
-                    {
-                        // this is the super column case 
-                        IColumn column = cfamily.getColumn(superColumnKey);
-                        if (column != null)
-                            columns = column.getSubColumns();
-                    }
-                    else
-                    {
-                        columns = cfamily.getAllColumns();
-                    }
+                    // this is the super column case
+                    IColumn column = cfamily.getColumn(superColumnKey);
+                    if (column != null)
+                        columns = column.getSubColumns();
+                }
+                else
+                {
+                    columns = cfamily.getAllColumns();
+                }
 
-                    if (columns != null && columns.size() > 0)
+                if (columns != null && columns.size() > 0)
+                {
+                    for (IColumn column : columns)
                     {
-                        for (IColumn column : columns)
-                        {
-                            Map<String, String> result = new HashMap<String, String>();
-                            
-                            result.put(cfMetaData_.n_columnKey, column.name());
-                            result.put(cfMetaData_.n_columnValue, new String(column.value()));
-                            result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp()));
-                            
-                            rows.add(result);
-                        }
+                        Map<String, String> result = new HashMap<String, String>();
+
+                        result.put(cfMetaData_.n_columnKey, column.name());
+                        result.put(cfMetaData_.n_columnValue, new String(column.value()));
+                        result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp()));
+
+                        rows.add(result);
                     }
                 }
             }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java
Thu May 28 21:15:24 2009
@@ -82,27 +82,23 @@
         List<Map<String, String>> rows = new LinkedList<Map<String, String>>();
         if (row != null)
         {
-            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
-            if (cfMap != null && cfMap.size() > 0)
+            ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName);
+            if (cfamily != null)
             {
-                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
-                if (cfamily != null)
+                Collection<IColumn> columns = cfamily.getAllColumns();
+                if (columns != null && columns.size() > 0)
                 {
-                    Collection<IColumn> columns = cfamily.getAllColumns();
-                    if (columns != null && columns.size() > 0)
+                    for (IColumn column : columns)
                     {
-                        for (IColumn column : columns)
+                        Collection<IColumn> subColumns = column.getSubColumns();
+                        for( IColumn subColumn : subColumns )
                         {
-                            Collection<IColumn> subColumns = column.getSubColumns();
-                            for( IColumn subColumn : subColumns )
-                            {
-                               Map<String, String> result = new HashMap<String,
String>();
-                               result.put(cfMetaData_.n_superColumnKey, column.name()); 
                             
-                               result.put(cfMetaData_.n_columnKey, subColumn.name());
-                               result.put(cfMetaData_.n_columnValue, new String(subColumn.value()));
-                               result.put(cfMetaData_.n_columnTimestamp, Long.toString(subColumn.timestamp()));
-                               rows.add(result);
-                            }
+                           Map<String, String> result = new HashMap<String, String>();
+                           result.put(cfMetaData_.n_superColumnKey, column.name());
+                           result.put(cfMetaData_.n_columnKey, subColumn.name());
+                           result.put(cfMetaData_.n_columnValue, new String(subColumn.value()));
+                           result.put(cfMetaData_.n_columnTimestamp, Long.toString(subColumn.timestamp()));
+                           rows.add(result);
                         }
                     }
                 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java
Thu May 28 21:15:24 2009
@@ -97,51 +97,47 @@
 
         if (row != null)
         {
-            Map<String, ColumnFamily> cfMap = row.getColumnFamilyMap();
-            if (cfMap != null && cfMap.size() > 0)
+            ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName);
+            if (cfamily != null)
             {
-                ColumnFamily cfamily = cfMap.get(cfMetaData_.cfName);
-                if (cfamily != null)
+                Collection<IColumn> columns = null;
+                if (superColumnKey_ != null)
                 {
-                    Collection<IColumn> columns = null;
-                    if (superColumnKey_ != null)
-                    {
-                        // this is the super column case 
-                        IColumn column = cfamily.getColumn(superColumnKey);
-                        if (column != null)
-                            columns = column.getSubColumns();
-                    }
-                    else
+                    // this is the super column case
+                    IColumn column = cfamily.getColumn(superColumnKey);
+                    if (column != null)
+                        columns = column.getSubColumns();
+                }
+                else
+                {
+                    columns = cfamily.getAllColumns();
+                }
+
+                if (columns != null && columns.size() > 0)
+                {
+                    if (columns.size() > 1)
                     {
-                        columns = cfamily.getAllColumns();
+                        // We are looking up by a rowKey & columnKey. There should
+                        // be at most one column that matches. If we find more than
+                        // one, then it is an internal error.
+                        throw new RuntimeException(RuntimeErrorMsg.INTERNAL_ERROR.getMsg("Too
many columns found for: " + columnKey));
                     }
-                    
-                    if (columns != null && columns.size() > 0)
+                    for (IColumn column : columns)
                     {
-                        if (columns.size() > 1)
-                        {
-                            // We are looking up by a rowKey & columnKey. There should
-                            // be at most one column that matches. If we find more than
-                            // one, then it is an internal error.
-                            throw new RuntimeException(RuntimeErrorMsg.INTERNAL_ERROR.getMsg("Too
many columns found for: " + columnKey));
-                        }
-                        for (IColumn column : columns)
-                        {
-                            List<Map<String, String>> rows = new LinkedList<Map<String,
String>>();
-
-                            Map<String, String> result = new HashMap<String, String>();
-                            result.put(cfMetaData_.n_columnKey, column.name());
-                            result.put(cfMetaData_.n_columnValue, new String(column.value()));
-                            result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp()));
-                            
-                            rows.add(result);
-                                
-                            // at this point, due to the prior checks, we are guaranteed
that
-                            // there is only one item in "columns".
-                            return rows;
-                        }
-                        return null;
+                        List<Map<String, String>> rows = new LinkedList<Map<String,
String>>();
+
+                        Map<String, String> result = new HashMap<String, String>();
+                        result.put(cfMetaData_.n_columnKey, column.name());
+                        result.put(cfMetaData_.n_columnValue, new String(column.value()));
+                        result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp()));
+
+                        rows.add(result);
+
+                        // at this point, due to the prior checks, we are guaranteed that
+                        // there is only one item in "columns".
+                        return rows;
                     }
+                    return null;
                 }
             }
         }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java Thu May 28 21:15:24
2009
@@ -369,15 +369,12 @@
                     try
                     {                        
                         Row row = Row.serializer().deserialize(bufIn);
-                        Map<String, ColumnFamily> columnFamilies = new HashMap<String,
ColumnFamily>(row.getColumnFamilyMap());
+                        Collection<ColumnFamily> columnFamilies = new ArrayList<ColumnFamily>(row.getColumnFamilies());
                         /* remove column families that have already been flushed */
-                    	Set<String> cNames = columnFamilies.keySet();
-
-                        for ( String cName : cNames )
+                        for (ColumnFamily columnFamily : columnFamilies)
                         {
-                        	ColumnFamily columnFamily = columnFamilies.get(cName);
                         	/* TODO: Remove this to not process Hints */
-                        	if ( !DatabaseDescriptor.isApplicationColumnFamily(cName) )
+                        	if ( !DatabaseDescriptor.isApplicationColumnFamily(columnFamily.name())
)
                         	{
                         		row.removeColumnFamily(columnFamily);
                         		continue;
@@ -416,12 +413,9 @@
     */
     private void updateHeader(Row row) throws IOException
     {
-    	Map<String, ColumnFamily> columnFamilies = row.getColumnFamilyMap();
         Table table = Table.open(table_);
-        Set<String> cNames = columnFamilies.keySet();
-        for ( String cName : cNames )
+        for (ColumnFamily columnFamily : row.getColumnFamilies())
         {
-        	ColumnFamily columnFamily = columnFamilies.get(cName);
         	int id = table.getColumnFamilyId(columnFamily.name());
         	if ( clHeader_.get(id) == 0 || ( clHeader_.get(id) == 1 && clHeader_.getPosition(id)
== 0 ) )
         	{

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java Thu May 28 21:15:24
2009
@@ -132,13 +132,8 @@
         else
         {
             /* we crashed and came back up need to bump generation # */
-        	Map<String, ColumnFamily> columnFamilies = row.getColumnFamilyMap();
-        	Set<String> cfNames = columnFamilies.keySet();
-
-            for ( String cfName : cfNames )
+            for (ColumnFamily columnFamily : row.getColumnFamilies())
             {
-            	ColumnFamily columnFamily = columnFamilies.get(cfName);
-
                 IColumn tokenColumn = columnFamily.getColumn(SystemTable.token_);
                 Token token = p.getTokenFactory().fromByteArray(tokenColumn.value());
 
@@ -148,7 +143,7 @@
                 Column generation2 = new Column("Generation", BasicUtilities.intToByteArray(gen),
generation.timestamp() + 1);
                 columnFamily.addColumn(generation2);
                 storageMetadata = new StorageMetadata(token, gen);
-                break;
+                break; // TODO why break after one iteration?
             }
             sysTable.reset(row);
         }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java Thu May 28 21:15:24
2009
@@ -78,13 +78,6 @@
         return columnFamilies_.values();
     }
 
-    @Deprecated
-    // (use getColumnFamilies or getColumnFamilyNames)
-    public Map<String, ColumnFamily> getColumnFamilyMap()
-    {
-        return columnFamilies_;
-    }
-
     public ColumnFamily getColumnFamily(String cfName)
     {
         return columnFamilies_.get(cfName);
@@ -199,16 +192,15 @@
     public void serialize(Row row, DataOutputStream dos) throws IOException
     {
         dos.writeUTF(row.key());
-        Map<String, ColumnFamily> columnFamilies = row.getColumnFamilyMap();
+        Collection<ColumnFamily> columnFamilies = row.getColumnFamilies();
         int size = columnFamilies.size();
         dos.writeInt(size);
 
         if (size > 0)
         {
-            Set<String> cNames = columnFamilies.keySet();
-            for (String cName : cNames)
+            for (ColumnFamily cf : columnFamilies)
             {
-                ColumnFamily.serializer().serialize(columnFamilies.get(cName), dos);
+                ColumnFamily.serializer().serialize(cf, dos);
             }
         }
     }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java Thu May 28
21:15:24 2009
@@ -238,7 +238,7 @@
     */
     void apply(Row emptyRow) throws IOException
     {
-        assert emptyRow.getColumnFamilyMap().size() == 0;
+        assert emptyRow.getColumnFamilies().size() == 0;
         Table table = Table.open(table_);
         for (String cfName : modifications_.keySet())
         {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java Thu May 28
21:15:24 2009
@@ -154,9 +154,8 @@
         IPartitioner p = StorageService.getPartitioner();
         if ( systemRow_ != null )
         {
-            Map<String, ColumnFamily> columnFamilies = systemRow_.getColumnFamilyMap();
             /* Retrieve the "LocationInfo" column family */
-            ColumnFamily columnFamily = columnFamilies.get(SystemTable.cfName_);
+            ColumnFamily columnFamily = systemRow_.getColumnFamily(SystemTable.cfName_);
             long oldTokenColumnTimestamp = columnFamily.getColumn(SystemTable.token_).timestamp();
             /* create the "Token" whose value is the new token. */
             IColumn tokenColumn = new Column(SystemTable.token_, p.getTokenFactory().toByteArray(token),
oldTokenColumnTimestamp + 1);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=779773&r1=779772&r2=779773&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Thu May 28 21:15:24
2009
@@ -822,12 +822,8 @@
     void applyNow(Row row) throws IOException
     {
         String key = row.key();
-        Map<String, ColumnFamily> columnFamilies = row.getColumnFamilyMap();
-
-        Set<String> cNames = columnFamilies.keySet();
-        for ( String cName : cNames )
+        for (ColumnFamily columnFamily : row.getColumnFamilies())
         {
-            ColumnFamily columnFamily = columnFamilies.get(cName);
             ColumnFamilyStore cfStore = columnFamilyStores_.get(columnFamily.name());
             cfStore.applyNow( key, columnFamily );
         }
@@ -852,13 +848,10 @@
         /* Add row to the commit log. */
         long start = System.currentTimeMillis();
                 
-        Map<String, ColumnFamily> columnFamilies = row.getColumnFamilyMap();
-        Set<String> cNames = columnFamilies.keySet();
-        for ( String cName : cNames )
+        for (ColumnFamily columnFamily : row.getColumnFamilies())
         {
-        	if( cName.equals(Table.recycleBin_))
+        	if (columnFamily.name().equals(Table.recycleBin_))
         	{
-	        	ColumnFamily columnFamily = columnFamilies.get(cName);
 	        	Collection<IColumn> columns = columnFamily.getAllColumns();
         		for(IColumn column : columns)
         		{



Mime
View raw message