public RequestFrame GetFrame(short streamId) { //protocol v2: <type><n><query_1>...<query_n><consistency> //protocol v3: <type><n><query_1>...<query_n><consistency><flags>[<serial_consistency>][<timestamp>] var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _headerFlags, streamId, OpCode); wb.WriteByte((byte) _type); wb.WriteInt16((short) _requests.Count); foreach (var br in _requests) { br.WriteToBatch((byte)ProtocolVersion, wb); } wb.WriteInt16((short) Consistency); if (ProtocolVersion >= 3) { wb.WriteByte((byte)_batchFlags); } if (_serialConsistency != null) { wb.WriteInt16((short)_serialConsistency.Value); } if (_timestamp != null) { //Expressed in microseconds wb.WriteLong(TypeCodec.ToUnixTime(_timestamp.Value).Ticks / 10); } return wb.GetFrame(); }
public RequestFrame GetFrame(short streamId) { //protocol v2: <type><n><query_1>...<query_n><consistency> //protocol v3: <type><n><query_1>...<query_n><consistency><flags>[<serial_consistency>][<timestamp>] var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _headerFlags, streamId, OpCode); wb.WriteByte((byte)_type); wb.WriteInt16((short)_requests.Count); foreach (var br in _requests) { br.WriteToBatch((byte)ProtocolVersion, wb); } wb.WriteInt16((short)Consistency); if (ProtocolVersion >= 3) { wb.WriteByte((byte)_batchFlags); } if (_serialConsistency != null) { wb.WriteInt16((short)_serialConsistency.Value); } if (_timestamp != null) { //Expressed in microseconds wb.WriteLong(TypeCodec.ToUnixTime(_timestamp.Value).Ticks / 10); } return(wb.GetFrame()); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(RequestFrame.ProtocolRequestVersionByte, 0x00, (byte)_streamId, OpCode); wb.WriteStringList(_eventTypes); return wb.GetFrame(); }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, 0x00, streamId, OpCode); wb.WriteStringList(_eventTypes); return wb.GetFrame(); }
//TODO: Move to ExecuteRequest and QueryRequest internal void Write(BEBinaryWriter wb, byte protocolVersion, bool isPrepared) { //protocol v1: <query><n><value_1>....<value_n><consistency> //protocol v2: <query><consistency><flags>[<n><value_1>...<value_n>][<result_page_size>][<paging_state>][<serial_consistency>] //protocol v3: <query><consistency><flags>[<n>[name_1]<value_1>...[name_n]<value_n>][<result_page_size>][<paging_state>][<serial_consistency>][<timestamp>] var flags = GetFlags(); if (protocolVersion > 1) { wb.WriteUInt16((ushort)Consistency); wb.WriteByte((byte)flags); } if (flags.HasFlag(QueryFlags.Values)) { wb.WriteUInt16((ushort)Values.Length); for (var i = 0; i < Values.Length; i++) { if (flags.HasFlag(QueryFlags.WithNameForValues)) { var name = ValueNames[i]; wb.WriteString(name); } var v = Values[i]; var bytes = TypeCodec.Encode(protocolVersion, v); wb.WriteBytes(bytes); } } else if (protocolVersion == 1 && isPrepared) { //n values is not optional on protocol v1 //Write 0 values wb.WriteUInt16(0); } if (protocolVersion == 1) { //Protocol v1 ends here wb.WriteUInt16((ushort)Consistency); return; } if ((flags & QueryFlags.PageSize) == QueryFlags.PageSize) { wb.WriteInt32(PageSize); } if ((flags & QueryFlags.WithPagingState) == QueryFlags.WithPagingState) { wb.WriteBytes(PagingState); } if ((flags & QueryFlags.WithSerialConsistency) == QueryFlags.WithSerialConsistency) { wb.WriteUInt16((ushort)SerialConsistency); } if (Timestamp != null) { //Expressed in microseconds wb.WriteLong(TypeCodec.ToUnixTime(Timestamp.Value).Ticks / 10); } }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, 0x00, streamId, OpCode); wb.WriteStringList(_eventTypes); return(wb.GetFrame()); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(0x01, 0x00, (byte)_streamId, OpCode); wb.WriteBytes(_token); return(wb.GetFrame()); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(0x01, 0x00, (byte)_streamId, OpCode); wb.WriteStringList(_eventTypes); return(wb.GetFrame()); }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _flags, streamId, OpCode); wb.WriteShortBytes(_id); _queryOptions.Write(wb, (byte)ProtocolVersion, true); return(wb.GetFrame()); }
public RequestFrame GetFrame(byte protocolVersionByte) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(protocolVersionByte, _flags, (byte)_streamId, OpCode); wb.WriteShortBytes(_id); _queryProtocolOptions.Write(wb, _consistency, protocolVersionByte); return(wb.GetFrame()); }
public void WriteToBatch(byte protocolVersion, BEBinaryWriter wb) { wb.WriteByte(1); //prepared query wb.WriteShortBytes(_id); wb.WriteUInt16((ushort)_queryOptions.Values.Length); for (int i = 0; i < _metadata.Columns.Length; i++) { byte[] bytes = TypeCodec.Encode(protocolVersion, _queryOptions.Values[i]); wb.WriteBytes(bytes); } }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _headerFlags, streamId, OpCode); wb.WriteLongString(_cqlQuery); _queryOptions.Write(wb, (byte)ProtocolVersion, false); return(wb.GetFrame()); }
public void WriteToBatch(BEBinaryWriter wb) { wb.WriteByte(1); //prepared query wb.WriteShortBytes(_id); wb.WriteUInt16((ushort)_queryProtocolOptions.Values.Length); for (int i = 0; i < _metadata.Columns.Length; i++) { byte[] bytes = TypeInterpreter.InvCqlConvert(_queryProtocolOptions.Values[i]); wb.WriteBytes(bytes); } }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, (byte)_headerFlags, streamId, OpCode); if (Payload != null) { wb.WriteBytesMap(Payload); } wb.WriteLongString(Query); return(wb.GetFrame()); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(0x01, 0x00, (byte)_streamId, OpCode); wb.WriteUInt16((ushort)_options.Count); foreach(var kv in _options) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return wb.GetFrame(); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(RequestFrame.ProtocolRequestVersionByte, 0x00, (byte)_streamId, OpCode); wb.WriteUInt16((ushort)_credentials.Count); foreach (var kv in _credentials) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return wb.GetFrame(); }
public RequestFrame GetFrame() { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(0x01, 0x00, (byte)_streamId, OpCode); wb.WriteUInt16((ushort)_credentials.Count); foreach (var kv in _credentials) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return(wb.GetFrame()); }
public RequestFrame GetFrame(byte protocolVersionByte) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader(protocolVersionByte, 0x00, (byte)_streamId, OpCode); wb.WriteUInt16((ushort)_options.Count); foreach (KeyValuePair <string, string> kv in _options) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return(wb.GetFrame()); }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, 0x00, streamId, OpCode); wb.WriteUInt16((ushort)_options.Count); foreach (var kv in _options) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return(wb.GetFrame()); }
internal void Write(BEBinaryWriter wb, ConsistencyLevel?extConsistency, byte protocolVersion) { //protocol v1: <id><n><value_1>....<value_n><consistency> //protocol v2: <id><consistency><flags>[<n><value_1>...<value_n>][<result_page_size>][<paging_state>][<serial_consistency>] if ((ushort)(extConsistency ?? Consistency) >= (ushort)ConsistencyLevel.Serial) { throw new InvalidQueryException("Serial consistency specified as a non-serial one."); } if (protocolVersion > 1) { wb.WriteUInt16((ushort)(extConsistency ?? Consistency)); wb.WriteByte((byte)Flags); } if ((Flags & QueryFlags.Values) == QueryFlags.Values) { wb.WriteUInt16((ushort)Values.Length); for (int i = 0; i < Values.Length; i++) { var bytes = TypeInterpreter.InvCqlConvert(Values[i]); wb.WriteBytes(bytes); } } if (protocolVersion == 1) { wb.WriteUInt16((ushort)(extConsistency ?? Consistency)); } else { if ((Flags & QueryFlags.PageSize) == QueryFlags.PageSize) { wb.WriteInt32(PageSize); } if ((Flags & QueryFlags.WithPagingState) == QueryFlags.WithPagingState) { wb.WriteBytes(PagingState); } if ((Flags & QueryFlags.WithSerialConsistency) == QueryFlags.WithSerialConsistency) { if ((ushort)(SerialConsistency) < (ushort)ConsistencyLevel.Serial) { throw new InvalidQueryException("Non-serial consistency specified as a serial one."); } wb.WriteUInt16((ushort)SerialConsistency); } } }
public RequestFrame GetFrame(short streamId) { if (ProtocolVersion > 1) { throw new NotSupportedException("Credentials request is only supported in C* = 1.2.x"); } var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, 0x00, streamId, OpCode); wb.WriteUInt16((ushort) _credentials.Count); foreach (var kv in _credentials) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return wb.GetFrame(); }
public RequestFrame GetFrame(byte protocolVersionByte) { if (protocolVersionByte != RequestFrame.ProtocolV1RequestVersionByte) { throw new NotSupportedException("Credentials request is supported in C* <= 1.2.x"); } var wb = new BEBinaryWriter(); wb.WriteFrameHeader(protocolVersionByte, 0x00, (byte)_streamId, OpCode); wb.WriteUInt16((ushort)_credentials.Count); foreach (KeyValuePair <string, string> kv in _credentials) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return(wb.GetFrame()); }
public RequestFrame GetFrame(short streamId) { if (ProtocolVersion > 1) { throw new NotSupportedException("Credentials request is only supported in C* = 1.2.x"); } var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, 0x00, streamId, OpCode); wb.WriteUInt16((ushort)_credentials.Count); foreach (var kv in _credentials) { wb.WriteString(kv.Key); wb.WriteString(kv.Value); } return(wb.GetFrame()); }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); if (Payload != null) { _headerFlags |= FrameHeader.HeaderFlag.CustomPayload; } wb.WriteFrameHeader((byte)ProtocolVersion, (byte)_headerFlags, streamId, OpCode); if (Payload != null) { //A custom payload for this request wb.WriteBytesMap(Payload); } wb.WriteLongString(_cqlQuery); _queryOptions.Write(wb, (byte)ProtocolVersion, false); return(wb.GetFrame()); }
public RequestFrame GetFrame(byte protocolVersionByte) { if (protocolVersionByte != RequestFrame.ProtocolV2RequestVersionByte) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } var wb = new BEBinaryWriter(); wb.WriteFrameHeader(protocolVersionByte, _flags, (byte)_streamId, OpCode); wb.WriteByte((byte)_type); wb.WriteInt16((short)_requests.Count); foreach (IQueryRequest br in _requests) { br.WriteToBatch(wb); } wb.WriteInt16((short)_consistency); return(wb.GetFrame()); }
public void WriteToBatch(byte protocolVersion, BEBinaryWriter wb) { //not a prepared query wb.WriteByte(0); wb.WriteLongString(_cqlQuery); if (_queryOptions.Values == null || _queryOptions.Values.Length == 0) { //not values wb.WriteInt16(0); } else { wb.WriteUInt16((ushort)_queryOptions.Values.Length); for (var i = 0; i < _queryOptions.Values.Length; i++) { var bytes = TypeCodec.Encode(protocolVersion, _queryOptions.Values[i]); wb.WriteBytes(bytes); } } }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); if (Payload != null) { _headerFlags |= FrameHeader.HeaderFlag.CustomPayload; } wb.WriteFrameHeader((byte)ProtocolVersion, (byte)_headerFlags, streamId, OpCode); if (Payload != null) { //A custom payload for this request wb.WriteBytesMap(Payload); } wb.WriteLongString(_cqlQuery); _queryOptions.Write(wb, (byte)ProtocolVersion, false); return wb.GetFrame(); }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _flags, streamId, OpCode); wb.WriteShortBytes(_id); _queryOptions.Write(wb, (byte)ProtocolVersion, true); return wb.GetFrame(); }
public void WriteToBatch(byte protocolVersion, BEBinaryWriter wb) { wb.WriteByte(1); //prepared query wb.WriteShortBytes(_id); wb.WriteUInt16((ushort) _queryOptions.Values.Length); for (int i = 0; i < _metadata.Columns.Length; i++) { byte[] bytes = TypeCodec.Encode(protocolVersion, _queryOptions.Values[i]); wb.WriteBytes(bytes); } }
public RequestFrame GetFrame(short streamId) { var wb = new BEBinaryWriter(); wb.WriteFrameHeader((byte)ProtocolVersion, _headerFlags, streamId, OpCode); wb.WriteLongString(_cqlQuery); _queryOptions.Write(wb, (byte)ProtocolVersion, false); return wb.GetFrame(); }
public void WriteToBatch(byte protocolVersion, BEBinaryWriter wb) { //not a prepared query wb.WriteByte(0); wb.WriteLongString(_cqlQuery); if (_queryOptions.Values == null || _queryOptions.Values.Length == 0) { //not values wb.WriteInt16(0); } else { wb.WriteUInt16((ushort) _queryOptions.Values.Length); for (var i = 0; i < _queryOptions.Values.Length; i++) { var bytes = TypeCodec.Encode(protocolVersion, _queryOptions.Values[i]); wb.WriteBytes(bytes); } } }