cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject cassandra git commit: Cleanup of generics in bounds serialization
Date Tue, 10 Mar 2015 17:23:15 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 05a6f2667 -> 69542a99c


Cleanup of generics in bounds serialization

Patch by blambov; reviewed by jmckenzie for CASSANDRA-8375


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

Branch: refs/heads/trunk
Commit: 69542a99c670bd5619e3b3c271512635dc7f9b76
Parents: 05a6f26
Author: Branimir Lambov <branimir.lambov@datastax.com>
Authored: Tue Mar 10 12:18:05 2015 -0500
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Tue Mar 10 12:21:00 2015 -0500

----------------------------------------------------------------------
 .../apache/cassandra/db/ColumnFamilyStore.java  |  2 +-
 src/java/org/apache/cassandra/db/DataRange.java | 15 ++--
 .../apache/cassandra/db/PagedRangeCommand.java  |  7 +-
 .../apache/cassandra/db/RangeSliceCommand.java  |  6 +-
 .../cassandra/db/SizeEstimatesRecorder.java     |  2 +-
 .../apache/cassandra/dht/AbstractBounds.java    | 90 +++++++-------------
 src/java/org/apache/cassandra/dht/Bounds.java   | 12 ---
 .../apache/cassandra/dht/ExcludingBounds.java   | 21 -----
 .../cassandra/dht/IncludingExcludingBounds.java | 21 -----
 src/java/org/apache/cassandra/dht/Range.java    | 20 ++---
 .../io/sstable/format/SSTableReader.java        |  2 +-
 .../apache/cassandra/repair/RepairJobDesc.java  |  6 +-
 .../repair/messages/AnticompactionRequest.java  |  8 +-
 .../repair/messages/PrepareMessage.java         |  8 +-
 .../cassandra/repair/messages/SyncRequest.java  |  6 +-
 .../cassandra/service/StorageService.java       | 10 +--
 .../cassandra/streaming/StreamSession.java      |  2 +-
 test/unit/org/apache/cassandra/Util.java        |  2 +-
 .../apache/cassandra/db/SerializationsTest.java |  2 +-
 .../db/compaction/CompactionsTest.java          |  4 +-
 .../locator/OldNetworkTopologyStrategyTest.java | 48 ++++++-----
 21 files changed, 107 insertions(+), 187 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 467ec01..4795b88 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1869,7 +1869,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
      */
     private AbstractScanIterator getSequentialIterator(final DataRange range, long now)
     {
-        assert !(range.keyRange() instanceof Range) || !((Range)range.keyRange()).isWrapAround()
|| range.keyRange().right.isMinimum() : range.keyRange();
+        assert !(range.keyRange() instanceof Range) || !((Range<?>)range.keyRange()).isWrapAround()
|| range.keyRange().right.isMinimum() : range.keyRange();
 
         final ViewFragment view = select(viewFilter(range.keyRange()));
         Tracing.trace("Executing seq scan across {} sstables for {}", view.sstables.size(),
range.keyRange().getString(metadata.getKeyValidator()));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/db/DataRange.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DataRange.java b/src/java/org/apache/cassandra/db/DataRange.java
index dd4fbe8..d93e1dd 100644
--- a/src/java/org/apache/cassandra/db/DataRange.java
+++ b/src/java/org/apache/cassandra/db/DataRange.java
@@ -65,12 +65,17 @@ public class DataRange
 
     public static DataRange allData(IPartitioner partitioner)
     {
-        return forKeyRange(new Range<Token>(partitioner.getMinimumToken(), partitioner.getMinimumToken()));
+        return forTokenRange(new Range<Token>(partitioner.getMinimumToken(), partitioner.getMinimumToken()));
     }
 
-    public static DataRange forKeyRange(Range<Token> keyRange)
+    public static DataRange forTokenRange(Range<Token> keyRange)
     {
-        return new DataRange(keyRange.toRowBounds(), new IdentityQueryFilter());
+        return forKeyRange(Range.makeRowRange(keyRange));
+    }
+
+    public static DataRange forKeyRange(Range<RowPosition> keyRange)
+    {
+        return new DataRange(keyRange, new IdentityQueryFilter());
     }
 
     public AbstractBounds<RowPosition> keyRange()
@@ -104,7 +109,7 @@ public class DataRange
     public boolean isWrapAround()
     {
         // On range can ever wrap
-        return keyRange instanceof Range && ((Range)keyRange).isWrapAround();
+        return keyRange instanceof Range && ((Range<?>)keyRange).isWrapAround();
     }
 
     public boolean contains(RowPosition pos)
@@ -160,7 +165,7 @@ public class DataRange
 
             // When using a paging range, we don't allow wrapped ranges, as it's unclear
how to handle them properly.
             // This is ok for now since we only need this in range slice queries, and the
range are "unwrapped" in that case.
-            assert !(range instanceof Range) || !((Range)range).isWrapAround() || range.right.isMinimum()
: range;
+            assert !(range instanceof Range) || !((Range<?>)range).isWrapAround() ||
range.right.isMinimum() : range;
 
             this.sliceFilter = filter;
             this.comparator = comparator;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/db/PagedRangeCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/PagedRangeCommand.java b/src/java/org/apache/cassandra/db/PagedRangeCommand.java
index ebedecf..ab988f1 100644
--- a/src/java/org/apache/cassandra/db/PagedRangeCommand.java
+++ b/src/java/org/apache/cassandra/db/PagedRangeCommand.java
@@ -130,7 +130,7 @@ public class PagedRangeCommand extends AbstractRangeCommand
             out.writeLong(cmd.timestamp);
 
             MessagingService.validatePartitioner(cmd.keyRange);
-            AbstractBounds.serializer.serialize(cmd.keyRange, out, version);
+            AbstractBounds.rowPositionSerializer.serialize(cmd.keyRange, out, version);
 
             CFMetaData metadata = Schema.instance.getCFMetaData(cmd.keyspace, cmd.columnFamily);
 
@@ -159,7 +159,8 @@ public class PagedRangeCommand extends AbstractRangeCommand
             String columnFamily = in.readUTF();
             long timestamp = in.readLong();
 
-            AbstractBounds<RowPosition> keyRange = AbstractBounds.serializer.deserialize(in,
MessagingService.globalPartitioner(), version).toRowBounds();
+            AbstractBounds<RowPosition> keyRange =
+                    AbstractBounds.rowPositionSerializer.deserialize(in, MessagingService.globalPartitioner(),
version);
 
             CFMetaData metadata = Schema.instance.getCFMetaData(keyspace, columnFamily);
 
@@ -190,7 +191,7 @@ public class PagedRangeCommand extends AbstractRangeCommand
             size += TypeSizes.NATIVE.sizeof(cmd.columnFamily);
             size += TypeSizes.NATIVE.sizeof(cmd.timestamp);
 
-            size += AbstractBounds.serializer.serializedSize(cmd.keyRange, version);
+            size += AbstractBounds.rowPositionSerializer.serializedSize(cmd.keyRange, version);
 
             CFMetaData metadata = Schema.instance.getCFMetaData(cmd.keyspace, cmd.columnFamily);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/db/RangeSliceCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeSliceCommand.java b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
index 6009524..ce6e386 100644
--- a/src/java/org/apache/cassandra/db/RangeSliceCommand.java
+++ b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
@@ -173,7 +173,7 @@ class RangeSliceCommandSerializer implements IVersionedSerializer<RangeSliceComm
             }
         }
         MessagingService.validatePartitioner(sliceCommand.keyRange);
-        AbstractBounds.serializer.serialize(sliceCommand.keyRange, out, version);
+        AbstractBounds.rowPositionSerializer.serialize(sliceCommand.keyRange, out, version);
         out.writeInt(sliceCommand.maxResults);
         out.writeBoolean(sliceCommand.countCQL3Rows);
         out.writeBoolean(sliceCommand.isPaging);
@@ -196,7 +196,7 @@ class RangeSliceCommandSerializer implements IVersionedSerializer<RangeSliceComm
         {
             rowFilter.add(IndexExpression.readFrom(in));
         }
-        AbstractBounds<RowPosition> range = AbstractBounds.serializer.deserialize(in,
MessagingService.globalPartitioner(), version).toRowBounds();
+        AbstractBounds<RowPosition> range = AbstractBounds.rowPositionSerializer.deserialize(in,
MessagingService.globalPartitioner(), version);
 
         int maxResults = in.readInt();
         boolean countCQL3Rows = in.readBoolean();
@@ -230,7 +230,7 @@ class RangeSliceCommandSerializer implements IVersionedSerializer<RangeSliceComm
                 size += TypeSizes.NATIVE.sizeofWithShortLength(expr.value);
             }
         }
-        size += AbstractBounds.serializer.serializedSize(rsc.keyRange, version);
+        size += AbstractBounds.rowPositionSerializer.serializedSize(rsc.keyRange, version);
         size += TypeSizes.NATIVE.sizeof(rsc.maxResults);
         size += TypeSizes.NATIVE.sizeof(rsc.countCQL3Rows);
         size += TypeSizes.NATIVE.sizeof(rsc.isPaging);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java b/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
index e45154f..69ae810 100644
--- a/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
+++ b/src/java/org/apache/cassandra/db/SizeEstimatesRecorder.java
@@ -86,7 +86,7 @@ public class SizeEstimatesRecorder extends MigrationListener implements
Runnable
             Refs<SSTableReader> refs = null;
             while (refs == null)
             {
-                ColumnFamilyStore.ViewFragment view = table.select(table.viewFilter(range.toRowBounds()));
+                ColumnFamilyStore.ViewFragment view = table.select(table.viewFilter(Range.makeRowRange(range)));
                 refs = Refs.tryRef(view.sstables);
             }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/dht/AbstractBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractBounds.java b/src/java/org/apache/cassandra/dht/AbstractBounds.java
index f045acf..2424034 100644
--- a/src/java/org/apache/cassandra/dht/AbstractBounds.java
+++ b/src/java/org/apache/cassandra/dht/AbstractBounds.java
@@ -32,7 +32,10 @@ import org.apache.cassandra.utils.Pair;
 public abstract class AbstractBounds<T extends RingPosition<T>> implements Serializable
 {
     private static final long serialVersionUID = 1L;
-    public static final AbstractBoundsSerializer serializer = new AbstractBoundsSerializer();
+    public static final IPartitionerDependentSerializer<AbstractBounds<Token>>
tokenSerializer =
+            new AbstractBoundsSerializer<Token>(Token.serializer);
+    public static final IPartitionerDependentSerializer<AbstractBounds<RowPosition>>
rowPositionSerializer =
+            new AbstractBoundsSerializer<RowPosition>(RowPosition.serializer);
 
     private enum Type
     {
@@ -107,42 +110,13 @@ public abstract class AbstractBounds<T extends RingPosition<T>>
implements Seria
     protected abstract String getOpeningString();
     protected abstract String getClosingString();
 
-    /**
-     * Transform this abstract bounds to equivalent covering bounds of row positions.
-     * If this abstract bounds was already an abstractBounds of row positions, this is a
noop.
-     */
-    public abstract AbstractBounds<RowPosition> toRowBounds();
-
-    /**
-     * Transform this abstract bounds to a token abstract bounds.
-     * If this abstract bounds was already an abstractBounds of token, this is a noop, otherwise
this use the row position tokens.
-     */
-    public abstract AbstractBounds<Token> toTokenBounds();
-
     public abstract AbstractBounds<T> withNewRight(T newRight);
 
-    public static class AbstractBoundsSerializer implements IPartitionerDependentSerializer<AbstractBounds<?>>
+    public static class AbstractBoundsSerializer<T extends RingPosition<T>> implements
IPartitionerDependentSerializer<AbstractBounds<T>>
     {
-        public void serialize(AbstractBounds<?> range, DataOutputPlus out, int version)
throws IOException
-        {
-            /*
-             * The first int tells us if it's a range or bounds (depending on the value)
_and_ if it's tokens or keys (depending on the
-             * sign). We use negative kind for keys so as to preserve the serialization of
token from older version.
-             */
-            out.writeInt(kindInt(range));
-            if (range.left instanceof Token)
-            {
-                Token.serializer.serialize((Token) range.left, out, version);
-                Token.serializer.serialize((Token) range.right, out, version);
-            }
-            else
-            {
-                RowPosition.serializer.serialize((RowPosition) range.left, out, version);
-                RowPosition.serializer.serialize((RowPosition) range.right, out, version);
-            }
-        }
+        IPartitionerDependentSerializer<T> serializer;
 
-        private int kindInt(AbstractBounds<?> ab)
+        private static int kindInt(AbstractBounds<?> ab)
         {
             int kind = ab instanceof Range ? Type.RANGE.ordinal() : Type.BOUNDS.ordinal();
             if (!(ab.left instanceof Token))
@@ -150,43 +124,43 @@ public abstract class AbstractBounds<T extends RingPosition<T>>
implements Seria
             return kind;
         }
 
-        public AbstractBounds<?> deserialize(DataInput in, IPartitioner p, int version)
throws IOException
+        public AbstractBoundsSerializer(IPartitionerDependentSerializer<T> serializer)
+        {
+            this.serializer = serializer;
+        }
+
+        public void serialize(AbstractBounds<T> range, DataOutputPlus out, int version)
throws IOException
+        {
+            /*
+             * The first int tells us if it's a range or bounds (depending on the value)
_and_ if it's tokens or keys (depending on the
+             * sign). We use negative kind for keys so as to preserve the serialization of
token from older version.
+             */
+            out.writeInt(kindInt(range));
+            serializer.serialize(range.left, out, version);
+            serializer.serialize(range.right, out, version);
+        }
+
+        public AbstractBounds<T> deserialize(DataInput in, IPartitioner p, int version)
throws IOException
         {
             int kind = in.readInt();
             boolean isToken = kind >= 0;
             if (!isToken)
                 kind = -(kind+1);
 
-            RingPosition<?> left, right;
-            if (isToken)
-            {
-                left = Token.serializer.deserialize(in, p, version);
-                right = Token.serializer.deserialize(in, p, version);
-            }
-            else
-            {
-                left = RowPosition.serializer.deserialize(in, p, version);
-                right = RowPosition.serializer.deserialize(in, p, version);
-            }
+            T left = serializer.deserialize(in, p, version);
+            T right = serializer.deserialize(in, p, version);
+            assert isToken == left instanceof Token;
 
             if (kind == Type.RANGE.ordinal())
-                return new Range(left, right);
-            return new Bounds(left, right);
+                return new Range<T>(left, right);
+            return new Bounds<T>(left, right);
         }
 
-        public long serializedSize(AbstractBounds<?> ab, int version)
+        public long serializedSize(AbstractBounds<T> ab, int version)
         {
             int size = TypeSizes.NATIVE.sizeof(kindInt(ab));
-            if (ab.left instanceof Token)
-            {
-                size += Token.serializer.serializedSize((Token) ab.left, version);
-                size += Token.serializer.serializedSize((Token) ab.right, version);
-            }
-            else
-            {
-                size += RowPosition.serializer.serializedSize((RowPosition) ab.left, version);
-                size += RowPosition.serializer.serializedSize((RowPosition) ab.right, version);
-            }
+            size += serializer.serializedSize(ab.left, version);
+            size += serializer.serializedSize(ab.right, version);
             return size;
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/dht/Bounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Bounds.java b/src/java/org/apache/cassandra/dht/Bounds.java
index 8f87553..fd2ff88 100644
--- a/src/java/org/apache/cassandra/dht/Bounds.java
+++ b/src/java/org/apache/cassandra/dht/Bounds.java
@@ -100,18 +100,6 @@ public class Bounds<T extends RingPosition<T>> extends AbstractBounds<T>
         return new Bounds<RowPosition>(left.minKeyBound(), right.maxKeyBound());
     }
 
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<RowPosition> toRowBounds()
-    {
-        return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right) : (Bounds<RowPosition>)this;
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<Token> toTokenBounds()
-    {
-        return (left instanceof RowPosition) ? new Bounds<Token>(((RowPosition)left).getToken(),
((RowPosition)right).getToken()) : (Bounds<Token>)this;
-    }
-
     public AbstractBounds<T> withNewRight(T newRight)
     {
         return new Bounds<T>(left, newRight);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/dht/ExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/ExcludingBounds.java b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
index 8a89d14..13e4e28 100644
--- a/src/java/org/apache/cassandra/dht/ExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.dht;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.cassandra.db.RowPosition;
 import org.apache.cassandra.utils.Pair;
 
 /**
@@ -81,26 +80,6 @@ public class ExcludingBounds<T extends RingPosition<T>> extends
AbstractBounds<T
         return ")";
     }
 
-    /**
-     * Compute a bounds of keys corresponding to a given bounds of token.
-     */
-    private static ExcludingBounds<RowPosition> makeRowBounds(Token left, Token right)
-    {
-        return new ExcludingBounds<RowPosition>(left.maxKeyBound(), right.minKeyBound());
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<RowPosition> toRowBounds()
-    {
-        return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right) : (ExcludingBounds<RowPosition>)this;
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<Token> toTokenBounds()
-    {
-        return (left instanceof RowPosition) ? new ExcludingBounds<Token>(((RowPosition)left).getToken(),
((RowPosition)right).getToken()) : (ExcludingBounds<Token>)this;
-    }
-
     public AbstractBounds<T> withNewRight(T newRight)
     {
         return new ExcludingBounds<T>(left, newRight);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
index e9801ca..b4448ba 100644
--- a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.dht;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.cassandra.db.RowPosition;
 import org.apache.cassandra.utils.Pair;
 
 /**
@@ -80,26 +79,6 @@ public class IncludingExcludingBounds<T extends RingPosition<T>>
extends Abstrac
         return ")";
     }
 
-    /**
-     * Compute a bounds of keys corresponding to a given bounds of token.
-     */
-    private static IncludingExcludingBounds<RowPosition> makeRowBounds(Token left,
Token right)
-    {
-        return new IncludingExcludingBounds<RowPosition>(left.maxKeyBound(), right.minKeyBound());
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<RowPosition> toRowBounds()
-    {
-        return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right) : (IncludingExcludingBounds<RowPosition>)this;
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<Token> toTokenBounds()
-    {
-        return (left instanceof RowPosition) ? new IncludingExcludingBounds<Token>(((RowPosition)left).getToken(),
((RowPosition)right).getToken()) : (IncludingExcludingBounds<Token>)this;
-    }
-
     public AbstractBounds<T> withNewRight(T newRight)
     {
         return new IncludingExcludingBounds<T>(left, newRight);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/dht/Range.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Range.java b/src/java/org/apache/cassandra/dht/Range.java
index 7ab328f..224deac 100644
--- a/src/java/org/apache/cassandra/dht/Range.java
+++ b/src/java/org/apache/cassandra/dht/Range.java
@@ -447,6 +447,10 @@ public class Range<T extends RingPosition<T>> extends AbstractBounds<T>
implemen
         return output;
     }
 
+    public AbstractBounds<T> withNewRight(T newRight)
+    {
+        return new Range<T>(left, newRight);
+    }
 
     /**
      * Compute a range of keys corresponding to a given range of token.
@@ -456,20 +460,8 @@ public class Range<T extends RingPosition<T>> extends AbstractBounds<T>
implemen
         return new Range<RowPosition>(left.maxKeyBound(), right.maxKeyBound());
     }
 
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<RowPosition> toRowBounds()
-    {
-        return (left instanceof Token) ? makeRowRange((Token)left, (Token)right) : (Range<RowPosition>)this;
-    }
-
-    @SuppressWarnings("unchecked")
-    public AbstractBounds<Token> toTokenBounds()
-    {
-        return (left instanceof RowPosition) ? new Range<Token>(((RowPosition)left).getToken(),
((RowPosition)right).getToken()) : (Range<Token>)this;
-    }
-
-    public AbstractBounds<T> withNewRight(T newRight)
+    public static Range<RowPosition> makeRowRange(Range<Token> tokenBounds)
     {
-        return new Range<T>(left, newRight);
+        return makeRowRange(tokenBounds.left, tokenBounds.right);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index 9b32933..e296f35 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -1249,7 +1249,7 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
         {
             assert !range.isWrapAround() || range.right.isMinimum();
             // truncate the range so it at most covers the sstable
-            AbstractBounds<RowPosition> bounds = range.toRowBounds();
+            AbstractBounds<RowPosition> bounds = Range.makeRowRange(range);
             RowPosition leftBound = bounds.left.compareTo(first) > 0 ? bounds.left : first.getToken().minKeyBound();
             RowPosition rightBound = bounds.right.isMinimum() ? last.getToken().maxKeyBound()
: bounds.right;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/repair/RepairJobDesc.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/RepairJobDesc.java b/src/java/org/apache/cassandra/repair/RepairJobDesc.java
index c4a713d..8382136 100644
--- a/src/java/org/apache/cassandra/repair/RepairJobDesc.java
+++ b/src/java/org/apache/cassandra/repair/RepairJobDesc.java
@@ -101,7 +101,7 @@ public class RepairJobDesc
             out.writeUTF(desc.keyspace);
             out.writeUTF(desc.columnFamily);
             MessagingService.validatePartitioner(desc.range);
-            AbstractBounds.serializer.serialize(desc.range, out, version);
+            AbstractBounds.tokenSerializer.serialize(desc.range, out, version);
         }
 
         public RepairJobDesc deserialize(DataInput in, int version) throws IOException
@@ -115,7 +115,7 @@ public class RepairJobDesc
             UUID sessionId = UUIDSerializer.serializer.deserialize(in, version);
             String keyspace = in.readUTF();
             String columnFamily = in.readUTF();
-            Range<Token> range = (Range<Token>)AbstractBounds.serializer.deserialize(in,
MessagingService.globalPartitioner(), version).toTokenBounds();
+            Range<Token> range = (Range<Token>)AbstractBounds.tokenSerializer.deserialize(in,
MessagingService.globalPartitioner(), version);
             return new RepairJobDesc(parentSessionId, sessionId, keyspace, columnFamily,
range);
         }
 
@@ -131,7 +131,7 @@ public class RepairJobDesc
             size += UUIDSerializer.serializer.serializedSize(desc.sessionId, version);
             size += TypeSizes.NATIVE.sizeof(desc.keyspace);
             size += TypeSizes.NATIVE.sizeof(desc.columnFamily);
-            size += AbstractBounds.serializer.serializedSize(desc.range, version);
+            size += AbstractBounds.tokenSerializer.serializedSize(desc.range, version);
             return size;
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/repair/messages/AnticompactionRequest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/messages/AnticompactionRequest.java b/src/java/org/apache/cassandra/repair/messages/AnticompactionRequest.java
index 455e5fb..b554500 100644
--- a/src/java/org/apache/cassandra/repair/messages/AnticompactionRequest.java
+++ b/src/java/org/apache/cassandra/repair/messages/AnticompactionRequest.java
@@ -55,7 +55,7 @@ public class AnticompactionRequest extends RepairMessage
             for (Range<Token> r : message.successfulRanges)
             {
                 MessagingService.validatePartitioner(r);
-                Range.serializer.serialize(r, out, version);
+                Range.tokenSerializer.serialize(r, out, version);
             }
         }
 
@@ -65,7 +65,7 @@ public class AnticompactionRequest extends RepairMessage
             int rangeCount = in.readInt();
             List<Range<Token>> ranges = new ArrayList<>(rangeCount);
             for (int i = 0; i < rangeCount; i++)
-                ranges.add((Range<Token>) Range.serializer.deserialize(in, MessagingService.globalPartitioner(),
version).toTokenBounds());
+                ranges.add((Range<Token>) Range.tokenSerializer.deserialize(in, MessagingService.globalPartitioner(),
version));
             return new AnticompactionRequest(parentRepairSession, ranges);
         }
 
@@ -73,7 +73,7 @@ public class AnticompactionRequest extends RepairMessage
         {
             long size = UUIDSerializer.serializer.serializedSize(message.parentRepairSession,
version);
             for (Range<Token> r : message.successfulRanges)
-                size += Range.serializer.serializedSize(r, version);
+                size += Range.tokenSerializer.serializedSize(r, version);
             return size;
         }
     }
@@ -85,4 +85,4 @@ public class AnticompactionRequest extends RepairMessage
                 "parentRepairSession=" + parentRepairSession +
                 "} " + super.toString();
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/repair/messages/PrepareMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/messages/PrepareMessage.java b/src/java/org/apache/cassandra/repair/messages/PrepareMessage.java
index d63bf70..37dc07c 100644
--- a/src/java/org/apache/cassandra/repair/messages/PrepareMessage.java
+++ b/src/java/org/apache/cassandra/repair/messages/PrepareMessage.java
@@ -62,7 +62,7 @@ public class PrepareMessage extends RepairMessage
             for (Range<Token> r : message.ranges)
             {
                 MessagingService.validatePartitioner(r);
-                Range.serializer.serialize(r, out, version);
+                Range.tokenSerializer.serialize(r, out, version);
             }
             out.writeBoolean(message.isIncremental);
         }
@@ -77,7 +77,7 @@ public class PrepareMessage extends RepairMessage
             int rangeCount = in.readInt();
             List<Range<Token>> ranges = new ArrayList<>(rangeCount);
             for (int i = 0; i < rangeCount; i++)
-                ranges.add((Range<Token>) Range.serializer.deserialize(in, MessagingService.globalPartitioner(),
version).toTokenBounds());
+                ranges.add((Range<Token>) Range.tokenSerializer.deserialize(in, MessagingService.globalPartitioner(),
version));
             boolean isIncremental = in.readBoolean();
             return new PrepareMessage(parentRepairSession, cfIds, ranges, isIncremental);
         }
@@ -91,8 +91,8 @@ public class PrepareMessage extends RepairMessage
                 size += UUIDSerializer.serializer.serializedSize(cfId, version);
             size += UUIDSerializer.serializer.serializedSize(message.parentRepairSession,
version);
             size += sizes.sizeof(message.ranges.size());
-            for (Range r : message.ranges)
-                size += Range.serializer.serializedSize(r, version);
+            for (Range<Token> r : message.ranges)
+                size += Range.tokenSerializer.serializedSize(r, version);
             size += sizes.sizeof(message.isIncremental);
             return size;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/repair/messages/SyncRequest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/messages/SyncRequest.java b/src/java/org/apache/cassandra/repair/messages/SyncRequest.java
index 077132a..68aaf4d 100644
--- a/src/java/org/apache/cassandra/repair/messages/SyncRequest.java
+++ b/src/java/org/apache/cassandra/repair/messages/SyncRequest.java
@@ -69,7 +69,7 @@ public class SyncRequest extends RepairMessage
             for (Range<Token> range : message.ranges)
             {
                 MessagingService.validatePartitioner(range);
-                AbstractBounds.serializer.serialize(range, out, version);
+                AbstractBounds.tokenSerializer.serialize(range, out, version);
             }
         }
 
@@ -82,7 +82,7 @@ public class SyncRequest extends RepairMessage
             int rangesCount = in.readInt();
             List<Range<Token>> ranges = new ArrayList<>(rangesCount);
             for (int i = 0; i < rangesCount; ++i)
-                ranges.add((Range<Token>) AbstractBounds.serializer.deserialize(in,
MessagingService.globalPartitioner(), version).toTokenBounds());
+                ranges.add((Range<Token>) AbstractBounds.tokenSerializer.deserialize(in,
MessagingService.globalPartitioner(), version));
             return new SyncRequest(desc, owner, src, dst, ranges);
         }
 
@@ -92,7 +92,7 @@ public class SyncRequest extends RepairMessage
             size += 3 * CompactEndpointSerializationHelper.serializedSize(message.initiator);
             size += TypeSizes.NATIVE.sizeof(message.ranges.size());
             for (Range<Token> range : message.ranges)
-                size += AbstractBounds.serializer.serializedSize(range, version);
+                size += AbstractBounds.tokenSerializer.serializedSize(range, version);
             return size;
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 61bd938..f616710 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -1228,7 +1228,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
 
         for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
         {
-            Range range = entry.getKey();
+            Range<Token> range = entry.getKey();
             List<InetAddress> addresses = entry.getValue();
             List<String> endpoints = new ArrayList<>(addresses.size());
             List<String> rpc_endpoints = new ArrayList<>(addresses.size());
@@ -4006,10 +4006,10 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
         Set<Range<Token>> toFetch  = new HashSet<>();
 
 
-        for (Range r1 : current)
+        for (Range<Token> r1 : current)
         {
             boolean intersect = false;
-            for (Range r2 : updated)
+            for (Range<Token> r2 : updated)
             {
                 if (r1.intersects(r2))
                 {
@@ -4024,10 +4024,10 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
             }
         }
 
-        for (Range r2 : updated)
+        for (Range<Token> r2 : updated)
         {
             boolean intersect = false;
-            for (Range r1 : current)
+            for (Range<Token> r1 : current)
             {
                 if (r2.intersects(r1))
                 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/src/java/org/apache/cassandra/streaming/StreamSession.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamSession.java b/src/java/org/apache/cassandra/streaming/StreamSession.java
index 15b9aa9..1b529ed 100644
--- a/src/java/org/apache/cassandra/streaming/StreamSession.java
+++ b/src/java/org/apache/cassandra/streaming/StreamSession.java
@@ -307,7 +307,7 @@ public class StreamSession implements IEndpointStateChangeSubscriber
             {
                 List<AbstractBounds<RowPosition>> rowBoundsList = new ArrayList<>(ranges.size());
                 for (Range<Token> range : ranges)
-                    rowBoundsList.add(range.toRowBounds());
+                    rowBoundsList.add(Range.makeRowRange(range));
                 refs.addAll(cfStore.selectAndReference(cfStore.viewFilter(rowBoundsList)).refs);
             }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/test/unit/org/apache/cassandra/Util.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/Util.java b/test/unit/org/apache/cassandra/Util.java
index 24e334a..a171d3c 100644
--- a/test/unit/org/apache/cassandra/Util.java
+++ b/test/unit/org/apache/cassandra/Util.java
@@ -181,7 +181,7 @@ public class Util
                                : new SliceQueryFilter(SuperColumns.startOf(superColumn),
SuperColumns.endOf(superColumn), false, Integer.MAX_VALUE);
 
         Token min = StorageService.getPartitioner().getMinimumToken();
-        return cfs.getRangeSlice(new Bounds<Token>(min, min).toRowBounds(), null, filter,
10000);
+        return cfs.getRangeSlice(Bounds.makeRowBounds(min, min), null, filter, 10000);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/test/unit/org/apache/cassandra/db/SerializationsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SerializationsTest.java b/test/unit/org/apache/cassandra/db/SerializationsTest.java
index a50bbae..a720608 100644
--- a/test/unit/org/apache/cassandra/db/SerializationsTest.java
+++ b/test/unit/org/apache/cassandra/db/SerializationsTest.java
@@ -77,7 +77,7 @@ public class SerializationsTest extends AbstractSerializationsTester
     private void testRangeSliceCommandWrite() throws IOException
     {
         IPartitioner part = StorageService.getPartitioner();
-        AbstractBounds<RowPosition> bounds = new Range<Token>(part.getRandomToken(),
part.getRandomToken()).toRowBounds();
+        AbstractBounds<RowPosition> bounds = Range.makeRowRange(part.getRandomToken(),
part.getRandomToken());
 
         RangeSliceCommand namesCmd = new RangeSliceCommand(statics.KS, "Standard1", statics.readTs,
namesPred, bounds, 100);
         MessageOut<RangeSliceCommand> namesCmdMsg = namesCmd.createMessage();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
index 0016261..3c34bf3 100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
@@ -19,10 +19,8 @@
 package org.apache.cassandra.db.compaction;
 
 import java.io.File;
-import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.*;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.cassandra.OrderedJUnit4ClassRunner;
@@ -188,7 +186,7 @@ public class CompactionsTest
 
         // check that the shadowed column is gone
         SSTableReader sstable = cfs.getSSTables().iterator().next();
-        Range keyRange = new Range<RowPosition>(key, sstable.partitioner.getMinimumToken().maxKeyBound());
+        Range<RowPosition> keyRange = new Range<RowPosition>(key, sstable.partitioner.getMinimumToken().maxKeyBound());
         ISSTableScanner scanner = sstable.getScanner(DataRange.forKeyRange(keyRange));
         OnDiskAtomIterator iter = scanner.next();
         assertEquals(key, iter.getKey());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/69542a99/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java b/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java
index b854e18..eceb847 100644
--- a/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java
+++ b/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java
@@ -37,6 +37,7 @@ import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.Pair;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -202,6 +203,7 @@ public class OldNetworkTopologyStrategyTest
 
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void testMoveMiddleOfRing() throws UnknownHostException
     {
@@ -215,25 +217,26 @@ public class OldNetworkTopologyStrategyTest
         Pair<Set<Range<Token>>, Set<Range<Token>>> ranges =
calculateStreamAndFetchRanges(tokens, tokensAfterMove, movingNodeIdx);
 
         // sort the results, so they can be compared
-        Range[] toStream = ranges.left.toArray(new Range[0]);
-        Range[] toFetch = ranges.right.toArray(new Range[0]);
+        Range<Token>[] toStream = ranges.left.toArray(new Range[0]);
+        Range<Token>[] toFetch = ranges.right.toArray(new Range[0]);
         Arrays.sort(toStream);
         Arrays.sort(toFetch);
 
         // build expected ranges
-        Range[] toStreamExpected = new Range[2];
-        toStreamExpected[0] = new Range(getToken(movingNodeIdx - 2, tokens), getToken(movingNodeIdx
- 1, tokens));
-        toStreamExpected[1] = new Range(getToken(movingNodeIdx - 1, tokens), getToken(movingNodeIdx,
tokens));
+        Range<Token>[] toStreamExpected = new Range[2];
+        toStreamExpected[0] = new Range<Token>(getToken(movingNodeIdx - 2, tokens),
getToken(movingNodeIdx - 1, tokens));
+        toStreamExpected[1] = new Range<Token>(getToken(movingNodeIdx - 1, tokens),
getToken(movingNodeIdx, tokens));
         Arrays.sort(toStreamExpected);
-        Range[] toFetchExpected = new Range[2];
-        toFetchExpected[0] = new Range(getToken(movingNodeIdxAfterMove - 1, tokens), getToken(movingNodeIdxAfterMove,
tokens));
-        toFetchExpected[1] = new Range(getToken(movingNodeIdxAfterMove, tokensAfterMove),
getToken(movingNodeIdx, tokensAfterMove));
+        Range<Token>[] toFetchExpected = new Range[2];
+        toFetchExpected[0] = new Range<Token>(getToken(movingNodeIdxAfterMove - 1,
tokens), getToken(movingNodeIdxAfterMove, tokens));
+        toFetchExpected[1] = new Range<Token>(getToken(movingNodeIdxAfterMove, tokensAfterMove),
getToken(movingNodeIdx, tokensAfterMove));
         Arrays.sort(toFetchExpected);
 
         assertEquals(Arrays.equals(toStream, toStreamExpected), true);
         assertEquals(Arrays.equals(toFetch, toFetchExpected), true);
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void testMoveAfterNextNeighbors() throws UnknownHostException
     {
@@ -248,24 +251,25 @@ public class OldNetworkTopologyStrategyTest
 
 
         // sort the results, so they can be compared
-        Range[] toStream = ranges.left.toArray(new Range[0]);
-        Range[] toFetch = ranges.right.toArray(new Range[0]);
+        Range<Token>[] toStream = ranges.left.toArray(new Range[0]);
+        Range<Token>[] toFetch = ranges.right.toArray(new Range[0]);
         Arrays.sort(toStream);
         Arrays.sort(toFetch);
 
         // build expected ranges
-        Range[] toStreamExpected = new Range[1];
-        toStreamExpected[0] = new Range(getToken(movingNodeIdx - 2, tokens), getToken(movingNodeIdx
- 1, tokens));
+        Range<Token>[] toStreamExpected = new Range[1];
+        toStreamExpected[0] = new Range<Token>(getToken(movingNodeIdx - 2, tokens),
getToken(movingNodeIdx - 1, tokens));
         Arrays.sort(toStreamExpected);
-        Range[] toFetchExpected = new Range[2];
-        toFetchExpected[0] = new Range(getToken(movingNodeIdxAfterMove - 1, tokens), getToken(movingNodeIdxAfterMove,
tokens));
-        toFetchExpected[1] = new Range(getToken(movingNodeIdxAfterMove, tokensAfterMove),
getToken(movingNodeIdx, tokensAfterMove));
+        Range<Token>[] toFetchExpected = new Range[2];
+        toFetchExpected[0] = new Range<Token>(getToken(movingNodeIdxAfterMove - 1,
tokens), getToken(movingNodeIdxAfterMove, tokens));
+        toFetchExpected[1] = new Range<Token>(getToken(movingNodeIdxAfterMove, tokensAfterMove),
getToken(movingNodeIdx, tokensAfterMove));
         Arrays.sort(toFetchExpected);
 
         assertEquals(Arrays.equals(toStream, toStreamExpected), true);
         assertEquals(Arrays.equals(toFetch, toFetchExpected), true);
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void testMoveBeforePreviousNeighbor() throws UnknownHostException
     {
@@ -278,17 +282,17 @@ public class OldNetworkTopologyStrategyTest
         BigIntegerToken[] tokensAfterMove = initTokensAfterMove(tokens, movingNodeIdx, newToken);
         Pair<Set<Range<Token>>, Set<Range<Token>>> ranges =
calculateStreamAndFetchRanges(tokens, tokensAfterMove, movingNodeIdx);
 
-        Range[] toStream = ranges.left.toArray(new Range[0]);
-        Range[] toFetch = ranges.right.toArray(new Range[0]);
+        Range<Token>[] toStream = ranges.left.toArray(new Range[0]);
+        Range<Token>[] toFetch = ranges.right.toArray(new Range[0]);
         Arrays.sort(toStream);
         Arrays.sort(toFetch);
 
-        Range[] toStreamExpected = new Range[2];
-        toStreamExpected[0] = new Range(getToken(movingNodeIdx, tokensAfterMove), getToken(movingNodeIdx
- 1, tokensAfterMove));
-        toStreamExpected[1] = new Range(getToken(movingNodeIdx - 1, tokens), getToken(movingNodeIdx,
tokens));
+        Range<Token>[] toStreamExpected = new Range[2];
+        toStreamExpected[0] = new Range<Token>(getToken(movingNodeIdx, tokensAfterMove),
getToken(movingNodeIdx - 1, tokensAfterMove));
+        toStreamExpected[1] = new Range<Token>(getToken(movingNodeIdx - 1, tokens),
getToken(movingNodeIdx, tokens));
         Arrays.sort(toStreamExpected);
-        Range[] toFetchExpected = new Range[1];
-        toFetchExpected[0] = new Range(getToken(movingNodeIdxAfterMove - 1, tokens), getToken(movingNodeIdxAfterMove,
tokens));
+        Range<Token>[] toFetchExpected = new Range[1];
+        toFetchExpected[0] = new Range<Token>(getToken(movingNodeIdxAfterMove - 1,
tokens), getToken(movingNodeIdxAfterMove, tokens));
         Arrays.sort(toFetchExpected);
 
         System.out.println("toStream : " + Arrays.toString(toStream));


Mime
View raw message