cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1148029 - in /cassandra/trunk: src/java/org/apache/cassandra/io/sstable/SSTableReader.java src/java/org/apache/cassandra/streaming/IncomingStreamReader.java test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Date Mon, 18 Jul 2011 19:56:33 GMT
Author: jbellis
Date: Mon Jul 18 19:56:32 2011
New Revision: 1148029

URL: http://svn.apache.org/viewvc?rev=1148029&view=rev
Log:
ensure that we never estimate 0 keys when streaming non-empty ranges
patch by Stu Hood; reviewed by jbellis for CASSANDRA-2916

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
    cassandra/trunk/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
    cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=1148029&r1=1148028&r2=1148029&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java Mon Jul 18
19:56:32 2011
@@ -393,7 +393,7 @@ public class SSTableReader extends SSTab
         List<Pair<Integer, Integer>> sampleIndexes = getSampleIndexesForRanges(indexSummary.getIndexPositions(),
ranges);
         for (Pair<Integer, Integer> sampleIndexRange : sampleIndexes)
             sampleKeyCount += (sampleIndexRange.right - sampleIndexRange.left + 1);
-        return sampleKeyCount * DatabaseDescriptor.getIndexInterval();
+        return Math.max(1, sampleKeyCount * DatabaseDescriptor.getIndexInterval());
     }
 
     /**
@@ -444,7 +444,7 @@ public class SSTableReader extends SSTab
                     right--;
             }
 
-            if (left >= right)
+            if (left > right)
                 // empty range
                 continue;
             positions.add(new Pair(Integer.valueOf(left), Integer.valueOf(right)));

Modified: cassandra/trunk/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java?rev=1148029&r1=1148028&r2=1148029&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java Mon
Jul 18 19:56:32 2011
@@ -82,7 +82,9 @@ public class IncomingStreamReader
         if (logger.isDebugEnabled())
         {
             logger.debug("Receiving stream");
-            logger.debug("Creating file for {}", localFile.getFilename());
+            logger.debug("Creating file for {} with {} estimated keys",
+                         localFile.getFilename(),
+                         remoteFile.estimatedKeys);
         }
 
         SSTableReader reader = null;

Modified: cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1148029&r1=1148028&r2=1148029&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java Mon
Jul 18 19:56:32 2011
@@ -66,9 +66,10 @@ public class StreamingTransferTest exten
         for (int i = 1; i <= 3; i++)
         {
             String key = "key" + i;
+            String col = "col" + i;
             RowMutation rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes(key));
             ColumnFamily cf = ColumnFamily.create(table.name, cfs.columnFamily);
-            cf.addColumn(column(key, "v", 0));
+            cf.addColumn(column(col, "v", 0));
             cf.addColumn(new Column(ByteBufferUtil.bytes("birthdate"), ByteBufferUtil.bytes((long)
i), 0));
             rm.add(cf);
             rm.apply();
@@ -94,7 +95,7 @@ public class StreamingTransferTest exten
         assert rows.get(1).key.key.equals( ByteBufferUtil.bytes("key3"));
         assertEquals(2, rows.get(0).cf.getColumnsMap().size());
         assertEquals(2, rows.get(1).cf.getColumnsMap().size());
-        assert rows.get(1).cf.getColumn(ByteBufferUtil.bytes("key3")) != null;
+        assert rows.get(1).cf.getColumn(ByteBufferUtil.bytes("col3")) != null;
 
         // and that the index and filter were properly recovered
         assert null != cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key1"),
new QueryPath(cfs.columnFamily)));



Mime
View raw message