cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blam...@apache.org
Subject [07/13] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0
Date Fri, 18 Nov 2016 10:56:17 GMT
http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb41380c/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
index 26d53ed,4a1f2ca..436b916
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
@@@ -86,17 -98,16 +86,17 @@@ public class CompactionsPurgeTes
          String cfName = "Standard1";
          ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
  
 -        DecoratedKey key = Util.dk("key1");
 -        Mutation rm;
 +        String key = "key1";
  
          // inserts
 -        rm = new Mutation(KEYSPACE1, key.getKey());
          for (int i = 0; i < 10; i++)
          {
 -            rm.add(cfName, cellname(String.valueOf(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
 +            RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
 +            builder.clustering(String.valueOf(i))
-                     .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
-                     .build().applyUnsafe();
++                   .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++                   .build().applyUnsafe();
          }
 -        rm.applyUnsafe();
 +
          cfs.forceBlockingFlush();
  
          // deletes
@@@ -107,19 -120,148 +107,149 @@@
          cfs.forceBlockingFlush();
  
          // resurrect one column
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.add(cfName, cellname(String.valueOf(5)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
 -        rm.applyUnsafe();
 +        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 2, key);
 +        builder.clustering(String.valueOf(5))
-                 .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
-                 .build().applyUnsafe();
++               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++               .build().applyUnsafe();
 +
          cfs.forceBlockingFlush();
  
          // major compact and test that all columns but the resurrected one is completely
gone
          FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE,
false));
 -        cfs.invalidateCachedRow(key);
 -        ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
 -        assertColumns(cf, "5");
 -        assertNotNull(cf.getColumn(cellname(String.valueOf(5))));
 +        cfs.invalidateCachedPartition(dk(key));
++
++        ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs,
key).build());
++        assertEquals(1, partition.rowCount());
+     }
+ 
+     @Test
+     public void testMajorCompactionPurgeTombstonesWithMaxTimestamp()
+     {
+         CompactionManager.instance.disableAutoCompaction();
+ 
+         Keyspace keyspace = Keyspace.open(KEYSPACE1);
+         String cfName = "Standard1";
+         ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+ 
 -        DecoratedKey key = Util.dk("key1");
 -        Mutation rm;
++        String key = "key1";
+ 
+         // inserts
 -        rm = new Mutation(KEYSPACE1, key.getKey());
+         for (int i = 0; i < 10; i++)
+         {
 -            rm.add(cfName, cellname(String.valueOf(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
++            RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
++            builder.clustering(String.valueOf(i))
++                   .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++                   .build().applyUnsafe();
+         }
 -        rm.apply();
+         cfs.forceBlockingFlush();
+ 
+         // deletes
+         for (int i = 0; i < 10; i++)
+         {
 -            rm = new Mutation(KEYSPACE1, key.getKey());
 -            rm.delete(cfName, cellname(String.valueOf(i)), Long.MAX_VALUE);
 -            rm.apply();
++            RowUpdateBuilder.deleteRow(cfs.metadata, Long.MAX_VALUE, key, String.valueOf(i)).applyUnsafe();
+         }
+         cfs.forceBlockingFlush();
+ 
+         // major compact - tombstones should be purged
+         FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE,
false));
+ 
+         // resurrect one column
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.add(cfName, cellname(String.valueOf(5)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
 -        rm.apply();
++        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 2, key);
++        builder.clustering(String.valueOf(5))
++               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++               .build().applyUnsafe();
++
+         cfs.forceBlockingFlush();
+ 
 -        cfs.invalidateCachedRow(key);
 -        ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
 -        assertColumns(cf, "5");
 -        assert cf.getColumn(cellname(String.valueOf(5))) != null;
++        cfs.invalidateCachedPartition(dk(key));
++
++        ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs,
key).build());
++        assertEquals(1, partition.rowCount());
+     }
+ 
+     @Test
+     public void testMajorCompactionPurgeTopLevelTombstoneWithMaxTimestamp()
+     {
+         CompactionManager.instance.disableAutoCompaction();
+ 
+         Keyspace keyspace = Keyspace.open(KEYSPACE1);
+         String cfName = "Standard1";
+         ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+ 
 -        DecoratedKey key = Util.dk("key1");
 -        Mutation rm;
++        String key = "key1";
+ 
+         // inserts
 -        rm = new Mutation(KEYSPACE1, key.getKey());
+         for (int i = 0; i < 10; i++)
+         {
 -            rm.add(cfName, cellname(String.valueOf(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
++            RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
++            builder.clustering(String.valueOf(i))
++                   .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++                   .build().applyUnsafe();
+         }
 -        rm.apply();
+         cfs.forceBlockingFlush();
+ 
 -        // delete
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.delete(cfName, Long.MAX_VALUE);
 -        rm.apply();
 -
++        new Mutation(KEYSPACE1, dk(key))
++            .add(PartitionUpdate.fullPartitionDelete(cfs.metadata, dk(key), Long.MAX_VALUE,
FBUtilities.nowInSeconds()))
++            .applyUnsafe();
+         cfs.forceBlockingFlush();
+ 
 -        // major compact - tombstone should be purged
++        // major compact - tombstones should be purged
+         FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE,
false));
+ 
+         // resurrect one column
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.add(cfName, cellname(String.valueOf(5)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
 -        rm.apply();
++        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 2, key);
++        builder.clustering(String.valueOf(5))
++               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++               .build().applyUnsafe();
++
+         cfs.forceBlockingFlush();
+ 
 -        cfs.invalidateCachedRow(key);
 -        ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
 -        assertColumns(cf, "5");
 -        assert cf.getColumn(cellname(String.valueOf(5))) != null;
++        cfs.invalidateCachedPartition(dk(key));
++
++        ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs,
key).build());
++        assertEquals(1, partition.rowCount());
+     }
+ 
+     @Test
+     public void testMajorCompactionPurgeRangeTombstoneWithMaxTimestamp()
+     {
+         CompactionManager.instance.disableAutoCompaction();
+ 
+         Keyspace keyspace = Keyspace.open(KEYSPACE1);
+         String cfName = "Standard1";
+         ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+ 
 -        DecoratedKey key = Util.dk("key1");
 -        Mutation rm;
++        String key = "key1";
+ 
+         // inserts
 -        rm = new Mutation(KEYSPACE1, key.getKey());
+         for (int i = 0; i < 10; i++)
+         {
 -            rm.add(cfName, cellname(String.valueOf(i)), ByteBufferUtil.EMPTY_BYTE_BUFFER,
0);
++            RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 0, key);
++            builder.clustering(String.valueOf(i))
++                   .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++                   .build().applyUnsafe();
+         }
 -        rm.apply();
+         cfs.forceBlockingFlush();
+ 
 -        // delete
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.deleteRange(cfName, cellname(String.valueOf(0)), cellname(String.valueOf(9)),
Long.MAX_VALUE);
 -        rm.apply();
 -
++        new RowUpdateBuilder(cfs.metadata, Long.MAX_VALUE, dk(key))
++            .addRangeTombstone(String.valueOf(0), String.valueOf(9)).build().applyUnsafe();
+         cfs.forceBlockingFlush();
+ 
 -        // major compact - tombstone should be purged
++        // major compact - tombstones should be purged
+         FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE,
false));
+ 
+         // resurrect one column
 -        rm = new Mutation(KEYSPACE1, key.getKey());
 -        rm.add(cfName, cellname(String.valueOf(5)), ByteBufferUtil.EMPTY_BYTE_BUFFER, 2);
 -        rm.apply();
++        RowUpdateBuilder builder = new RowUpdateBuilder(cfs.metadata, 2, key);
++        builder.clustering(String.valueOf(5))
++               .add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER)
++               .build().applyUnsafe();
++
+         cfs.forceBlockingFlush();
+ 
 -        cfs.invalidateCachedRow(key);
 -        ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
 -        assertColumns(cf, "5");
 -        assert cf.getColumn(cellname(String.valueOf(5))) != null;
++        cfs.invalidateCachedPartition(dk(key));
 +
 +        ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs,
key).build());
 +        assertEquals(1, partition.rowCount());
      }
  
      @Test


Mime
View raw message