Пример #1
0
        public int encodedSize(QueryMessage msg, int version) {
          int size = CBUtil.sizeOfLongString(msg.query);

          if (version == 1) {
            size += CBUtil.sizeOfConsistencyLevel(msg.options.getConsistency());
          } else {
            size += QueryOptions.codec.encodedSize(msg.options, version);
          }
          return size;
        }
Пример #2
0
 public QueryMessage decode(ByteBuf body, int version) {
   String query = CBUtil.readLongString(body);
   if (version == 1) {
     ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body);
     return new QueryMessage(
         query,
         QueryOptions.fromProtocolV1(consistency, Collections.<ByteBuffer>emptyList()));
   } else {
     return new QueryMessage(query, QueryOptions.codec.decode(body, version));
   }
 }
Пример #3
0
 public RegisterMessage decode(ByteBuf body, int version) {
   int length = body.readUnsignedShort();
   List<Event.Type> eventTypes = new ArrayList<Event.Type>(length);
   for (int i = 0; i < length; ++i)
     eventTypes.add(CBUtil.readEnumValue(Event.Type.class, body));
   return new RegisterMessage(eventTypes);
 }
Пример #4
0
 public ChannelBuffer encode(PrepareMessage msg) {
   return CBUtil.longStringToCB(msg.query);
 }
Пример #5
0
 public PrepareMessage decode(ChannelBuffer body) {
   String query = CBUtil.readLongString(body);
   return new PrepareMessage(query);
 }
Пример #6
0
 public int encodedSize(RegisterMessage msg, int version) {
   int size = 2;
   for (Event.Type type : msg.eventTypes) size += CBUtil.sizeOfEnumValue(type);
   return size;
 }
Пример #7
0
 public void encode(RegisterMessage msg, ByteBuf dest, int version) {
   dest.writeShort(msg.eventTypes.size());
   for (Event.Type type : msg.eventTypes) CBUtil.writeEnumValue(type, dest);
 }
Пример #8
0
 public void encode(QueryMessage msg, ByteBuf dest, int version) {
   CBUtil.writeLongString(msg.query, dest);
   if (version == 1) CBUtil.writeConsistencyLevel(msg.options.getConsistency(), dest);
   else QueryOptions.codec.encode(msg.options, dest, version);
 }