cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/4] Removed compatibility with pre-1.2.5 sstables and network messages patch by jbellis; reviewed by marcuse for CASSANDRA-5511
Date Fri, 26 Apr 2013 19:07:02 GMT
Updated Branches:
  refs/heads/trunk a45918b08 -> 7f2c3a8e4


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f2c3a8e/test/unit/org/apache/cassandra/utils/LegacyBloomFilterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/LegacyBloomFilterTest.java b/test/unit/org/apache/cassandra/utils/LegacyBloomFilterTest.java
deleted file mode 100644
index e7319db..0000000
--- a/test/unit/org/apache/cassandra/utils/LegacyBloomFilterTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*    http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.cassandra.utils;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import org.apache.cassandra.io.util.DataOutputBuffer;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class LegacyBloomFilterTest
-{
-    public LegacyBloomFilter bf;
-
-    public LegacyBloomFilterTest()
-    {
-        bf = LegacyBloomFilter.getFilter(FilterTestHelper.ELEMENTS, FilterTestHelper.MAX_FAILURE_RATE);
-    }
-
-    public static IFilter testSerialize(LegacyBloomFilter f) throws IOException
-    {
-        f.add(ByteBufferUtil.bytes("a"));
-        DataOutputBuffer out = new DataOutputBuffer();
-        FilterFactory.serialize(f, out, FilterFactory.Type.SHA);
-
-        ByteArrayInputStream in = new ByteArrayInputStream(out.getData(), 0, out.getLength());
-        LegacyBloomFilter f2 = (LegacyBloomFilter) FilterFactory.deserialize(new DataInputStream(in),
FilterFactory.Type.SHA, false);
-
-        assert f2.isPresent(ByteBufferUtil.bytes("a"));
-        assert !f2.isPresent(ByteBufferUtil.bytes("b"));
-        return f2;
-    }
-
-
-    @Before
-    public void clear()
-    {
-        bf.clear();
-    }
-
-    @Test(expected=UnsupportedOperationException.class)
-    public void testBloomLimits1()
-    {
-        int maxBuckets = BloomCalculations.probs.length - 1;
-        int maxK = BloomCalculations.probs[maxBuckets].length - 1;
-
-        // possible
-        BloomCalculations.computeBloomSpec(maxBuckets, BloomCalculations.probs[maxBuckets][maxK]);
-
-        // impossible, throws
-        BloomCalculations.computeBloomSpec(maxBuckets, BloomCalculations.probs[maxBuckets][maxK]
/ 2);
-    }
-
-    @Test
-    public void testOne()
-    {
-        bf.add(ByteBufferUtil.bytes("a"));
-        assert bf.isPresent(ByteBufferUtil.bytes("a"));
-        assert !bf.isPresent(ByteBufferUtil.bytes("b"));
-    }
-
-    @Test
-    public void testFalsePositivesInt()
-    {
-        FilterTestHelper.testFalsePositives(bf, FilterTestHelper.intKeys(), FilterTestHelper.randomKeys2());
-    }
-
-    @Test
-    public void testFalsePositivesRandom()
-    {
-        FilterTestHelper.testFalsePositives(bf, FilterTestHelper.randomKeys(), FilterTestHelper.randomKeys2());
-    }
-
-    @Test
-    public void testWords()
-    {
-        if (KeyGenerator.WordGenerator.WORDS == 0)
-        {
-            return;
-        }
-        LegacyBloomFilter bf2 = LegacyBloomFilter.getFilter(KeyGenerator.WordGenerator.WORDS
/ 2, FilterTestHelper.MAX_FAILURE_RATE);
-        int skipEven = KeyGenerator.WordGenerator.WORDS % 2 == 0 ? 0 : 2;
-        FilterTestHelper.testFalsePositives(bf2,
-                                      new KeyGenerator.WordGenerator(skipEven, 2),
-                                      new KeyGenerator.WordGenerator(1, 2));
-    }
-
-    public void testManyHashes(Iterator<ByteBuffer> keys)
-    {
-        int MAX_HASH_COUNT = 128;
-        Set<Integer> hashes = new HashSet<Integer>();
-        int collisions = 0;
-        while (keys.hasNext())
-        {
-            hashes.clear();
-            for (int hashIndex : LegacyBloomFilter.getHashBuckets(keys.next(), MAX_HASH_COUNT,
1024 * 1024))
-            {
-                hashes.add(hashIndex);
-            }
-            collisions += (MAX_HASH_COUNT - hashes.size());
-        }
-        assert collisions <= 100;
-    }
-
-    @Test
-    public void testManyRandom()
-    {
-        testManyHashes(FilterTestHelper.randomKeys());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f2c3a8e/test/unit/org/apache/cassandra/utils/SerializationsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/SerializationsTest.java b/test/unit/org/apache/cassandra/utils/SerializationsTest.java
index 1a1e9fb..f2112c2 100644
--- a/test/unit/org/apache/cassandra/utils/SerializationsTest.java
+++ b/test/unit/org/apache/cassandra/utils/SerializationsTest.java
@@ -20,74 +20,34 @@ package org.apache.cassandra.utils;
 
 import org.apache.cassandra.AbstractSerializationsTester;
 import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.utils.FilterFactory.Type;
+
 import org.junit.Test;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.nio.ByteBuffer;
 
 public class SerializationsTest extends AbstractSerializationsTester
 {
 
-    private void testBloomFilterWrite(Type murmur, boolean offheap) throws IOException
+    private void testBloomFilterWrite(boolean offheap) throws IOException
     {
-        IFilter bf = FilterFactory.getFilter(1000000, 0.0001, murmur, offheap);
+        IFilter bf = FilterFactory.getFilter(1000000, 0.0001, offheap);
         for (int i = 0; i < 100; i++)
             bf.add(StorageService.getPartitioner().getTokenFactory().toByteArray(StorageService.getPartitioner().getRandomToken()));
         DataOutputStream out = getOutput("utils.BloomFilter.bin");
-        FilterFactory.serialize(bf, out, murmur);
+        FilterFactory.serialize(bf, out);
         out.close();
     }
 
     @Test
-    public void testBloomFilterReadMURMUR2() throws IOException
-    {
-        if (EXECUTE_WRITES)
-            testBloomFilterWrite(FilterFactory.Type.MURMUR2, false);
-
-        DataInputStream in = getInput("utils.BloomFilter.bin");
-        assert FilterFactory.deserialize(in, FilterFactory.Type.MURMUR2, false) != null;
-        in.close();
-    }
-
-    @Test
     public void testBloomFilterReadMURMUR3() throws IOException
     {
         if (EXECUTE_WRITES)
-            testBloomFilterWrite(FilterFactory.Type.MURMUR3, true);
+            testBloomFilterWrite(true);
 
         DataInputStream in = getInput("utils.BloomFilter.bin");
-        assert FilterFactory.deserialize(in, FilterFactory.Type.MURMUR3, true) != null;
-        in.close();
-    }
-
-    private void testLegacyBloomFilterWrite() throws IOException
-    {
-        LegacyBloomFilter a = LegacyBloomFilter.getFilter(1000000, 1000);
-        LegacyBloomFilter b = LegacyBloomFilter.getFilter(1000000, 0.0001);
-        for (int i = 0; i < 100; i++)
-        {
-            ByteBuffer key = StorageService.getPartitioner().getTokenFactory().toByteArray(StorageService.getPartitioner().getRandomToken());
-            a.add(key);
-            b.add(key);
-        }
-        DataOutputStream out = getOutput("utils.LegacyBloomFilter.bin");
-        FilterFactory.serialize(a, out, FilterFactory.Type.SHA);
-        FilterFactory.serialize(b, out, FilterFactory.Type.SHA);
-        out.close();
-    }
-
-    @Test
-    public void testLegacyBloomFilterRead() throws IOException
-    {
-        // We never write out a new LBF.  Copy the data file from 0.7 instead.
-        // if (EXECUTE_WRITES)
-        //      testLegacyBloomFilterWrite();
-        
-        DataInputStream in = getInput("utils.LegacyBloomFilter.bin");
-        assert FilterFactory.deserialize(in, FilterFactory.Type.SHA, false) != null;
+        assert FilterFactory.deserialize(in, true) != null;
         in.close();
     }
 


Mime
View raw message