cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1205403 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/db/CollationController.java src/java/org/apache/cassandra/db/Table.java
Date Wed, 23 Nov 2011 14:09:37 GMT
Author: jbellis
Date: Wed Nov 23 14:09:36 2011
New Revision: 1205403

URL: http://svn.apache.org/viewvc?rev=1205403&view=rev
Log:
"defragment" rows for name-based queries under STCS, again
patch by jbellis; reviewed by slebresne for CASSANDRA-2503

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1205403&r1=1205402&r2=1205403&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Wed Nov 23 14:09:36 2011
@@ -1,4 +1,5 @@
 1.1-dev
+ * "defragment" rows for name-based queries under STCS, again (CASSANDRA-2503)
  * Recycle commitlog segments for improved performance (CASSANDRA-3411)
  * update size-tiered compaction to prioritize small tiers (CASSANDRA-2407)
  * add message expiration logic to OutboundTcpConnection (CASSANDRA-3005)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java?rev=1205403&r1=1205402&r2=1205403&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java Wed Nov 23 14:09:36
2011
@@ -151,6 +151,24 @@ public class CollationController
             ColumnFamily returnCF = container.cloneMeShallow();
             filter.collateColumns(returnCF, Collections.singletonList(toCollate), cfs.metadata.comparator,
gcBefore);
             
+            // "hoist up" the requested data into a more recent sstable
+            if (!cfs.isCompactionDisabled()
+                && cfs.getMinimumCompactionThreshold() > 0
+                && cfs.getCompactionStrategy() instanceof SizeTieredCompactionStrategy)
+            {
+                RowMutation rm = new RowMutation(cfs.table.name, new Row(filter.key, returnCF.cloneMe()));
+                try
+                {
+                    // skipping commitlog and index updates is fine since we're just de-fragmenting
existing data
+                    Table.open(rm.getTable()).apply(rm, false, false);
+                }
+                catch (IOException e)
+                {
+                    // log and allow the result to be returned
+                    logger.error("Error re-writing read results", e);
+                }
+            }
+
             // Caller is responsible for final removeDeletedCF.  This is important for cacheRow
to work correctly:
             return returnCF;
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1205403&r1=1205402&r2=1205403&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Wed Nov 23 14:09:36 2011
@@ -376,12 +376,17 @@ public class Table
         return new Row(filter.key, columnFamily);
     }
 
+    public void apply(RowMutation mutation, boolean writeCommitLog) throws IOException
+    {
+        apply(mutation, writeCommitLog, true);
+    }
+
     /**
      * This method adds the row to the Commit Log associated with this table.
      * Once this happens the data associated with the individual column families
      * is also written to the column family store's memtable.
     */
-    public void apply(RowMutation mutation, boolean writeCommitLog) throws IOException
+    public void apply(RowMutation mutation, boolean writeCommitLog, boolean updateIndexes)
throws IOException
     {
         if (logger.isDebugEnabled())
             logger.debug("applying mutation of row {}", ByteBufferUtil.bytesToHex(mutation.key()));
@@ -404,21 +409,24 @@ public class Table
                 }
 
                 SortedSet<ByteBuffer> mutatedIndexedColumns = null;
-                for (ByteBuffer column : cfs.indexManager.getIndexedColumns())
+                if (updateIndexes)
                 {
-                    if (cf.getColumnNames().contains(column) || cf.isMarkedForDelete())
+                    for (ByteBuffer column : cfs.indexManager.getIndexedColumns())
                     {
-                        if (mutatedIndexedColumns == null)
-                            mutatedIndexedColumns = new TreeSet<ByteBuffer>();
-                        mutatedIndexedColumns.add(column);
-                        if (logger.isDebugEnabled())
+                        if (cf.getColumnNames().contains(column) || cf.isMarkedForDelete())
                         {
-                            // can't actually use validator to print value here, because
we overload value
-                            // for deletion timestamp as well (which may not be a well-formed
value for the column type)
-                            ByteBuffer value = cf.getColumn(column) == null ? null : cf.getColumn(column).value();
// may be null on row-level deletion
-                            logger.debug(String.format("mutating indexed column %s value
%s",
-                                                       cf.getComparator().getString(column),
-                                                       value == null ? "null" : ByteBufferUtil.bytesToHex(value)));
+                            if (mutatedIndexedColumns == null)
+                                mutatedIndexedColumns = new TreeSet<ByteBuffer>();
+                            mutatedIndexedColumns.add(column);
+                            if (logger.isDebugEnabled())
+                            {
+                                // can't actually use validator to print value here, because
we overload value
+                                // for deletion timestamp as well (which may not be a well-formed
value for the column type)
+                                ByteBuffer value = cf.getColumn(column) == null ? null :
cf.getColumn(column).value(); // may be null on row-level deletion
+                                logger.debug(String.format("mutating indexed column %s value
%s",
+                                                           cf.getComparator().getString(column),
+                                                           value == null ? "null" : ByteBufferUtil.bytesToHex(value)));
+                            }
                         }
                     }
                 }
@@ -453,7 +461,6 @@ public class Table
         {
             switchLock.readLock().unlock();
         }
-
     }
 
     private static void ignoreObsoleteMutations(ColumnFamily cf, SortedSet<ByteBuffer>
mutatedIndexedColumns, ColumnFamily oldIndexedColumns)



Mime
View raw message