cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [10/11] cassandra git commit: Extend native protocol request flags, add versions to SUPPORTED, and introduce ProtocolVersion enum
Date Mon, 31 Oct 2016 13:38:27 GMT
Extend native protocol request flags, add versions to SUPPORTED, and introduce ProtocolVersion enum

patch by Stefania Alborghetti; reviewed by Benjamin Lerer for CASSANDRA-12838


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

Branch: refs/heads/trunk
Commit: e0adc166a33033c9d2668547803a1e034c2c2494
Parents: 0a1f1c8
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue Oct 25 16:01:40 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Mon Oct 31 21:14:42 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 doc/native_protocol_v5.spec                     |  13 +-
 ...driver-internal-only-3.7.0.post0-2481531.zip | Bin 0 -> 252057 bytes
 ...driver-internal-only-3.7.0.post0-70f41b5.zip | Bin 252036 -> 0 bytes
 .../org/apache/cassandra/cql3/CQL3Type.java     |  20 +--
 .../apache/cassandra/cql3/ColumnCondition.java  |  14 +-
 .../org/apache/cassandra/cql3/Constants.java    |   3 +-
 src/java/org/apache/cassandra/cql3/Lists.java   |   8 +-
 src/java/org/apache/cassandra/cql3/Maps.java    |   8 +-
 .../org/apache/cassandra/cql3/QueryOptions.java |  46 +++---
 .../apache/cassandra/cql3/QueryProcessor.java   |   5 +-
 .../org/apache/cassandra/cql3/ResultSet.java    |  61 ++++++--
 src/java/org/apache/cassandra/cql3/Sets.java    |   8 +-
 src/java/org/apache/cassandra/cql3/Term.java    |   3 +-
 src/java/org/apache/cassandra/cql3/Tuples.java  |   5 +-
 .../apache/cassandra/cql3/UntypedResultSet.java |   4 +-
 .../org/apache/cassandra/cql3/UserTypes.java    |   3 +-
 .../cassandra/cql3/functions/AggregateFcts.java |  81 +++++-----
 .../cql3/functions/AggregateFunction.java       |   8 +-
 .../cql3/functions/BytesConversionFcts.java     |   9 +-
 .../cassandra/cql3/functions/CastFcts.java      |   8 +-
 .../cassandra/cql3/functions/FromJsonFct.java   |   3 +-
 .../cassandra/cql3/functions/FunctionCall.java  |   5 +-
 .../cql3/functions/JavaBasedUDFunction.java     |   5 +-
 .../cassandra/cql3/functions/JavaUDF.java       |  23 +--
 .../cql3/functions/ScalarFunction.java          |   3 +-
 .../cql3/functions/ScriptBasedUDFunction.java   |   7 +-
 .../cassandra/cql3/functions/TimeFcts.java      |  25 +--
 .../cassandra/cql3/functions/ToJsonFct.java     |   3 +-
 .../cassandra/cql3/functions/TokenFct.java      |   3 +-
 .../cassandra/cql3/functions/UDAggregate.java   |   5 +-
 .../cql3/functions/UDFByteCodeVerifier.java     |   8 +-
 .../cassandra/cql3/functions/UDFunction.java    |  28 ++--
 .../cassandra/cql3/functions/UDHelper.java      |  15 +-
 .../cassandra/cql3/functions/UuidFcts.java      |   3 +-
 .../selection/AggregateFunctionSelector.java    |   5 +-
 .../cassandra/cql3/selection/FieldSelector.java |   5 +-
 .../cql3/selection/ScalarFunctionSelector.java  |   5 +-
 .../cassandra/cql3/selection/Selection.java     |  18 ++-
 .../cassandra/cql3/selection/Selector.java      |   5 +-
 .../cql3/selection/SimpleSelector.java          |   5 +-
 .../cassandra/cql3/selection/TermSelector.java  |   5 +-
 .../cql3/selection/WritetimeOrTTLSelector.java  |   5 +-
 .../statements/CreateAggregateStatement.java    |   4 +-
 .../cql3/statements/SelectStatement.java        |   5 +-
 .../cassandra/db/PartitionRangeReadCommand.java |   3 +-
 src/java/org/apache/cassandra/db/ReadQuery.java |   5 +-
 .../db/SinglePartitionReadCommand.java          |   7 +-
 .../org/apache/cassandra/db/SystemKeyspace.java |   4 +-
 .../db/marshal/AbstractCompositeType.java       |   3 +-
 .../cassandra/db/marshal/AbstractType.java      |   3 +-
 .../apache/cassandra/db/marshal/AsciiType.java  |   3 +-
 .../cassandra/db/marshal/BooleanType.java       |   3 +-
 .../apache/cassandra/db/marshal/ByteType.java   |   3 +-
 .../apache/cassandra/db/marshal/BytesType.java  |   3 +-
 .../cassandra/db/marshal/CollectionType.java    |   3 +-
 .../db/marshal/ColumnToCollectionType.java      |   3 +-
 .../cassandra/db/marshal/CounterColumnType.java |   3 +-
 .../apache/cassandra/db/marshal/DateType.java   |   3 +-
 .../cassandra/db/marshal/DecimalType.java       |   3 +-
 .../apache/cassandra/db/marshal/DoubleType.java |   3 +-
 .../cassandra/db/marshal/DurationType.java      |   3 +-
 .../db/marshal/DynamicCompositeType.java        |   3 +-
 .../apache/cassandra/db/marshal/FloatType.java  |   3 +-
 .../apache/cassandra/db/marshal/FrozenType.java |   3 +-
 .../cassandra/db/marshal/InetAddressType.java   |   3 +-
 .../apache/cassandra/db/marshal/Int32Type.java  |   3 +-
 .../cassandra/db/marshal/IntegerType.java       |   3 +-
 .../apache/cassandra/db/marshal/ListType.java   |  13 +-
 .../apache/cassandra/db/marshal/LongType.java   |   3 +-
 .../apache/cassandra/db/marshal/MapType.java    |   6 +-
 .../db/marshal/PartitionerDefinedOrder.java     |   3 +-
 .../cassandra/db/marshal/ReversedType.java      |   3 +-
 .../apache/cassandra/db/marshal/SetType.java    |   3 +-
 .../apache/cassandra/db/marshal/ShortType.java  |   3 +-
 .../cassandra/db/marshal/SimpleDateType.java    |   3 +-
 .../apache/cassandra/db/marshal/TimeType.java   |   3 +-
 .../cassandra/db/marshal/TimestampType.java     |   3 +-
 .../apache/cassandra/db/marshal/TupleType.java  |   3 +-
 .../apache/cassandra/db/marshal/UTF8Type.java   |   3 +-
 .../apache/cassandra/db/marshal/UserType.java   |   5 +-
 .../apache/cassandra/schema/SchemaKeyspace.java |   4 +-
 .../serializers/CollectionSerializer.java       |  26 ++--
 .../cassandra/serializers/ListSerializer.java   |  10 +-
 .../cassandra/serializers/MapSerializer.java    |  12 +-
 .../cassandra/serializers/SetSerializer.java    |   6 +-
 .../cassandra/service/StorageService.java       |   5 +-
 .../service/pager/AbstractQueryPager.java       |   5 +-
 .../service/pager/MultiPartitionPager.java      |   3 +-
 .../cassandra/service/pager/PagingState.java    |  24 +--
 .../service/pager/PartitionRangeQueryPager.java |   5 +-
 .../cassandra/service/pager/QueryPagers.java    |   4 +-
 .../service/pager/SinglePartitionPager.java     |   5 +-
 .../org/apache/cassandra/transport/CBCodec.java |   6 +-
 .../org/apache/cassandra/transport/CBUtil.java  |   8 +-
 .../org/apache/cassandra/transport/Client.java  |   6 +-
 .../apache/cassandra/transport/Connection.java  |   8 +-
 .../apache/cassandra/transport/DataType.java    |  80 +++++-----
 .../org/apache/cassandra/transport/Event.java   |  58 +++----
 .../org/apache/cassandra/transport/Frame.java   |  42 ++---
 .../org/apache/cassandra/transport/Message.java |  23 +--
 .../apache/cassandra/transport/OptionCodec.java |  26 ++--
 .../cassandra/transport/ProtocolException.java  |  17 +--
 .../cassandra/transport/ProtocolVersion.java    | 153 +++++++++++++++++++
 .../org/apache/cassandra/transport/Server.java  |   9 +-
 .../cassandra/transport/ServerConnection.java   |   6 +-
 .../cassandra/transport/SimpleClient.java       |  14 +-
 .../transport/messages/AuthChallenge.java       |   7 +-
 .../transport/messages/AuthResponse.java        |   8 +-
 .../transport/messages/AuthSuccess.java         |   7 +-
 .../transport/messages/AuthenticateMessage.java |   7 +-
 .../transport/messages/BatchMessage.java        |  10 +-
 .../transport/messages/CredentialsMessage.java  |   9 +-
 .../transport/messages/ErrorMessage.java        |  26 ++--
 .../transport/messages/EventMessage.java        |   7 +-
 .../transport/messages/ExecuteMessage.java      |  10 +-
 .../transport/messages/OptionsMessage.java      |   8 +-
 .../transport/messages/PrepareMessage.java      |   6 +-
 .../transport/messages/QueryMessage.java        |  11 +-
 .../transport/messages/ReadyMessage.java        |   7 +-
 .../transport/messages/RegisterMessage.java     |   8 +-
 .../transport/messages/ResultMessage.java       |  42 ++---
 .../transport/messages/StartupMessage.java      |   9 +-
 .../transport/messages/SupportedMessage.java    |   7 +-
 .../cassandra/cql3/functions/JavaSourceUDF.txt  |   5 +-
 .../org/apache/cassandra/cql3/ViewLongTest.java |   3 +-
 test/unit/org/apache/cassandra/Util.java        |  23 +++
 .../cassandra/cql3/CQL3TypeLiteralTest.java     |  26 ++--
 .../org/apache/cassandra/cql3/CQLTester.java    |  70 +++++----
 .../cassandra/cql3/ViewFilteringTest.java       |   3 +-
 .../apache/cassandra/cql3/ViewSchemaTest.java   |   3 +-
 .../org/apache/cassandra/cql3/ViewTest.java     |   3 +-
 .../cassandra/cql3/functions/TimeFctsTest.java  |   4 +-
 .../validation/entities/UFPureScriptTest.java   |   5 +-
 .../UFPureScriptTupleCollectionTest.java        |   6 +-
 .../cql3/validation/entities/UFTest.java        |  25 +--
 .../entities/udfverify/CallClone.java           |   5 +-
 .../entities/udfverify/CallComDatastax.java     |   5 +-
 .../entities/udfverify/CallFinalize.java        |   5 +-
 .../entities/udfverify/CallOrgApache.java       |   5 +-
 .../entities/udfverify/ClassWithField.java      |   5 +-
 .../udfverify/ClassWithInitializer.java         |   5 +-
 .../udfverify/ClassWithInitializer2.java        |   5 +-
 .../udfverify/ClassWithInitializer3.java        |   5 +-
 .../entities/udfverify/ClassWithInnerClass.java |   5 +-
 .../udfverify/ClassWithInnerClass2.java         |   5 +-
 .../udfverify/ClassWithStaticInitializer.java   |   5 +-
 .../udfverify/ClassWithStaticInnerClass.java    |   5 +-
 .../entities/udfverify/GoodClass.java           |   5 +-
 .../entities/udfverify/UseOfSynchronized.java   |   5 +-
 .../udfverify/UseOfSynchronizedWithNotify.java  |   5 +-
 .../UseOfSynchronizedWithNotifyAll.java         |   5 +-
 .../udfverify/UseOfSynchronizedWithWait.java    |   5 +-
 .../udfverify/UseOfSynchronizedWithWaitL.java   |   5 +-
 .../udfverify/UseOfSynchronizedWithWaitLI.java  |   5 +-
 .../entities/udfverify/UsingMapEntry.java       |   5 +-
 .../validation/operations/AggregationTest.java  |  10 +-
 .../cql3/validation/operations/AlterTest.java   |   6 +-
 .../apache/cassandra/index/CustomIndexTest.java |  24 +--
 .../cassandra/service/ClientWarningsTest.java   |  10 +-
 .../service/ProtocolBetaVersionTest.java        |  40 ++++-
 .../cassandra/service/QueryPagerTest.java       |  58 +++----
 .../service/pager/PagingStateTest.java          |  47 ++----
 .../cassandra/transport/DataTypeTest.java       |  14 +-
 .../cassandra/transport/ErrorMessageTest.java   |   6 +-
 .../cassandra/transport/MessagePayloadTest.java |   2 +-
 .../cassandra/transport/ProtocolErrorTest.java  |  13 +-
 .../transport/ProtocolVersionTest.java          |  97 ++++++++++++
 .../cassandra/transport/SerDeserTest.java       | 138 +++++++++++++----
 .../cassandra/utils/CassandraVersionTest.java   |  14 +-
 170 files changed, 1324 insertions(+), 821 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 82d3d9c..1b16518 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * Extend native protocol request flags, add versions to SUPPORTED, and introduce ProtocolVersion enum (CASSANDRA-12838)
  * Set JOINING mode when running pre-join tasks (CASSANDRA-12836)
  * remove net.mintern.primitive library due to license issue (CASSANDRA-12845)
  * Properly format IPv6 addresses when logging JMX service URL (CASSANDRA-12454)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/doc/native_protocol_v5.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v5.spec b/doc/native_protocol_v5.spec
index bbde714..35dd2d7 100644
--- a/doc/native_protocol_v5.spec
+++ b/doc/native_protocol_v5.spec
@@ -317,7 +317,7 @@ Table of Contents
     <consistency><flags>[<n>[name_1]<value_1>...[name_n]<value_n>][<result_page_size>][<paging_state>][<serial_consistency>][<timestamp>]
   where:
     - <consistency> is the [consistency] level for the operation.
-    - <flags> is a [byte] whose bits define the options for this query and
+    - <flags> is a [int] whose bits define the options for this query and
       in particular influence what the remainder of the message contains.
       A flag is set if the bit corresponding to its `mask` is set. Supported
       flags are, given their mask:
@@ -398,7 +398,7 @@ Table of Contents
         - If <type> == 1, the batch will be "unlogged".
         - If <type> == 2, the batch will be a "counter" batch (and non-counter
           statements will be rejected).
-    - <flags> is a [byte] whose bits define the options for this query and
+    - <flags> is a [int] whose bits define the options for this query and
       in particular influence what the remainder of the message contains. It is similar
       to the <flags> from QUERY and EXECUTE methods, except that the 4 rightmost
       bits must always be 0 as their corresponding options do not make sense for
@@ -514,7 +514,12 @@ Table of Contents
   comes as a response to an OPTIONS message.
 
   The body of a SUPPORTED message is a [string multimap]. This multimap gives
-  for each of the supported STARTUP options, the list of supported values.
+  for each of the supported STARTUP options, the list of supported values. It
+  also includes:
+      - "PROTOCOL_VERSIONS": the list of native protocol versions that are
+      supported, encoded as the version number followed by a slash and the
+      version description. For example: 3/v3, 4/v4, 5/v5-beta. If a version is
+      in beta, it will have the word "beta" in its description.
 
 
 4.2.5. RESULT
@@ -1175,3 +1180,5 @@ Table of Contents
   * <numfailures> in Read_failure and Write_failure error message bodies (Section 9)
     has been replaced with <reasonmap>. The <reasonmap> maps node IP addresses to
     a failure reason code which indicates why the request failed on that node.
+  * Enlarged flag's bitmaps for QUERY, EXECUTE and BATCH messages from [byte] to [int]
+    (Sections 4.1.4, 4.1.6 and 4.1.7).

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip b/lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip
new file mode 100644
index 0000000..11d5944
Binary files /dev/null and b/lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/lib/cassandra-driver-internal-only-3.7.0.post0-70f41b5.zip
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-internal-only-3.7.0.post0-70f41b5.zip b/lib/cassandra-driver-internal-only-3.7.0.post0-70f41b5.zip
deleted file mode 100644
index 4bbe903..0000000
Binary files a/lib/cassandra-driver-internal-only-3.7.0.post0-70f41b5.zip and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/CQL3Type.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/CQL3Type.java b/src/java/org/apache/cassandra/cql3/CQL3Type.java
index 94b8f6d..20f3e2d 100644
--- a/src/java/org/apache/cassandra/cql3/CQL3Type.java
+++ b/src/java/org/apache/cassandra/cql3/CQL3Type.java
@@ -34,6 +34,7 @@ import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.Types;
 import org.apache.cassandra.serializers.CollectionSerializer;
 import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public interface CQL3Type
@@ -54,12 +55,11 @@ public interface CQL3Type
 
     /**
      * Generates CQL literal from a binary value of this type.
-     *
-     * @param buffer the value to convert to a CQL literal. This value must be
+     *  @param buffer the value to convert to a CQL literal. This value must be
      * serialized with {@code version} of the native protocol.
      * @param version the native protocol version in which {@code buffer} is encoded.
      */
-    public String toCQLLiteral(ByteBuffer buffer, int version);
+    public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version);
 
     public enum Native implements CQL3Type
     {
@@ -105,7 +105,7 @@ public interface CQL3Type
          * {@link org.apache.cassandra.serializers.TypeSerializer#toString(Object)}
          * {@link org.apache.cassandra.serializers.TypeSerializer#deserialize(ByteBuffer)} implementations.
          */
-        public String toCQLLiteral(ByteBuffer buffer, int version)
+        public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version)
         {
             return type.getSerializer().toCQLLiteral(buffer);
         }
@@ -136,7 +136,7 @@ public interface CQL3Type
             return type;
         }
 
-        public String toCQLLiteral(ByteBuffer buffer, int version)
+        public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version)
         {
             // *always* use the 'blob' syntax to express custom types in CQL
             return Native.BLOB.toCQLLiteral(buffer, version);
@@ -184,7 +184,7 @@ public interface CQL3Type
             return true;
         }
 
-        public String toCQLLiteral(ByteBuffer buffer, int version)
+        public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version)
         {
             if (buffer == null)
                 return "null";
@@ -216,7 +216,7 @@ public interface CQL3Type
             return target.toString();
         }
 
-        private void generateMapCQLLiteral(ByteBuffer buffer, int version, StringBuilder target, int size)
+        private void generateMapCQLLiteral(ByteBuffer buffer, ProtocolVersion version, StringBuilder target, int size)
         {
             CQL3Type keys = ((MapType) type).getKeysType().asCQL3Type();
             CQL3Type values = ((MapType) type).getValuesType().asCQL3Type();
@@ -232,7 +232,7 @@ public interface CQL3Type
             }
         }
 
-        private static void generateSetOrListCQLLiteral(ByteBuffer buffer, int version, StringBuilder target, int size, CQL3Type elements)
+        private static void generateSetOrListCQLLiteral(ByteBuffer buffer, ProtocolVersion version, StringBuilder target, int size, CQL3Type elements)
         {
             for (int i = 0; i < size; i++)
             {
@@ -316,7 +316,7 @@ public interface CQL3Type
             return type;
         }
 
-        public String toCQLLiteral(ByteBuffer buffer, int version)
+        public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version)
         {
             if (buffer == null)
                 return "null";
@@ -404,7 +404,7 @@ public interface CQL3Type
             return type;
         }
 
-        public String toCQLLiteral(ByteBuffer buffer, int version)
+        public String toCQLLiteral(ByteBuffer buffer, ProtocolVersion version)
         {
             if (buffer == null)
                 return "null";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/ColumnCondition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index 304f8bc..07f9f60 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -28,7 +28,7 @@ import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.rows.*;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
@@ -508,11 +508,11 @@ public class ColumnCondition
             // make sure we use v3 serialization format for comparison
             ByteBuffer conditionValue;
             if (type.kind == CollectionType.Kind.LIST)
-                conditionValue = ((Lists.Value) value).get(Server.VERSION_3);
+                conditionValue = ((Lists.Value) value).get(ProtocolVersion.V3);
             else if (type.kind == CollectionType.Kind.SET)
-                conditionValue = ((Sets.Value) value).get(Server.VERSION_3);
+                conditionValue = ((Sets.Value) value).get(ProtocolVersion.V3);
             else
-                conditionValue = ((Maps.Value) value).get(Server.VERSION_3);
+                conditionValue = ((Maps.Value) value).get(ProtocolVersion.V3);
 
             return compareWithOperator(operator, type, conditionValue, cell.value());
         }
@@ -680,7 +680,7 @@ public class ColumnCondition
                         if (cell == null)
                             return true;
                     }
-                    else if (type.compare(value.get(Server.VERSION_3), cell.value()) == 0)
+                    else if (type.compare(value.get(ProtocolVersion.V3), cell.value()) == 0)
                     {
                         return true;
                     }
@@ -782,7 +782,7 @@ public class ColumnCondition
     static class UDTBound extends Bound
     {
         private final ByteBuffer value;
-        private final int protocolVersion;
+        private final ProtocolVersion protocolVersion;
 
         private UDTBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException
         {
@@ -826,7 +826,7 @@ public class ColumnCondition
     public static class UDTInBound extends Bound
     {
         private final List<ByteBuffer> inValues;
-        private final int protocolVersion;
+        private final ProtocolVersion protocolVersion;
 
         private UDTInBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Constants.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Constants.java b/src/java/org/apache/cassandra/cql3/Constants.java
index c701b71..03e2053 100644
--- a/src/java/org/apache/cassandra/cql3/Constants.java
+++ b/src/java/org/apache/cassandra/cql3/Constants.java
@@ -26,6 +26,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
@@ -312,7 +313,7 @@ public abstract class Constants
             this.bytes = bytes;
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             return bytes;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Lists.java b/src/java/org/apache/cassandra/cql3/Lists.java
index ad0af6d..037162b 100644
--- a/src/java/org/apache/cassandra/cql3/Lists.java
+++ b/src/java/org/apache/cassandra/cql3/Lists.java
@@ -35,7 +35,7 @@ import org.apache.cassandra.db.marshal.ListType;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.CollectionSerializer;
 import org.apache.cassandra.serializers.MarshalException;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.UUIDGen;
 
@@ -141,7 +141,7 @@ public abstract class Lists
             this.elements = elements;
         }
 
-        public static Value fromSerialized(ByteBuffer value, ListType type, int version) throws InvalidRequestException
+        public static Value fromSerialized(ByteBuffer value, ListType type, ProtocolVersion version) throws InvalidRequestException
         {
             try
             {
@@ -160,7 +160,7 @@ public abstract class Lists
             }
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             return CollectionSerializer.pack(elements, elements.size(), protocolVersion);
         }
@@ -412,7 +412,7 @@ public abstract class Lists
                 if (value == null)
                     params.addTombstone(column);
                 else
-                    params.addCell(column, value.get(Server.CURRENT_VERSION));
+                    params.addCell(column, value.get(ProtocolVersion.CURRENT));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Maps.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Maps.java b/src/java/org/apache/cassandra/cql3/Maps.java
index 952bff0..5c3bc44 100644
--- a/src/java/org/apache/cassandra/cql3/Maps.java
+++ b/src/java/org/apache/cassandra/cql3/Maps.java
@@ -31,7 +31,7 @@ import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.CollectionSerializer;
 import org.apache.cassandra.serializers.MarshalException;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.Pair;
 
@@ -161,7 +161,7 @@ public abstract class Maps
             this.map = map;
         }
 
-        public static Value fromSerialized(ByteBuffer value, MapType type, int version) throws InvalidRequestException
+        public static Value fromSerialized(ByteBuffer value, MapType type, ProtocolVersion version) throws InvalidRequestException
         {
             try
             {
@@ -179,7 +179,7 @@ public abstract class Maps
             }
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             List<ByteBuffer> buffers = new ArrayList<>(2 * map.size());
             for (Map.Entry<ByteBuffer, ByteBuffer> entry : map.entrySet())
@@ -374,7 +374,7 @@ public abstract class Maps
                 if (value == null)
                     params.addTombstone(column);
                 else
-                    params.addCell(column, value.get(Server.CURRENT_VERSION));
+                    params.addCell(column, value.get(ProtocolVersion.CURRENT));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/QueryOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryOptions.java b/src/java/org/apache/cassandra/cql3/QueryOptions.java
index e6cda89..1ba8f89 100644
--- a/src/java/org/apache/cassandra/cql3/QueryOptions.java
+++ b/src/java/org/apache/cassandra/cql3/QueryOptions.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import com.google.common.collect.ImmutableList;
+
 import io.netty.buffer.ByteBuf;
 
 import org.apache.cassandra.config.ColumnDefinition;
@@ -32,7 +33,7 @@ import org.apache.cassandra.service.pager.PagingState;
 import org.apache.cassandra.transport.CBCodec;
 import org.apache.cassandra.transport.CBUtil;
 import org.apache.cassandra.transport.ProtocolException;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.Pair;
 
 /**
@@ -44,7 +45,7 @@ public abstract class QueryOptions
                                                                        Collections.<ByteBuffer>emptyList(),
                                                                        false,
                                                                        SpecificOptions.DEFAULT,
-                                                                       Server.CURRENT_VERSION);
+                                                                       ProtocolVersion.CURRENT);
 
     public static final CBCodec<QueryOptions> codec = new Codec();
 
@@ -53,27 +54,27 @@ public abstract class QueryOptions
 
     public static QueryOptions fromThrift(ConsistencyLevel consistency, List<ByteBuffer> values)
     {
-        return new DefaultQueryOptions(consistency, values, false, SpecificOptions.DEFAULT, Server.VERSION_3);
+        return new DefaultQueryOptions(consistency, values, false, SpecificOptions.DEFAULT, ProtocolVersion.V3);
     }
 
     public static QueryOptions forInternalCalls(ConsistencyLevel consistency, List<ByteBuffer> values)
     {
-        return new DefaultQueryOptions(consistency, values, false, SpecificOptions.DEFAULT, Server.VERSION_3);
+        return new DefaultQueryOptions(consistency, values, false, SpecificOptions.DEFAULT, ProtocolVersion.V3);
     }
 
     public static QueryOptions forInternalCalls(List<ByteBuffer> values)
     {
-        return new DefaultQueryOptions(ConsistencyLevel.ONE, values, false, SpecificOptions.DEFAULT, Server.VERSION_3);
+        return new DefaultQueryOptions(ConsistencyLevel.ONE, values, false, SpecificOptions.DEFAULT, ProtocolVersion.V3);
     }
 
-    public static QueryOptions forProtocolVersion(int protocolVersion)
+    public static QueryOptions forProtocolVersion(ProtocolVersion protocolVersion)
     {
         return new DefaultQueryOptions(null, null, true, null, protocolVersion);
     }
 
-    public static QueryOptions create(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency)
+    public static QueryOptions create(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version)
     {
-        return new DefaultQueryOptions(consistency, values, skipMetadata, new SpecificOptions(pageSize, pagingState, serialConsistency, -1L), 0);
+        return new DefaultQueryOptions(consistency, values, skipMetadata, new SpecificOptions(pageSize, pagingState, serialConsistency, -1L), version);
     }
 
     public static QueryOptions addColumnSpecifications(QueryOptions options, List<ColumnSpecification> columnSpecs)
@@ -180,7 +181,7 @@ public abstract class QueryOptions
      * The protocol version for the query. Will be 3 if the object don't come from
      * a native protocol request (i.e. it's been allocated locally or by CQL-over-thrift).
      */
-    public abstract int getProtocolVersion();
+    public abstract ProtocolVersion getProtocolVersion();
 
     // Mainly for the sake of BatchQueryOptions
     abstract SpecificOptions getSpecificOptions();
@@ -198,9 +199,9 @@ public abstract class QueryOptions
 
         private final SpecificOptions options;
 
-        private final transient int protocolVersion;
+        private final transient ProtocolVersion protocolVersion;
 
-        DefaultQueryOptions(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, SpecificOptions options, int protocolVersion)
+        DefaultQueryOptions(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, SpecificOptions options, ProtocolVersion protocolVersion)
         {
             this.consistency = consistency;
             this.values = values;
@@ -224,7 +225,7 @@ public abstract class QueryOptions
             return skipMetadata;
         }
 
-        public int getProtocolVersion()
+        public ProtocolVersion getProtocolVersion()
         {
             return protocolVersion;
         }
@@ -259,7 +260,7 @@ public abstract class QueryOptions
             return wrapped.skipMetadata();
         }
 
-        public int getProtocolVersion()
+        public ProtocolVersion getProtocolVersion()
         {
             return wrapped.getProtocolVersion();
         }
@@ -364,7 +365,7 @@ public abstract class QueryOptions
 
     private static class Codec implements CBCodec<QueryOptions>
     {
-        private static enum Flag
+        private enum Flag
         {
             // The order of that enum matters!!
             VALUES,
@@ -397,10 +398,12 @@ public abstract class QueryOptions
             }
         }
 
-        public QueryOptions decode(ByteBuf body, int version)
+        public QueryOptions decode(ByteBuf body, ProtocolVersion version)
         {
             ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body);
-            EnumSet<Flag> flags = Flag.deserialize((int)body.readByte());
+            EnumSet<Flag> flags = Flag.deserialize(version.isGreaterOrEqualTo(ProtocolVersion.V5)
+                                                   ? (int)body.readUnsignedInt()
+                                                   : (int)body.readByte());
 
             List<ByteBuffer> values = Collections.<ByteBuffer>emptyList();
             List<String> names = null;
@@ -443,12 +446,15 @@ public abstract class QueryOptions
             return names == null ? opts : new OptionsWithNames(opts, names);
         }
 
-        public void encode(QueryOptions options, ByteBuf dest, int version)
+        public void encode(QueryOptions options, ByteBuf dest, ProtocolVersion version)
         {
             CBUtil.writeConsistencyLevel(options.getConsistency(), dest);
 
             EnumSet<Flag> flags = gatherFlags(options);
-            dest.writeByte((byte)Flag.serialize(flags));
+            if (version.isGreaterOrEqualTo(ProtocolVersion.V5))
+                dest.writeInt(Flag.serialize(flags));
+            else
+                dest.writeByte((byte)Flag.serialize(flags));
 
             if (flags.contains(Flag.VALUES))
                 CBUtil.writeValueList(options.getValues(), dest);
@@ -466,14 +472,14 @@ public abstract class QueryOptions
             // don't bother.
         }
 
-        public int encodedSize(QueryOptions options, int version)
+        public int encodedSize(QueryOptions options, ProtocolVersion version)
         {
             int size = 0;
 
             size += CBUtil.sizeOfConsistencyLevel(options.getConsistency());
 
             EnumSet<Flag> flags = gatherFlags(options);
-            size += 1;
+            size += (version.isGreaterOrEqualTo(ProtocolVersion.V5) ? 4 : 1);
 
             if (flags.contains(Flag.VALUES))
                 size += CBUtil.sizeOfValueList(options.getValues());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 1d5a024..288fd4b 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
 import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
 import org.antlr.runtime.*;
 import org.apache.cassandra.concurrent.ScheduledExecutors;
-import org.apache.cassandra.config.Config;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.config.SchemaConstants;
@@ -53,7 +52,7 @@ import org.apache.cassandra.service.*;
 import org.apache.cassandra.service.pager.QueryPager;
 import org.apache.cassandra.thrift.ThriftClientState;
 import org.apache.cassandra.tracing.Tracing;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.utils.*;
 
@@ -342,7 +341,7 @@ public class QueryProcessor implements QueryHandler
             throw new IllegalArgumentException("Only SELECTs can be paged");
 
         SelectStatement select = (SelectStatement)prepared.statement;
-        QueryPager pager = select.getQuery(makeInternalOptions(prepared, values), FBUtilities.nowInSeconds()).getPager(null, Server.CURRENT_VERSION);
+        QueryPager pager = select.getQuery(makeInternalOptions(prepared, values), FBUtilities.nowInSeconds()).getPager(null, ProtocolVersion.CURRENT);
         return UntypedResultSet.create(select, pager, pageSize);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/ResultSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ResultSet.java b/src/java/org/apache/cassandra/cql3/ResultSet.java
index e9a0f42..9659509 100644
--- a/src/java/org/apache/cassandra/cql3/ResultSet.java
+++ b/src/java/org/apache/cassandra/cql3/ResultSet.java
@@ -177,7 +177,7 @@ public class ResultSet
          *   - rows count (4 bytes)
          *   - rows
          */
-        public ResultSet decode(ByteBuf body, int version)
+        public ResultSet decode(ByteBuf body, ProtocolVersion version)
         {
             ResultMetadata m = ResultMetadata.codec.decode(body, version);
             int rowCount = body.readInt();
@@ -191,7 +191,7 @@ public class ResultSet
             return rs;
         }
 
-        public void encode(ResultSet rs, ByteBuf dest, int version)
+        public void encode(ResultSet rs, ByteBuf dest, ProtocolVersion version)
         {
             ResultMetadata.codec.encode(rs.metadata, dest, version);
             dest.writeInt(rs.rows.size());
@@ -204,7 +204,7 @@ public class ResultSet
             }
         }
 
-        public int encodedSize(ResultSet rs, int version)
+        public int encodedSize(ResultSet rs, ProtocolVersion version)
         {
             int size = ResultMetadata.codec.encodedSize(rs.metadata, version) + 4;
             for (List<ByteBuffer> row : rs.rows)
@@ -296,6 +296,29 @@ public class ResultSet
         }
 
         @Override
+        public boolean equals(Object other)
+        {
+            if (this == other)
+                return true;
+
+            if (!(other instanceof ResultMetadata))
+                return false;
+
+            ResultMetadata that = (ResultMetadata) other;
+
+            return Objects.equals(flags, that.flags)
+                   && Objects.equals(names, that.names)
+                   && columnCount == that.columnCount
+                   && Objects.equals(pagingState, that.pagingState);
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return Objects.hash(flags, names, columnCount, pagingState);
+        }
+
+        @Override
         public String toString()
         {
             StringBuilder sb = new StringBuilder();
@@ -320,7 +343,7 @@ public class ResultSet
 
         private static class Codec implements CBCodec<ResultMetadata>
         {
-            public ResultMetadata decode(ByteBuf body, int version)
+            public ResultMetadata decode(ByteBuf body, ProtocolVersion version)
             {
                 // flags & column count
                 int iflags = body.readInt();
@@ -358,13 +381,14 @@ public class ResultSet
                 return new ResultMetadata(flags, names, names.size(), state);
             }
 
-            public void encode(ResultMetadata m, ByteBuf dest, int version)
+            public void encode(ResultMetadata m, ByteBuf dest, ProtocolVersion version)
             {
                 boolean noMetadata = m.flags.contains(Flag.NO_METADATA);
                 boolean globalTablesSpec = m.flags.contains(Flag.GLOBAL_TABLES_SPEC);
                 boolean hasMorePages = m.flags.contains(Flag.HAS_MORE_PAGES);
 
-                assert version > 1 || (!hasMorePages && !noMetadata): "version = " + version + ", flags = " + m.flags;
+                assert version.isGreaterThan(ProtocolVersion.V1) || (!hasMorePages && !noMetadata)
+                    : "version = " + version + ", flags = " + m.flags;
 
                 dest.writeInt(Flag.serialize(m.flags));
                 dest.writeInt(m.columnCount);
@@ -394,7 +418,7 @@ public class ResultSet
                 }
             }
 
-            public int encodedSize(ResultMetadata m, int version)
+            public int encodedSize(ResultMetadata m, ProtocolVersion version)
             {
                 boolean noMetadata = m.flags.contains(Flag.NO_METADATA);
                 boolean globalTablesSpec = m.flags.contains(Flag.GLOBAL_TABLES_SPEC);
@@ -462,6 +486,9 @@ public class ResultSet
         @Override
         public boolean equals(Object other)
         {
+            if (this == other)
+                return true;
+
             if (!(other instanceof PreparedMetadata))
                 return false;
 
@@ -472,6 +499,12 @@ public class ResultSet
         }
 
         @Override
+        public int hashCode()
+        {
+            return Objects.hash(names, flags) + Arrays.hashCode(partitionKeyBindIndexes);
+        }
+
+        @Override
         public String toString()
         {
             StringBuilder sb = new StringBuilder();
@@ -498,7 +531,7 @@ public class ResultSet
 
         private static class Codec implements CBCodec<PreparedMetadata>
         {
-            public PreparedMetadata decode(ByteBuf body, int version)
+            public PreparedMetadata decode(ByteBuf body, ProtocolVersion version)
             {
                 // flags & column count
                 int iflags = body.readInt();
@@ -507,7 +540,7 @@ public class ResultSet
                 EnumSet<Flag> flags = Flag.deserialize(iflags);
 
                 short[] partitionKeyBindIndexes = null;
-                if (version >= Server.VERSION_4)
+                if (version.isGreaterOrEqualTo(ProtocolVersion.V4))
                 {
                     int numPKNames = body.readInt();
                     if (numPKNames > 0)
@@ -541,13 +574,13 @@ public class ResultSet
                 return new PreparedMetadata(flags, names, partitionKeyBindIndexes);
             }
 
-            public void encode(PreparedMetadata m, ByteBuf dest, int version)
+            public void encode(PreparedMetadata m, ByteBuf dest, ProtocolVersion version)
             {
                 boolean globalTablesSpec = m.flags.contains(Flag.GLOBAL_TABLES_SPEC);
                 dest.writeInt(Flag.serialize(m.flags));
                 dest.writeInt(m.names.size());
 
-                if (version >= Server.VERSION_4)
+                if (version.isGreaterOrEqualTo(ProtocolVersion.V4))
                 {
                     // there's no point in providing partition key bind indexes if the statements affect multiple tables
                     if (m.partitionKeyBindIndexes == null || !globalTablesSpec)
@@ -580,7 +613,7 @@ public class ResultSet
                 }
             }
 
-            public int encodedSize(PreparedMetadata m, int version)
+            public int encodedSize(PreparedMetadata m, ProtocolVersion version)
             {
                 boolean globalTablesSpec = m.flags.contains(Flag.GLOBAL_TABLES_SPEC);
                 int size = 8;
@@ -590,7 +623,7 @@ public class ResultSet
                     size += CBUtil.sizeOfString(m.names.get(0).cfName);
                 }
 
-                if (m.partitionKeyBindIndexes != null && version >= Server.VERSION_4)
+                if (m.partitionKeyBindIndexes != null && version.isGreaterOrEqualTo(ProtocolVersion.V4))
                     size += 4 + 2 * m.partitionKeyBindIndexes.length;
 
                 for (ColumnSpecification name : m.names)
@@ -608,7 +641,7 @@ public class ResultSet
         }
     }
 
-    public static enum Flag
+    public enum Flag
     {
         // The order of that enum matters!!
         GLOBAL_TABLES_SPEC,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Sets.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Sets.java b/src/java/org/apache/cassandra/cql3/Sets.java
index e8617aa..d17a771 100644
--- a/src/java/org/apache/cassandra/cql3/Sets.java
+++ b/src/java/org/apache/cassandra/cql3/Sets.java
@@ -31,7 +31,7 @@ import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.CollectionSerializer;
 import org.apache.cassandra.serializers.MarshalException;
-import org.apache.cassandra.transport.Server;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
@@ -149,7 +149,7 @@ public abstract class Sets
             this.elements = elements;
         }
 
-        public static Value fromSerialized(ByteBuffer value, SetType type, int version) throws InvalidRequestException
+        public static Value fromSerialized(ByteBuffer value, SetType type, ProtocolVersion version) throws InvalidRequestException
         {
             try
             {
@@ -167,7 +167,7 @@ public abstract class Sets
             }
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             return CollectionSerializer.pack(elements, elements.size(), protocolVersion);
         }
@@ -308,7 +308,7 @@ public abstract class Sets
                 if (value == null)
                     params.addTombstone(column);
                 else
-                    params.addCell(column, value.get(Server.CURRENT_VERSION));
+                    params.addCell(column, value.get(ProtocolVersion.CURRENT));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Term.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Term.java b/src/java/org/apache/cassandra/cql3/Term.java
index 2c2eba6..11b9860 100644
--- a/src/java/org/apache/cassandra/cql3/Term.java
+++ b/src/java/org/apache/cassandra/cql3/Term.java
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 /**
  * A CQL3 term, i.e. a column value with or without bind variables.
@@ -156,7 +157,7 @@ public interface Term
          * @return the serialized value of this terminal.
          * @param protocolVersion
          */
-        public abstract ByteBuffer get(int protocolVersion) throws InvalidRequestException;
+        public abstract ByteBuffer get(ProtocolVersion protocolVersion) throws InvalidRequestException;
 
         public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/Tuples.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Tuples.java b/src/java/org/apache/cassandra/cql3/Tuples.java
index 267832d..32a31fd 100644
--- a/src/java/org/apache/cassandra/cql3/Tuples.java
+++ b/src/java/org/apache/cassandra/cql3/Tuples.java
@@ -30,6 +30,7 @@ import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /**
@@ -179,7 +180,7 @@ public class Tuples
             return new Value(type.split(bytes));
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             return TupleType.buildValue(elements);
         }
@@ -296,7 +297,7 @@ public class Tuples
             }
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             throw new UnsupportedOperationException();
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/UntypedResultSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/UntypedResultSet.java b/src/java/org/apache/cassandra/cql3/UntypedResultSet.java
index 3d70051..d896071 100644
--- a/src/java/org/apache/cassandra/cql3/UntypedResultSet.java
+++ b/src/java/org/apache/cassandra/cql3/UntypedResultSet.java
@@ -22,6 +22,7 @@ import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.AbstractIterator;
 
 import org.apache.cassandra.config.CFMetaData;
@@ -32,7 +33,6 @@ import org.apache.cassandra.db.rows.*;
 import org.apache.cassandra.db.partitions.PartitionIterator;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.service.pager.QueryPager;
-import org.apache.cassandra.transport.Server;
 import org.apache.cassandra.utils.FBUtilities;
 
 /** a utility for doing internal cql-based queries */
@@ -245,7 +245,7 @@ public abstract class UntypedResultSet implements Iterable<UntypedResultSet.Row>
                 {
                     ComplexColumnData complexData = row.getComplexColumnData(def);
                     if (complexData != null)
-                        data.put(def.name.toString(), ((CollectionType)def.type).serializeForNativeProtocol(complexData.iterator(), Server.VERSION_3));
+                        data.put(def.name.toString(), ((CollectionType)def.type).serializeForNativeProtocol(complexData.iterator(), ProtocolVersion.V3));
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/UserTypes.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/UserTypes.java b/src/java/org/apache/cassandra/cql3/UserTypes.java
index 41b8eed..e867179 100644
--- a/src/java/org/apache/cassandra/cql3/UserTypes.java
+++ b/src/java/org/apache/cassandra/cql3/UserTypes.java
@@ -26,6 +26,7 @@ import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.db.rows.CellPath;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 import static org.apache.cassandra.cql3.Constants.UNSET_VALUE;
@@ -172,7 +173,7 @@ public abstract class UserTypes
             return new Value(type, type.split(bytes));
         }
 
-        public ByteBuffer get(int protocolVersion)
+        public ByteBuffer get(ProtocolVersion protocolVersion)
         {
             return TupleType.buildValue(elements);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
index 530b7ba..85d3763 100644
--- a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
@@ -28,6 +28,7 @@ import java.util.List;
 import org.apache.cassandra.cql3.CQL3Type;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 /**
  * Factory methods for aggregate functions.
@@ -102,12 +103,12 @@ public abstract class AggregateFcts
                             count = 0;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return LongType.instance.decompose(count);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             count++;
                         }
@@ -139,12 +140,12 @@ public abstract class AggregateFcts
                             sum = BigDecimal.ZERO;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ((DecimalType) returnType()).decompose(sum);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -178,12 +179,12 @@ public abstract class AggregateFcts
                             avg = BigDecimal.ZERO;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return DecimalType.instance.decompose(avg);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -218,12 +219,12 @@ public abstract class AggregateFcts
                             sum = BigInteger.ZERO;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ((IntegerType) returnType()).decompose(sum);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -257,7 +258,7 @@ public abstract class AggregateFcts
                             sum = BigInteger.ZERO;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             if (count == 0)
                                 return IntegerType.instance.decompose(BigInteger.ZERO);
@@ -265,7 +266,7 @@ public abstract class AggregateFcts
                             return IntegerType.instance.decompose(sum.divide(BigInteger.valueOf(count)));
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -297,12 +298,12 @@ public abstract class AggregateFcts
                             sum = 0;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ((ByteType) returnType()).decompose(sum);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -326,7 +327,7 @@ public abstract class AggregateFcts
                 {
                     return new AvgAggregate(ByteType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                         {
                             return ByteType.instance.decompose((byte) computeInternal());
                         }
@@ -351,12 +352,12 @@ public abstract class AggregateFcts
                             sum = 0;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ((ShortType) returnType()).decompose(sum);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -380,7 +381,7 @@ public abstract class AggregateFcts
                 {
                     return new AvgAggregate(ShortType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ShortType.instance.decompose((short) computeInternal());
                         }
@@ -405,12 +406,12 @@ public abstract class AggregateFcts
                             sum = 0;
                         }
 
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return ((Int32Type) returnType()).decompose(sum);
                         }
 
-                        public void addInput(int protocolVersion, List<ByteBuffer> values)
+                        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                         {
                             ByteBuffer value = values.get(0);
 
@@ -434,7 +435,7 @@ public abstract class AggregateFcts
                 {
                     return new AvgAggregate(Int32Type.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return Int32Type.instance.decompose((int) computeInternal());
                         }
@@ -464,7 +465,7 @@ public abstract class AggregateFcts
                 {
                     return new AvgAggregate(LongType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion)
+                        public ByteBuffer compute(ProtocolVersion protocolVersion)
                         {
                             return LongType.instance.decompose(computeInternal());
                         }
@@ -482,7 +483,7 @@ public abstract class AggregateFcts
                 {
                     return new FloatSumAggregate(FloatType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                         {
                             return FloatType.instance.decompose((float) computeInternal());
                         }
@@ -500,7 +501,7 @@ public abstract class AggregateFcts
                 {
                     return new FloatAvgAggregate(FloatType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                         {
                             return FloatType.instance.decompose((float) computeInternal());
                         }
@@ -518,7 +519,7 @@ public abstract class AggregateFcts
                 {
                     return new FloatSumAggregate(DoubleType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                         {
                             return DoubleType.instance.decompose(computeInternal());
                         }
@@ -550,7 +551,7 @@ public abstract class AggregateFcts
             simpleSum = 0;
         }
 
-        public void addInput(int protocolVersion, List<ByteBuffer> values)
+        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
         {
             ByteBuffer value = values.get(0);
 
@@ -635,7 +636,7 @@ public abstract class AggregateFcts
             }
         }
 
-        public void addInput(int protocolVersion, List<ByteBuffer> values)
+        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
         {
             ByteBuffer value = values.get(0);
 
@@ -678,7 +679,7 @@ public abstract class AggregateFcts
                 {
                     return new FloatAvgAggregate(DoubleType.instance)
                     {
-                        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                         {
                             return DoubleType.instance.decompose(computeInternal());
                         }
@@ -708,7 +709,7 @@ public abstract class AggregateFcts
         {
             return new AvgAggregate(LongType.instance)
             {
-                public ByteBuffer compute(int protocolVersion) throws InvalidRequestException
+                public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException
                 {
                     return CounterColumnType.instance.decompose(computeInternal());
                 }
@@ -733,12 +734,12 @@ public abstract class AggregateFcts
                     min = null;
                 }
 
-                public ByteBuffer compute(int protocolVersion)
+                public ByteBuffer compute(ProtocolVersion protocolVersion)
                 {
                     return min != null ? LongType.instance.decompose(min) : null;
                 }
 
-                public void addInput(int protocolVersion, List<ByteBuffer> values)
+                public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                 {
                     ByteBuffer value = values.get(0);
 
@@ -771,12 +772,12 @@ public abstract class AggregateFcts
                     max = null;
                 }
 
-                public ByteBuffer compute(int protocolVersion)
+                public ByteBuffer compute(ProtocolVersion protocolVersion)
                 {
                     return max != null ? LongType.instance.decompose(max) : null;
                 }
 
-                public void addInput(int protocolVersion, List<ByteBuffer> values)
+                public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                 {
                     ByteBuffer value = values.get(0);
 
@@ -813,12 +814,12 @@ public abstract class AggregateFcts
                         max = null;
                     }
 
-                    public ByteBuffer compute(int protocolVersion)
+                    public ByteBuffer compute(ProtocolVersion protocolVersion)
                     {
                         return max;
                     }
 
-                    public void addInput(int protocolVersion, List<ByteBuffer> values)
+                    public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                     {
                         ByteBuffer value = values.get(0);
 
@@ -854,12 +855,12 @@ public abstract class AggregateFcts
                         min = null;
                     }
 
-                    public ByteBuffer compute(int protocolVersion)
+                    public ByteBuffer compute(ProtocolVersion protocolVersion)
                     {
                         return min;
                     }
 
-                    public void addInput(int protocolVersion, List<ByteBuffer> values)
+                    public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                     {
                         ByteBuffer value = values.get(0);
 
@@ -895,12 +896,12 @@ public abstract class AggregateFcts
                         count = 0;
                     }
 
-                    public ByteBuffer compute(int protocolVersion)
+                    public ByteBuffer compute(ProtocolVersion protocolVersion)
                     {
                         return ((LongType) returnType()).decompose(count);
                     }
 
-                    public void addInput(int protocolVersion, List<ByteBuffer> values)
+                    public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
                     {
                         ByteBuffer value = values.get(0);
 
@@ -923,12 +924,12 @@ public abstract class AggregateFcts
             sum = 0;
         }
 
-        public ByteBuffer compute(int protocolVersion)
+        public ByteBuffer compute(ProtocolVersion protocolVersion)
         {
             return LongType.instance.decompose(sum);
         }
 
-        public void addInput(int protocolVersion, List<ByteBuffer> values)
+        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
         {
             ByteBuffer value = values.get(0);
 
@@ -979,7 +980,7 @@ public abstract class AggregateFcts
             }
         }
 
-        public void addInput(int protocolVersion, List<ByteBuffer> values)
+        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
         {
             ByteBuffer value = values.get(0);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/AggregateFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/AggregateFunction.java b/src/java/org/apache/cassandra/cql3/functions/AggregateFunction.java
index ddbc9d1..b207563 100644
--- a/src/java/org/apache/cassandra/cql3/functions/AggregateFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/AggregateFunction.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 /**
  * Performs a calculation on a set of values and return a single value.
@@ -41,11 +42,10 @@ public interface AggregateFunction extends Function
     {
         /**
          * Adds the specified input to this aggregate.
-         *
-         * @param protocolVersion native protocol version
+         *  @param protocolVersion native protocol version
          * @param values the values to add to the aggregate.
          */
-        public void addInput(int protocolVersion, List<ByteBuffer> values) throws InvalidRequestException;
+        public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values) throws InvalidRequestException;
 
         /**
          * Computes and returns the aggregate current value.
@@ -53,7 +53,7 @@ public interface AggregateFunction extends Function
          * @param protocolVersion native protocol version
          * @return the aggregate current value.
          */
-        public ByteBuffer compute(int protocolVersion) throws InvalidRequestException;
+        public ByteBuffer compute(ProtocolVersion protocolVersion) throws InvalidRequestException;
 
         /**
          * Reset this aggregate.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java b/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
index d9c6a52..33771b7 100644
--- a/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
@@ -26,6 +26,7 @@ import org.apache.cassandra.cql3.CQL3Type;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.BytesType;
 import org.apache.cassandra.db.marshal.UTF8Type;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.MarshalException;
@@ -60,7 +61,7 @@ public abstract class BytesConversionFcts
         String name = fromType.asCQL3Type() + "asblob";
         return new NativeScalarFunction(name, BytesType.instance, fromType)
         {
-            public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+            public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
             {
                 return parameters.get(0);
             }
@@ -72,7 +73,7 @@ public abstract class BytesConversionFcts
         final String name = "blobas" + toType.asCQL3Type();
         return new NativeScalarFunction(name, toType, BytesType.instance)
         {
-            public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
+            public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
             {
                 ByteBuffer val = parameters.get(0);
                 try
@@ -92,7 +93,7 @@ public abstract class BytesConversionFcts
 
     public static final Function VarcharAsBlobFct = new NativeScalarFunction("varcharasblob", BytesType.instance, UTF8Type.instance)
     {
-        public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+        public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
         {
             return parameters.get(0);
         }
@@ -100,7 +101,7 @@ public abstract class BytesConversionFcts
 
     public static final Function BlobAsVarcharFct = new NativeScalarFunction("blobasvarchar", UTF8Type.instance, BytesType.instance)
     {
-        public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+        public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
         {
             return parameters.get(0);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/CastFcts.java b/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
index b5d3698..9e5c729 100644
--- a/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
@@ -44,6 +44,8 @@ import org.apache.cassandra.db.marshal.TimeUUIDType;
 import org.apache.cassandra.db.marshal.TimestampType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.marshal.UUIDType;
+import org.apache.cassandra.transport.ProtocolVersion;
+
 import org.apache.commons.lang3.text.WordUtils;
 
 /**
@@ -224,7 +226,7 @@ public final class CastFcts
             this.converter = converter;
         }
 
-        public final ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+        public final ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
         {
             ByteBuffer bb = parameters.get(0);
             if (bb == null)
@@ -297,7 +299,7 @@ public final class CastFcts
             this.delegate = delegate;
         }
 
-        public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+        public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
         {
             return delegate.execute(protocolVersion, parameters);
         }
@@ -323,7 +325,7 @@ public final class CastFcts
             super(inputType, outputType);
         }
 
-        public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+        public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
         {
             ByteBuffer bb = parameters.get(0);
             if (bb == null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java b/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
index 2b9e8c6..8f07b38 100644
--- a/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
+++ b/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
@@ -28,6 +28,7 @@ import org.apache.cassandra.cql3.QueryOptions;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.FunctionExecutionException;
 import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 public class FromJsonFct extends NativeScalarFunction
 {
@@ -51,7 +52,7 @@ public class FromJsonFct extends NativeScalarFunction
         super("fromjson", returnType, UTF8Type.instance);
     }
 
-    public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters)
+    public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
     {
         assert parameters.size() == 1 : "Unexpectedly got " + parameters.size() + " arguments for fromJson()";
         ByteBuffer argument = parameters.get(0);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
index 3905c83..bcc912f 100644
--- a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
+++ b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
@@ -27,6 +27,7 @@ import org.apache.cassandra.cql3.statements.RequestValidations;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class FunctionCall extends Term.NonTerminal
@@ -69,7 +70,7 @@ public class FunctionCall extends Term.NonTerminal
         return executeInternal(options.getProtocolVersion(), fun, buffers);
     }
 
-    private static ByteBuffer executeInternal(int protocolVersion, ScalarFunction fun, List<ByteBuffer> params) throws InvalidRequestException
+    private static ByteBuffer executeInternal(ProtocolVersion protocolVersion, ScalarFunction fun, List<ByteBuffer> params) throws InvalidRequestException
     {
         ByteBuffer result = fun.execute(protocolVersion, params);
         try
@@ -96,7 +97,7 @@ public class FunctionCall extends Term.NonTerminal
         return false;
     }
 
-    private static Term.Terminal makeTerminal(Function fun, ByteBuffer result, int version) throws InvalidRequestException
+    private static Term.Terminal makeTerminal(Function fun, ByteBuffer result, ProtocolVersion version) throws InvalidRequestException
     {
         if (fun.returnType().isCollection())
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java b/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java
index 34c6cc9..8f12899 100644
--- a/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/JavaBasedUDFunction.java
@@ -48,6 +48,7 @@ import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.cql3.ColumnIdentifier;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.FBUtilities;
 import org.eclipse.jdt.core.compiler.IProblem;
 import org.eclipse.jdt.internal.compiler.*;
@@ -362,12 +363,12 @@ public final class JavaBasedUDFunction extends UDFunction
         return executor;
     }
 
-    protected ByteBuffer executeUserDefined(int protocolVersion, List<ByteBuffer> params)
+    protected ByteBuffer executeUserDefined(ProtocolVersion protocolVersion, List<ByteBuffer> params)
     {
         return javaUDF.executeImpl(protocolVersion, params);
     }
 
-    protected Object executeAggregateUserDefined(int protocolVersion, Object firstParam, List<ByteBuffer> params)
+    protected Object executeAggregateUserDefined(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params)
     {
         return javaUDF.executeAggregateImpl(protocolVersion, firstParam, params);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/JavaUDF.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/JavaUDF.java b/src/java/org/apache/cassandra/cql3/functions/JavaUDF.java
index 56a7ced..fab29f3 100644
--- a/src/java/org/apache/cassandra/cql3/functions/JavaUDF.java
+++ b/src/java/org/apache/cassandra/cql3/functions/JavaUDF.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import com.datastax.driver.core.TypeCodec;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 /**
  * Base class for all Java UDFs.
@@ -43,64 +44,64 @@ public abstract class JavaUDF
         this.udfContext = udfContext;
     }
 
-    protected abstract ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params);
+    protected abstract ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params);
 
-    protected abstract Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params);
+    protected abstract Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params);
 
-    protected Object compose(int protocolVersion, int argIndex, ByteBuffer value)
+    protected Object compose(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         return UDFunction.compose(argCodecs, protocolVersion, argIndex, value);
     }
 
-    protected ByteBuffer decompose(int protocolVersion, Object value)
+    protected ByteBuffer decompose(ProtocolVersion protocolVersion, Object value)
     {
         return UDFunction.decompose(returnCodec, protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected float compose_float(int protocolVersion, int argIndex, ByteBuffer value)
+    protected float compose_float(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (float) UDHelper.deserialize(TypeCodec.cfloat(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected double compose_double(int protocolVersion, int argIndex, ByteBuffer value)
+    protected double compose_double(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (double) UDHelper.deserialize(TypeCodec.cdouble(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected byte compose_byte(int protocolVersion, int argIndex, ByteBuffer value)
+    protected byte compose_byte(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (byte) UDHelper.deserialize(TypeCodec.tinyInt(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected short compose_short(int protocolVersion, int argIndex, ByteBuffer value)
+    protected short compose_short(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (short) UDHelper.deserialize(TypeCodec.smallInt(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected int compose_int(int protocolVersion, int argIndex, ByteBuffer value)
+    protected int compose_int(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (int) UDHelper.deserialize(TypeCodec.cint(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected long compose_long(int protocolVersion, int argIndex, ByteBuffer value)
+    protected long compose_long(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (long) UDHelper.deserialize(TypeCodec.bigint(), protocolVersion, value);
     }
 
     // do not remove - used by generated Java UDFs
-    protected boolean compose_boolean(int protocolVersion, int argIndex, ByteBuffer value)
+    protected boolean compose_boolean(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
     {
         assert value != null && value.remaining() > 0;
         return (boolean) UDHelper.deserialize(TypeCodec.cboolean(), protocolVersion, value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/ScalarFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/ScalarFunction.java b/src/java/org/apache/cassandra/cql3/functions/ScalarFunction.java
index ba258df..1f98372 100644
--- a/src/java/org/apache/cassandra/cql3/functions/ScalarFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/ScalarFunction.java
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 /**
  * Determines a single output value based on a single input value.
@@ -37,5 +38,5 @@ public interface ScalarFunction extends Function
      * @return the result of applying this function to the parameter
      * @throws InvalidRequestException if this function cannot not be applied to the parameter
      */
-    public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException;
+    public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException;
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/cql3/functions/ScriptBasedUDFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/ScriptBasedUDFunction.java b/src/java/org/apache/cassandra/cql3/functions/ScriptBasedUDFunction.java
index 8c15dc9..3ad60d0 100644
--- a/src/java/org/apache/cassandra/cql3/functions/ScriptBasedUDFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/ScriptBasedUDFunction.java
@@ -32,6 +32,7 @@ import org.apache.cassandra.concurrent.NamedThreadFactory;
 import org.apache.cassandra.cql3.ColumnIdentifier;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.transport.ProtocolVersion;
 
 final class ScriptBasedUDFunction extends UDFunction
 {
@@ -171,7 +172,7 @@ final class ScriptBasedUDFunction extends UDFunction
         return executor;
     }
 
-    public ByteBuffer executeUserDefined(int protocolVersion, List<ByteBuffer> parameters)
+    public ByteBuffer executeUserDefined(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
     {
         Object[] params = new Object[argTypes.size()];
         for (int i = 0; i < params.length; i++)
@@ -183,12 +184,12 @@ final class ScriptBasedUDFunction extends UDFunction
     }
 
     /**
-     * Like {@link #executeUserDefined(int, List)} but the first parameter is already in non-serialized form.
+     * Like {@link UDFunction#executeUserDefined(ProtocolVersion, List)} but the first parameter is already in non-serialized form.
      * Remaining parameters (2nd paramters and all others) are in {@code parameters}.
      * This is used to prevent superfluous (de)serialization of the state of aggregates.
      * Means: scalar functions of aggregates are called using this variant.
      */
-    protected Object executeAggregateUserDefined(int protocolVersion, Object firstParam, List<ByteBuffer> parameters)
+    protected Object executeAggregateUserDefined(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> parameters)
     {
         Object[] params = new Object[argTypes.size()];
         params[0] = firstParam;


Mime
View raw message