cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/3] git commit: Fix ABTC NPE patch by Benedict Elliott Smith; reviewed by jbellis for CASSANDRA-6692
Date Thu, 20 Feb 2014 17:36:59 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 63b1ef4ee -> 5223c4797
  refs/heads/trunk 4d75ed206 -> 7c730279e


Fix ABTC NPE
patch by Benedict Elliott Smith; reviewed by jbellis for CASSANDRA-6692


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

Branch: refs/heads/cassandra-2.1
Commit: 5223c4797cbb46d5df427d72bb115f96af342d60
Parents: 63b1ef4
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Feb 20 11:36:34 2014 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Feb 20 11:36:48 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../apache/cassandra/db/AtomicBTreeColumns.java | 14 ++++++++----
 .../org/apache/cassandra/utils/btree/BTree.java | 24 ++++++++++++++++----
 3 files changed, 30 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5223c479/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index feece93..efc54f8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,7 +1,9 @@
 2.1.0-beta2
+ * Fix ABTC NPE (CASSANDRA-6692)
  * Allow nodetool to use a file or prompt for password (CASSANDRA-6660)
  * Fix AIOOBE when concurrently accessing ABSC (CASSANDRA-6742)
 
+
 2.1.0-beta1
  * Add flush directory distinct from compaction directories (CASSANDRA-6357)
  * Require JNA by default (CASSANDRA-6575)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5223c479/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
index 5f56326..f75efd2 100644
--- a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
+++ b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
@@ -230,25 +230,29 @@ public class AtomicBTreeColumns extends ColumnFamily
             Holder current = ref;
 
             delta.reset();
-            DeletionInfo deletionInfo = cm.deletionInfo();
-            if (deletionInfo.mayModify(current.deletionInfo))
+            DeletionInfo deletionInfo;
+            if (cm.deletionInfo().mayModify(current.deletionInfo))
             {
-                if (deletionInfo.hasRanges())
+                if (cm.deletionInfo().hasRanges())
                 {
                     for (Iterator<Cell> iter : new Iterator[] { insert.iterator(),
BTree.<Cell>slice(current.tree, true) })
                     {
                         while (iter.hasNext())
                         {
                             Cell col = iter.next();
-                            if (deletionInfo.isDeleted(col))
+                            if (cm.deletionInfo().isDeleted(col))
                                 indexer.remove(col);
                         }
                     }
                 }
 
-                deletionInfo = current.deletionInfo.copy().add(deletionInfo);
+                deletionInfo = current.deletionInfo.copy().add(cm.deletionInfo());
                 delta.addHeapSize(deletionInfo.unsharedHeapSize() - current.deletionInfo.unsharedHeapSize());
             }
+            else
+            {
+                deletionInfo = current.deletionInfo;
+            }
 
             ColumnUpdater updater = new ColumnUpdater(this, current, allocator, transformation,
indexer, delta);
             Object[] tree = BTree.update(current.tree, metadata.comparator.columnComparator(),
insert, true, updater);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5223c479/src/java/org/apache/cassandra/utils/btree/BTree.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/btree/BTree.java b/src/java/org/apache/cassandra/utils/btree/BTree.java
index 82f5574..69cf145 100644
--- a/src/java/org/apache/cassandra/utils/btree/BTree.java
+++ b/src/java/org/apache/cassandra/utils/btree/BTree.java
@@ -18,9 +18,11 @@
  */
 package org.apache.cassandra.utils.btree;
 
+import java.util.ArrayDeque;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.Queue;
 
 import org.apache.cassandra.utils.ObjectSizes;
 
@@ -113,7 +115,13 @@ public class BTree
         if (!sorted)
             source = sorted(source, comparator, size);
 
-        return modifier.get().build(source, size);
+        Queue<Builder> queue = modifier.get();
+        Builder builder = queue.poll();
+        if (builder == null)
+            builder = new Builder();
+        Object[] btree = builder.build(source, size);
+        queue.add(builder);
+        return btree;
     }
 
     /**
@@ -154,7 +162,13 @@ public class BTree
         if (!updateWithIsSorted)
             updateWith = sorted(updateWith, comparator, updateWith.size());
 
-        return modifier.get().update(btree, comparator, updateWith, updateF);
+        Queue<Builder> queue = modifier.get();
+        Builder builder = queue.poll();
+        if (builder == null)
+            builder = new Builder();
+        btree = builder.update(btree, comparator, updateWith, updateF);
+        queue.add(builder);
+        return btree;
     }
 
     /**
@@ -319,12 +333,12 @@ public class BTree
         }
     };
 
-    private static final ThreadLocal<Builder> modifier = new ThreadLocal<Builder>()
+    private static final ThreadLocal<Queue<Builder>> modifier = new ThreadLocal<Queue<Builder>>()
     {
         @Override
-        protected Builder initialValue()
+        protected Queue<Builder> initialValue()
         {
-            return new Builder();
+            return new ArrayDeque<>();
         }
     };
 


Mime
View raw message