You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2014/04/03 23:00:55 UTC

[3/3] git commit: merge from 2.1

merge from 2.1


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

Branch: refs/heads/trunk
Commit: 106b43d4479a48f89e09f0563732b7df33b0d386
Parents: 51380e7 e6e596d
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Apr 3 16:00:39 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Apr 3 16:00:39 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/utils/btree/BTree.java |  4 +-
 .../cassandra/utils/btree/NodeBuilder.java      | 24 ++++---
 .../apache/cassandra/utils/LongBTreeTest.java   | 73 ++++++++++++++++----
 .../org/apache/cassandra/utils/BTreeTest.java   | 62 ++++++++++++++++-
 5 files changed, 139 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b43d4/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 7f56274,11dd6bd..580307a
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,9 -1,5 +1,10 @@@
 +3.0
 + * Remove CQL2 (CASSANDRA-5918)
 + * add Thrift get_multi_slice call (CASSANDRA-6757)
 +
 +
  2.1.0-beta2
+  * Fix BTree.clear for large updates (CASSANDRA-6943)
   * Fail write instead of logging a warning when unable to append to CL
     (CASSANDRA-6764)
   * Eliminate possibility of CL segment appearing twice in active list 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b43d4/test/long/org/apache/cassandra/utils/LongBTreeTest.java
----------------------------------------------------------------------
diff --cc test/long/org/apache/cassandra/utils/LongBTreeTest.java
index 498a9c9,76ff2bf..eb75671
--- a/test/long/org/apache/cassandra/utils/LongBTreeTest.java
+++ b/test/long/org/apache/cassandra/utils/LongBTreeTest.java
@@@ -18,23 -18,15 +18,28 @@@
   */
  package org.apache.cassandra.utils;
  
--import java.util.*;
++import java.util.ArrayList;
++import java.util.Arrays;
++import java.util.Comparator;
++import java.util.Iterator;
++import java.util.List;
++import java.util.NavigableMap;
++import java.util.NavigableSet;
++import java.util.Random;
++import java.util.TreeMap;
++import java.util.TreeSet;
  import java.util.concurrent.Callable;
 +import java.util.concurrent.CountDownLatch;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
- import java.util.concurrent.Semaphore;
 +import java.util.concurrent.ThreadLocalRandom;
  import java.util.concurrent.TimeUnit;
 +import java.util.concurrent.atomic.AtomicLong;
  
--import javax.annotation.Nullable;
--
 +import com.google.common.base.Function;
 +import com.google.common.base.Predicate;
 +import com.google.common.collect.Iterables;
- import com.google.common.collect.Iterators;
  import com.google.common.util.concurrent.Futures;
  import com.google.common.util.concurrent.ListenableFuture;
  import com.google.common.util.concurrent.ListenableFutureTask;
@@@ -411,43 -367,35 +426,73 @@@ public class LongBTreeTes
          };
      }
  
 +    private static Object[] randomTree(int maxSize, Random random)
 +    {
 +        TreeSet<Integer> build = new TreeSet<>();
 +        int size = random.nextInt(maxSize);
 +        for (int i = 0 ; i < size ; i++)
 +        {
 +            build.add(random.nextInt());
 +        }
 +        return BTree.build(build, ICMP, true, UpdateFunction.NoOp.<Integer>instance());
 +    }
 +
 +    private static Iterable<Integer> randomSelection(Object[] iter, final Random rnd)
 +    {
 +        final float proportion = rnd.nextFloat();
 +        return Iterables.filter(new BTreeSet<>(iter, ICMP), new Predicate<Integer>()
 +        {
-             public boolean apply(@Nullable Integer integer)
++            public boolean apply(Integer integer)
 +            {
 +                return rnd.nextFloat() < proportion;
 +            }
 +        });
 +    }
 +
 +    private static Iterable<Integer> randomMix(Object[] iter, final Random rnd)
 +    {
 +        final float proportion = rnd.nextFloat();
 +        return Iterables.transform(new BTreeSet<>(iter, ICMP), new Function<Integer, Integer>()
 +        {
 +            int last = Integer.MIN_VALUE;
 +
 +            public Integer apply(Integer v)
 +            {
 +                if (rnd.nextFloat() < proportion)
 +                    return last = v;
 +                return last = (v - last) / 2;
 +            }
 +        });
 +    }
 +
+     private static final class RandomAbort<V> implements UpdateFunction<V>
+     {
+         final Random rnd;
+         final float chance;
+         private RandomAbort(Random rnd, float chance)
+         {
+             this.rnd = rnd;
+             this.chance = chance;
+         }
+ 
+         public V apply(V replacing, V update)
+         {
+             return update;
+         }
+ 
+         public boolean abortEarly()
+         {
+             return rnd.nextFloat() < chance;
+         }
+ 
+         public void allocated(long heapSize)
+         {
+ 
+         }
+ 
+         public V apply(V v)
+         {
+             return v;
+         }
+     }
 -
  }