cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Simplify logic of ABSC#BatchRemoveIterator#commit()
Date Mon, 26 Jan 2015 21:23:17 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 2bf63f61e -> b077cda83


Simplify logic of ABSC#BatchRemoveIterator#commit()

patch by Aleksey Yeschenko; reviewed by Joshua McKenzie for
CASSANDRA-8666


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

Branch: refs/heads/cassandra-2.0
Commit: b077cda83bb1d32d5e6836027cfdfe3009b266b4
Parents: 2bf63f6
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Tue Jan 27 00:20:38 2015 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Jan 27 00:20:38 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +-
 .../cassandra/db/ArrayBackedSortedColumns.java  | 53 +++++++-------------
 2 files changed, 20 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b077cda8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0d08cce..792f8c1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,6 @@
 2.0.13:
  * Round up time deltas lower than 1ms in BulkLoader (CASSANDRA-8645)
- * Add batch remove iterator to ABSC (CASSANDRA-8414)
+ * Add batch remove iterator to ABSC (CASSANDRA-8414, 8666)
 
 
 2.0.12:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b077cda8/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 8d553be..482f04f 100644
--- a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
+++ b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
@@ -314,43 +314,28 @@ public class ArrayBackedSortedColumns extends AbstractThreadUnsafeSortedColumns
                 if (!removedAnything)
                     return;
 
-                // the lowest index both not visited and known to be not removed
-                int keepIdx = removedIndexes.nextClearBit(0);
-                // the running total of kept items
-                int resultLength = 0;
-                // start from the first not-removed cell, and shift left.
-                int removeIdx = removedIndexes.nextSetBit(keepIdx + 1);
-                while (removeIdx >= 0)
-                {
-                    int length = removeIdx - keepIdx;
-                    if (length > 0)
-                    {
-                        copy(keepIdx, resultLength, length);
-                        resultLength += length;
-                    }
-                    keepIdx = removedIndexes.nextClearBit(removeIdx + 1);
-                    if (keepIdx < 0)
-                        keepIdx = columns.size();
-                    removeIdx = removedIndexes.nextSetBit(keepIdx + 1);
-                }
-                // Copy everything after the last deleted column
-                int length = columns.size() - keepIdx;
-                if (length > 0)
+                int size = columns.size();
+                int retainedCount = 0;
+                int clearIdx, setIdx = -1;
+
+                // shift all [clearIdx, setIdx) segments to the left, skipping any removed
columns
+                while (true)
                 {
-                    copy(keepIdx, resultLength, length);
-                    resultLength += length;
+                    clearIdx = removedIndexes.nextClearBit(setIdx + 1);
+                    if (clearIdx >= size)
+                        break; // nothing left to retain
+
+                    setIdx = removedIndexes.nextSetBit(clearIdx + 1);
+                    if (setIdx < 0)
+                        setIdx = size; // no removals past retainIdx - copy all remaining
cells
+
+                    if (retainedCount != clearIdx)
+                        Collections.copy(columns.subList(retainedCount, retainedCount + setIdx
- clearIdx),
+                                         columns.subList(clearIdx, setIdx));
+                    retainedCount += (setIdx - clearIdx);
                 }
 
-                columns.subList(resultLength, columns.size()).clear();
-            }
-
-            private void copy(int src, int dst, int len)
-            {
-                // [src, src+len) and [dst, dst+len) might overlap, but it's okay because
we're going from left to right
-                assert dst <= src : "dst must not be greater than src";
-
-                if (dst < src)
-                    Collections.copy(columns.subList(dst, dst + len), columns.subList(src,
src + len));
+                columns.subList(retainedCount, size).clear();
             }
 
             public boolean hasNext()


Mime
View raw message