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; }
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)); } }
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); }
public ChannelBuffer encode(PrepareMessage msg) { return CBUtil.longStringToCB(msg.query); }
public PrepareMessage decode(ChannelBuffer body) { String query = CBUtil.readLongString(body); return new PrepareMessage(query); }
public int encodedSize(RegisterMessage msg, int version) { int size = 2; for (Event.Type type : msg.eventTypes) size += CBUtil.sizeOfEnumValue(type); return size; }
public void encode(RegisterMessage msg, ByteBuf dest, int version) { dest.writeShort(msg.eventTypes.size()); for (Event.Type type : msg.eventTypes) CBUtil.writeEnumValue(type, dest); }
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); }