cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [5/6] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0
Date Wed, 30 Oct 2013 19:11:48 GMT
Merge branch 'cassandra-1.2' into cassandra-2.0

Conflicts:
	src/java/org/apache/cassandra/io/sstable/SSTableReader.java
	test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java


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

Branch: refs/heads/cassandra-2.0
Commit: 89911c82ac7bddb32ccac4adc224c764d87b5cf3
Parents: 4169aa3 18f7935
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Wed Oct 30 14:09:47 2013 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Wed Oct 30 14:09:47 2013 -0500

----------------------------------------------------------------------
 .../cassandra/io/sstable/SSTableReaderTest.java | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/89911c82/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
index eeb22e6,fef27f1..8a9619d
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
@@@ -26,9 -27,10 +26,11 @@@ import java.nio.ByteBuffer
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
+ import java.util.Set;
  import java.util.concurrent.ExecutionException;
  
 +import org.junit.Assert;
+ import com.google.common.collect.Sets;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
@@@ -284,25 -317,40 +286,60 @@@ public class SSTableReaderTest extends 
          assert reopened.first.token instanceof LocalToken;
      }
  
 +    /** see CASSANDRA-5407 */
 +    @Test
 +    public void testGetScannerForNoIntersectingRanges()
 +    {
 +        Keyspace keyspace = Keyspace.open("Keyspace1");
 +        ColumnFamilyStore store = keyspace.getColumnFamilyStore("Standard1");
 +        ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("k1"));
 +        RowMutation rm = new RowMutation("Keyspace1", key);
 +        rm.add("Standard1", ByteBufferUtil.bytes("xyz"), ByteBufferUtil.bytes("abc"), 0);
 +        rm.apply();
 +        store.forceBlockingFlush();
 +        boolean foundScanner = false;
 +        for (SSTableReader s : store.getSSTables())
 +        {
 +            ICompactionScanner scanner = s.getScanner(new Range<Token>(t(0), t(1),
s.partitioner), null);
 +            scanner.next(); // throws exception pre 5407
 +            foundScanner = true;
 +        }
 +        assertTrue(foundScanner);
++
+     @Test
+     public void testGetPositionsForRangesFromTableOpenedForBulkLoading() throws IOException,
ExecutionException, InterruptedException
+     {
+         Table table = Table.open("Keyspace1");
+         ColumnFamilyStore store = table.getColumnFamilyStore("Standard2");
+ 
+         // insert data and compact to a single sstable. The
+         // number of keys inserted is greater than index_interval
+         // to ensure multiple segments in the index file
+         CompactionManager.instance.disableAutoCompaction();
+         for (int j = 0; j < 130; j++)
+         {
+             ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j));
+             RowMutation rm = new RowMutation("Keyspace1", key);
+             rm.add(new QueryPath("Standard2", null, ByteBufferUtil.bytes("0")), ByteBufferUtil.EMPTY_BYTE_BUFFER,
j);
+             rm.apply();
+         }
+         store.forceBlockingFlush();
+         CompactionManager.instance.performMaximal(store);
+ 
+         // construct a range which is present in the sstable, but whose
+         // keys are not found in the first segment of the index.
+         List<Range<Token>> ranges = new ArrayList<Range<Token>>();
+         ranges.add(new Range<Token>(t(98), t(99)));
+ 
+         SSTableReader sstable = store.getSSTables().iterator().next();
+         List<Pair<Long,Long>> sections = sstable.getPositionsForRanges(ranges);
+         assert sections.size() == 1 : "Expected to find range in sstable" ;
+ 
+         // re-open the same sstable as it would be during bulk loading
+         Set<Component> components = Sets.newHashSet(Component.DATA, Component.PRIMARY_INDEX);
+         SSTableReader bulkLoaded = SSTableReader.openForBatch(sstable.descriptor, components,
sstable.partitioner);
+         sections = bulkLoaded.getPositionsForRanges(ranges);
+         assert sections.size() == 1 : "Expected to find range in sstable opened for bulk
loading";
      }
  
      private void assertIndexQueryWorks(ColumnFamilyStore indexedCFS) throws IOException


Mime
View raw message