Repository: qpid-proton-j
Updated Branches:
  refs/heads/master 2951b4051 -> 31f5fc97b


PROTON-19 Optimization for the codec and transport hot paths

Write a cachded encoded value for Accepted states as that does not change
and can be easy syntheszied.  Also write the descriptor codes directly in
the fast path encoders since we know the type and value without needing to
dip back into the generic encoder write methods.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/commit/31f5fc97
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/tree/31f5fc97
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/diff/31f5fc97

Branch: refs/heads/master
Commit: 31f5fc97bbf60a73ba913b7dc16851cf7e2a150b
Parents: 2951b40
Author: Timothy Bish <tabish...@gmail.com>
Authored: Thu Nov 1 15:13:16 2018 -0400
Committer: Timothy Bish <tabish...@gmail.com>
Committed: Thu Nov 1 15:13:16 2018 -0400

----------------------------------------------------------------------
 .../codec/messaging/FastPathAcceptedType.java   | 17 +++++++++----
 .../messaging/FastPathAmqpSequenceType.java     |  9 ++++---
 .../codec/messaging/FastPathAmqpValueType.java  |  9 ++++---
 .../FastPathApplicationPropertiesType.java      |  9 ++++---
 .../codec/messaging/FastPathDataType.java       |  9 ++++---
 .../FastPathDeliveryAnnotationsType.java        |  7 ++++--
 .../codec/messaging/FastPathFooterType.java     |  7 ++++--
 .../codec/messaging/FastPathHeaderType.java     | 15 +++++------
 .../FastPathMessageAnnotationsType.java         |  9 ++++---
 .../codec/messaging/FastPathPropertiesType.java | 15 +++++------
 .../transport/FastPathDispositionType.java      | 26 +++++++++++++++-----
 .../codec/transport/FastPathFlowType.java       | 12 +++++----
 .../codec/transport/FastPathTransferType.java   | 12 +++++----
 13 files changed, 102 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
index d9eb991..9e5e96d 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
@@ -22,20 +22,29 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.Accepted;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathAcceptedType implements AMQPType<Accepted>, 
FastPathDescribedTypeConstructor<Accepted> {
 
+    private static final byte DESCRIPTOR_CODE = 0x24;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000024L), 
Symbol.valueOf("amqp:accepted:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:accepted:list"),
+    };
+
+    private static final byte[] ACCEPTED_ENCODED_BYTES = new byte[] {
+        EncodingCodes.DESCRIBED_TYPE_INDICATOR,
+        EncodingCodes.SMALLULONG,
+        DESCRIPTOR_CODE,
+        EncodingCodes.LIST0
     };
 
     private final AcceptedType acceptedType;
@@ -108,9 +117,7 @@ public class FastPathAcceptedType implements 
AMQPType<Accepted>, FastPathDescrib
     @Override
     public void write(Accepted accepted) {
         WritableBuffer buffer = getEncoder().getBuffer();
-        buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(acceptedType.getDescriptor());
-        buffer.put(EncodingCodes.LIST0);
+        buffer.put(ACCEPTED_ENCODED_BYTES, 0, ACCEPTED_ENCODED_BYTES.length);
     }
 
     public static void register(Decoder decoder, EncoderImpl encoder) {

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
index 611ec10..6a4ebd4 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
@@ -22,19 +22,21 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.AmqpSequence;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathAmqpSequenceType implements AMQPType<AmqpSequence>, 
FastPathDescribedTypeConstructor<AmqpSequence> {
 
+    private static final byte DESCRIPTOR_CODE = 0x76;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000076L), 
Symbol.valueOf("amqp:amqp-sequence:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:amqp-sequence:list"),
     };
 
     private final AmqpSequenceType sequenceType;
@@ -90,7 +92,8 @@ public class FastPathAmqpSequenceType implements 
AMQPType<AmqpSequence>, FastPat
     public void write(AmqpSequence sequence) {
         WritableBuffer buffer = getEncoder().getBuffer();
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(sequenceType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
         getEncoder().writeObject(sequence.getValue());
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
index 7120481..b9d4ee7 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
@@ -22,19 +22,21 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathAmqpValueType implements AMQPType<AmqpValue>, 
FastPathDescribedTypeConstructor<AmqpValue> {
 
+    private static final byte DESCRIPTOR_CODE = 0x77;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000077L), 
Symbol.valueOf("amqp:amqp-value:*"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:amqp-value:*"),
     };
 
     private final AmqpValueType valueType;
@@ -90,7 +92,8 @@ public class FastPathAmqpValueType implements 
AMQPType<AmqpValue>, FastPathDescr
     public void write(AmqpValue value) {
         WritableBuffer buffer = getEncoder().getBuffer();
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(valueType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
         getEncoder().writeObject(value.getValue());
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
index 4eed5e7..08078f3 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
@@ -22,20 +22,22 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.MapType;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathApplicationPropertiesType implements 
AMQPType<ApplicationProperties>, 
FastPathDescribedTypeConstructor<ApplicationProperties> {
 
+    private static final byte DESCRIPTOR_CODE = 0x74;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000074L), 
Symbol.valueOf("amqp:application-properties:map"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:application-properties:map"),
     };
 
     private final ApplicationPropertiesType propertiesType;
@@ -92,7 +94,8 @@ public class FastPathApplicationPropertiesType implements 
AMQPType<ApplicationPr
         WritableBuffer buffer = getEncoder().getBuffer();
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(propertiesType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
 
         MapType mapType = (MapType) getEncoder().getType(val.getValue());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
index 75a7543..a3cfb2a 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
@@ -22,19 +22,21 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.Data;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathDataType implements AMQPType<Data>, 
FastPathDescribedTypeConstructor<Data> {
 
+    private static final byte DESCRIPTOR_CODE = 0x75;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000075L), 
Symbol.valueOf("amqp:data:binary"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:data:binary"),
     };
 
     private final DataType dataType;
@@ -90,7 +92,8 @@ public class FastPathDataType implements AMQPType<Data>, 
FastPathDescribedTypeCo
     public void write(Data data) {
         WritableBuffer buffer = getEncoder().getBuffer();
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(dataType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
         getEncoder().writeBinary(data.getValue());
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
index 4252393..acf91dc 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
@@ -33,9 +33,11 @@ import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathDeliveryAnnotationsType implements 
AMQPType<DeliveryAnnotations>, 
FastPathDescribedTypeConstructor<DeliveryAnnotations> {
 
+    private static final byte DESCRIPTOR_CODE = 0x71;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000071L), 
Symbol.valueOf("amqp:delivery-annotations:map"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:delivery-annotations:map"),
     };
 
     private final DeliveryAnnotationsType annotationsType;
@@ -93,7 +95,8 @@ public class FastPathDeliveryAnnotationsType implements 
AMQPType<DeliveryAnnotat
         WritableBuffer buffer = getEncoder().getBuffer();
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(annotationsType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
 
         MapType mapType = (MapType) getEncoder().getType(val.getValue());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
index d1b0d40..88f690f 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
@@ -33,9 +33,11 @@ import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathFooterType implements AMQPType<Footer>, 
FastPathDescribedTypeConstructor<Footer> {
 
+    private static final byte DESCRIPTOR_CODE = 0x78;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000078L), 
Symbol.valueOf("amqp:footer:map"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:footer:map"),
     };
 
     private final FooterType footerType;
@@ -92,7 +94,8 @@ public class FastPathFooterType implements AMQPType<Footer>, 
FastPathDescribedTy
         WritableBuffer buffer = getEncoder().getBuffer();
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(footerType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
 
         MapType mapType = (MapType) getEncoder().getType(val.getValue());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
index 06d8026..2562e57 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
@@ -22,20 +22,22 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.Header;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathHeaderType implements AMQPType<Header>, 
FastPathDescribedTypeConstructor<Header> {
 
+    private static final byte DESCRIPTOR_CODE = 0x70;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000070L), 
Symbol.valueOf("amqp:header:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:header:list"),
     };
 
     private final HeaderType headerType;
@@ -140,11 +142,12 @@ public class FastPathHeaderType implements 
AMQPType<Header>, FastPathDescribedTy
         byte encodingCode = deduceEncodingCode(value, count);
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(headerType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
+        buffer.put(encodingCode);
 
         // Optimized step, no other data to be written.
-        if (count == 0 || encodingCode == EncodingCodes.LIST0) {
-            buffer.put(EncodingCodes.LIST0);
+        if (encodingCode == EncodingCodes.LIST0) {
             return;
         }
 
@@ -152,10 +155,8 @@ public class FastPathHeaderType implements 
AMQPType<Header>, FastPathDescribedTy
 
         if (encodingCode == EncodingCodes.LIST8) {
             fieldWidth = 1;
-            buffer.put(EncodingCodes.LIST8);
         } else {
             fieldWidth = 4;
-            buffer.put(EncodingCodes.LIST32);
         }
 
         int startIndex = buffer.position();

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
index 6d32004..195e4b5 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
@@ -22,20 +22,22 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.MapType;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathMessageAnnotationsType implements 
AMQPType<MessageAnnotations>, 
FastPathDescribedTypeConstructor<MessageAnnotations> {
 
+    private static final byte DESCRIPTOR_CODE = 0x72;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000072L), 
Symbol.valueOf("amqp:message-annotations:map"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:message-annotations:map"),
     };
 
     private final MessageAnnotationsType annotationsType;
@@ -93,7 +95,8 @@ public class FastPathMessageAnnotationsType implements 
AMQPType<MessageAnnotatio
         WritableBuffer buffer = getEncoder().getBuffer();
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(annotationsType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
 
         MapType mapType = (MapType) getEncoder().getType(val.getValue());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
index e071ea9..3d5c7c4 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
@@ -22,20 +22,22 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.messaging.Properties;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathPropertiesType implements AMQPType<Properties>, 
FastPathDescribedTypeConstructor<Properties> {
 
+    private static final byte DESCRIPTOR_CODE = 0x73;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000073L), 
Symbol.valueOf("amqp:properties:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:properties:list"),
     };
 
     private final PropertiesType propertiesType;
@@ -164,11 +166,12 @@ public class FastPathPropertiesType implements 
AMQPType<Properties>, FastPathDes
         byte encodingCode = deduceEncodingCode(value, count);
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(propertiesType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
+        buffer.put(encodingCode);
 
         // Optimized step, no other data to be written.
-        if (count == 0 || encodingCode == EncodingCodes.LIST0) {
-            buffer.put(EncodingCodes.LIST0);
+        if (encodingCode == EncodingCodes.LIST0) {
             return;
         }
 
@@ -176,10 +179,8 @@ public class FastPathPropertiesType implements 
AMQPType<Properties>, FastPathDes
 
         if (encodingCode == EncodingCodes.LIST8) {
             fieldWidth = 1;
-            buffer.put(EncodingCodes.LIST8);
         } else {
             fieldWidth = 4;
-            buffer.put(EncodingCodes.LIST32);
         }
 
         int startIndex = buffer.position();

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathDispositionType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathDispositionType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathDispositionType.java
index c329aa7..4424cfa 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathDispositionType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathDispositionType.java
@@ -26,20 +26,30 @@ import org.apache.qpid.proton.amqp.transport.DeliveryState;
 import org.apache.qpid.proton.amqp.transport.Disposition;
 import org.apache.qpid.proton.amqp.transport.Role;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathDispositionType implements AMQPType<Disposition>, 
FastPathDescribedTypeConstructor<Disposition> {
 
+    private static final byte DESCRIPTOR_CODE = 0x15;
+    private static final byte ACCEPTED_DESCRIPTOR_CODE = 0x24;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000015L), 
Symbol.valueOf("amqp:disposition:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:disposition:list"),
+    };
+
+    private static final byte[] ACCEPTED_ENCODED_BYTES = new byte[] {
+        EncodingCodes.DESCRIBED_TYPE_INDICATOR,
+        EncodingCodes.SMALLULONG,
+        ACCEPTED_DESCRIPTOR_CODE,
+        EncodingCodes.LIST0
     };
 
     private final DispositionType dispositionType;
@@ -148,16 +158,16 @@ public class FastPathDispositionType implements 
AMQPType<Disposition>, FastPathD
         byte encodingCode = deduceEncodingCode(disposition, count);
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(dispositionType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
+        buffer.put(encodingCode);
 
         final int fieldWidth;
 
         if (encodingCode == EncodingCodes.LIST8) {
             fieldWidth = 1;
-            buffer.put(EncodingCodes.LIST8);
         } else {
             fieldWidth = 4;
-            buffer.put(EncodingCodes.LIST32);
         }
 
         int startIndex = buffer.position();
@@ -204,7 +214,11 @@ public class FastPathDispositionType implements 
AMQPType<Disposition>, FastPathD
                 getEncoder().writeBoolean(disposition.getSettled());
                 break;
             case 4:
-                getEncoder().writeObject(disposition.getState());
+                if (Accepted.getInstance().equals(disposition.getState())) {
+                    getEncoder().getBuffer().put(ACCEPTED_ENCODED_BYTES, 0, 
ACCEPTED_ENCODED_BYTES.length);
+                } else {
+                    getEncoder().writeObject(disposition.getState());
+                }
                 break;
             case 5:
                 getEncoder().writeBoolean(disposition.getBatchable());

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathFlowType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathFlowType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathFlowType.java
index 6f500be..7ed89e4 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathFlowType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathFlowType.java
@@ -22,20 +22,22 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.transport.Flow;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
 public class FastPathFlowType implements AMQPType<Flow>, 
FastPathDescribedTypeConstructor<Flow> {
 
+    private static final byte DESCRIPTOR_CODE = 0x13;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000013L), 
Symbol.valueOf("amqp:flow:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:flow:list"),
     };
 
     private final FlowType flowType;
@@ -159,16 +161,16 @@ public class FastPathFlowType implements AMQPType<Flow>, 
FastPathDescribedTypeCo
         byte encodingCode = deduceEncodingCode(flow, count);
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(flowType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
+        buffer.put(encodingCode);
 
         final int fieldWidth;
 
         if (encodingCode == EncodingCodes.LIST8) {
             fieldWidth = 1;
-            buffer.put(EncodingCodes.LIST8);
         } else {
             fieldWidth = 4;
-            buffer.put(EncodingCodes.LIST32);
         }
 
         int startIndex = buffer.position();

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/31f5fc97/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathTransferType.java
----------------------------------------------------------------------
diff --git 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathTransferType.java
 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathTransferType.java
index 79842db..d27e59c 100644
--- 
a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathTransferType.java
+++ 
b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FastPathTransferType.java
@@ -25,12 +25,12 @@ import org.apache.qpid.proton.amqp.transport.DeliveryState;
 import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
 import org.apache.qpid.proton.amqp.transport.Transfer;
 import org.apache.qpid.proton.codec.AMQPType;
-import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.DecodeException;
 import org.apache.qpid.proton.codec.Decoder;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
 import org.apache.qpid.proton.codec.TypeEncoding;
 import org.apache.qpid.proton.codec.WritableBuffer;
 
@@ -39,9 +39,11 @@ import org.apache.qpid.proton.codec.WritableBuffer;
  */
 public class FastPathTransferType implements AMQPType<Transfer>, 
FastPathDescribedTypeConstructor<Transfer> {
 
+    private static final byte DESCRIPTOR_CODE = 0x14;
+
     private static final Object[] DESCRIPTORS =
     {
-        UnsignedLong.valueOf(0x0000000000000014L), 
Symbol.valueOf("amqp:transfer:list"),
+        UnsignedLong.valueOf(DESCRIPTOR_CODE), 
Symbol.valueOf("amqp:transfer:list"),
     };
 
     private final TransferType transferType;
@@ -166,16 +168,16 @@ public class FastPathTransferType implements 
AMQPType<Transfer>, FastPathDescrib
         byte encodingCode = deduceEncodingCode(value, count);
 
         buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
-        getEncoder().writeUnsignedLong(transferType.getDescriptor());
+        buffer.put(EncodingCodes.SMALLULONG);
+        buffer.put(DESCRIPTOR_CODE);
+        buffer.put(encodingCode);
 
         final int fieldWidth;
 
         if (encodingCode == EncodingCodes.LIST8) {
             fieldWidth = 1;
-            buffer.put(EncodingCodes.LIST8);
         } else {
             fieldWidth = 4;
-            buffer.put(EncodingCodes.LIST32);
         }
 
         int startIndex = buffer.position();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to