cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Optimize CollationController.collectTimeOrderedData post CASSANDRA-6662
Date Tue, 11 Feb 2014 18:04:25 GMT
Updated Branches:
  refs/heads/trunk 520457502 -> 6de2fd9bf


Optimize CollationController.collectTimeOrderedData post CASSANDRA-6662


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

Branch: refs/heads/trunk
Commit: 6de2fd9bfd4c20e47495d171da7175c1a9e92c68
Parents: 5204575
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Tue Feb 11 21:04:13 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Feb 11 21:04:13 2014 +0300

----------------------------------------------------------------------
 .../cassandra/db/ArrayBackedSortedColumns.java  |  7 ++++--
 .../cassandra/db/CollationController.java       | 26 ++++++--------------
 2 files changed, 12 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6de2fd9b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
index a6153e4..8049d87 100644
--- a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
+++ b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
@@ -186,8 +186,11 @@ public class ArrayBackedSortedColumns extends AbstractThreadUnsafeSortedColumns
         }
         else
         {
-            // Append to the end, making cells unsorted from now on
-            internalAdd(cell);
+            int pos = binarySearch(cell.name());
+            if (pos >= 0) // Reconcile with an existing cell
+                reconcileWith(pos, cell);
+            else
+                internalAdd(cell); // Append to the end, making cells unsorted from now on
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6de2fd9b/src/java/org/apache/cassandra/db/CollationController.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CollationController.java b/src/java/org/apache/cassandra/db/CollationController.java
index 3fd3e8b..e5d3495 100644
--- a/src/java/org/apache/cassandra/db/CollationController.java
+++ b/src/java/org/apache/cassandra/db/CollationController.java
@@ -62,16 +62,10 @@ public class CollationController
     private ColumnFamily collectTimeOrderedData()
     {
         final ColumnFamily container = ArrayBackedSortedColumns.factory.create(cfs.metadata,
filter.filter.isReversed());
-        List<OnDiskAtomIterator> iterators = new ArrayList<OnDiskAtomIterator>();
+        List<OnDiskAtomIterator> iterators = new ArrayList<>();
         Tracing.trace("Acquiring sstable references");
         ColumnFamilyStore.ViewFragment view = cfs.markReferenced(filter.key);
 
-        // We use a temporary CF object per memtable or sstable source so we can accomodate
this.factory being ABSC,
-        // which requires addAtom to happen in sorted order.  Then we use addAll to merge
into the final collection,
-        // which allows a (sorted) set of columns to be merged even if they are not uniformly
sorted after the existing
-        // ones.
-        ColumnFamily temp = ArrayBackedSortedColumns.factory.create(cfs.metadata, filter.filter.isReversed());
-
         try
         {
             Tracing.trace("Merging memtable contents");
@@ -81,13 +75,10 @@ public class CollationController
                 if (iter != null)
                 {
                     iterators.add(iter);
-                    temp.delete(iter.getColumnFamily());
+                    container.delete(iter.getColumnFamily());
                     while (iter.hasNext())
-                        temp.addAtom(iter.next());
+                        container.addAtom(iter.next());
                 }
-
-                container.addAll(temp);
-                temp.clear();
             }
 
             // avoid changing the filter columns of the original filter
@@ -122,14 +113,11 @@ public class CollationController
                     ColumnFamily cf = iter.getColumnFamily();
                     if (cf.isMarkedForDelete())
                         mostRecentRowTombstone = cf.deletionInfo().getTopLevelDeletion().markedForDeleteAt;
-                    temp.delete(cf);
+                    container.delete(cf);
                     sstablesIterated++;
                     while (iter.hasNext())
-                        temp.addAtom(iter.next());
+                        container.addAtom(iter.next());
                 }
-
-                container.addAll(temp);
-                temp.clear();
             }
 
             // we need to distinguish between "there is no data at all for this row" (BF
will let us rebuild that efficiently)
@@ -189,7 +177,7 @@ public class CollationController
     {
         Tracing.trace("Acquiring sstable references");
         ColumnFamilyStore.ViewFragment view = cfs.markReferenced(filter.key);
-        List<OnDiskAtomIterator> iterators = new ArrayList<OnDiskAtomIterator>(Iterables.size(view.memtables)
+ view.sstables.size());
+        List<OnDiskAtomIterator> iterators = new ArrayList<>(Iterables.size(view.memtables)
+ view.sstables.size());
         ColumnFamily returnCF = ArrayBackedSortedColumns.factory.create(cfs.metadata, filter.filter.isReversed());
 
         try
@@ -238,7 +226,7 @@ public class CollationController
                     if (sstable.getSSTableMetadata().maxLocalDeletionTime != Integer.MAX_VALUE)
                     {
                         if (skippedSSTables == null)
-                            skippedSSTables = new ArrayList<SSTableReader>();
+                            skippedSSTables = new ArrayList<>();
                         skippedSSTables.add(sstable);
                     }
                     continue;


Mime
View raw message