public BatchRequest(ProtocolVersion protocolVersion, BatchStatement statement, ConsistencyLevel consistency, Policies policies) { if (!protocolVersion.SupportsBatch()) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } _type = statement.BatchType; _requests = statement.Queries .Select(q => q.CreateBatchRequest(protocolVersion)) .ToArray(); Consistency = consistency; if (statement.IsTracing) { _headerFlags = FrameHeader.HeaderFlag.Tracing; } if (statement.SerialConsistencyLevel != ConsistencyLevel.Any) { if (!protocolVersion.SupportsTimestamp()) { throw new NotSupportedException("Serial consistency level for BATCH request is supported in Cassandra 2.1 or above."); } if (statement.SerialConsistencyLevel < ConsistencyLevel.Serial) { throw new RequestInvalidException("Non-serial consistency specified as a serial one."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _serialConsistency = statement.SerialConsistencyLevel; } _timestamp = GetRequestTimestamp(protocolVersion, statement, policies); if (_timestamp != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } }
public BatchRequest(ProtocolVersion protocolVersion, BatchStatement statement, ConsistencyLevel consistency, Configuration config) { if (!protocolVersion.SupportsBatch()) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } _type = statement.BatchType; _requests = statement.Queries .Select(q => q.CreateBatchRequest(protocolVersion)) .ToArray(); Consistency = consistency; if (statement.IsTracing) { _headerFlags = FrameHeader.HeaderFlag.Tracing; } _serialConsistency = config.QueryOptions.GetSerialConsistencyLevelOrDefault(statement); _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _timestamp = GetRequestTimestamp(protocolVersion, statement, config.Policies); if (_timestamp != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } }
public BatchRequest(ProtocolVersion protocolVersion, BatchStatement statement, ConsistencyLevel consistency, IRequestOptions requestOptions) { if (!protocolVersion.SupportsBatch()) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } _type = statement.BatchType; _requests = statement.Queries .Select(q => q.CreateBatchRequest(protocolVersion)) .ToArray(); Consistency = consistency; if (statement.IsTracing) { _headerFlags = FrameHeader.HeaderFlag.Tracing; } SerialConsistency = requestOptions.GetSerialConsistencyLevelOrDefault(statement); _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _timestamp = BatchRequest.GetRequestTimestamp(protocolVersion, statement, requestOptions.TimestampGenerator); if (_timestamp != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } if (protocolVersion.SupportsKeyspaceInRequest() && statement.Keyspace != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithKeyspace; _keyspace = statement.Keyspace; } }
public BatchRequest( ISerializer serializer, IDictionary <string, byte[]> payload, BatchStatement statement, ConsistencyLevel consistency, IRequestOptions requestOptions) : base(serializer, statement.IsTracing, payload) { if (!serializer.ProtocolVersion.SupportsBatch()) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } if (statement.Timestamp != null && !serializer.ProtocolVersion.SupportsTimestamp()) { throw new NotSupportedException( "Timestamp for BATCH request is supported in Cassandra 2.1 or above."); } _type = statement.BatchType; _requests = statement.Queries .Select(q => q.CreateBatchRequest(serializer)) .ToArray(); Consistency = consistency; if (!serializer.ProtocolVersion.SupportsBatchFlags()) { // if flags are not supported, then the following additional parameters aren't either return; } SerialConsistency = requestOptions.GetSerialConsistencyLevelOrDefault(statement); _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; if (serializer.ProtocolVersion.SupportsTimestamp()) { _timestamp = BatchRequest.GetRequestTimestamp(statement, requestOptions.TimestampGenerator); } if (_timestamp != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } _keyspace = statement.Keyspace; if (serializer.ProtocolVersion.SupportsKeyspaceInRequest() && _keyspace != null) { _batchFlags |= QueryProtocolOptions.QueryFlags.WithKeyspace; } }
public BatchRequest(int protocolVersion, BatchStatement statement, ConsistencyLevel consistency) { ProtocolVersion = protocolVersion; if (ProtocolVersion < 2) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } var subRequests = new List <IQueryRequest>(); foreach (var q in statement.Queries) { subRequests.Add(q.CreateBatchRequest(ProtocolVersion)); } _type = statement.BatchType; _requests = subRequests; Consistency = consistency; _timestamp = statement.Timestamp; if (statement.IsTracing) { _headerFlags = 0x02; } if (statement.SerialConsistencyLevel != ConsistencyLevel.Any) { if (protocolVersion < 3) { throw new NotSupportedException("Serial consistency level for BATCH request is supported in Cassandra 2.1 or above."); } if (statement.SerialConsistencyLevel < ConsistencyLevel.Serial) { throw new RequestInvalidException("Non-serial consistency specified as a serial one."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _serialConsistency = statement.SerialConsistencyLevel; } if (_timestamp != null) { if (protocolVersion < 3) { throw new NotSupportedException("Timestamp for BATCH request is supported in Cassandra 2.1 or above."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } }
public BatchRequest(int protocolVersion, BatchStatement statement, ConsistencyLevel consistency) { ProtocolVersion = protocolVersion; if (ProtocolVersion < 2) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } var subRequests = new List<IQueryRequest>(); foreach (var q in statement.Queries) { subRequests.Add(q.CreateBatchRequest(ProtocolVersion)); } _type = statement.BatchType; _requests = subRequests; Consistency = consistency; _timestamp = statement.Timestamp; if (statement.IsTracing) { _headerFlags = 0x02; } if (statement.SerialConsistencyLevel != ConsistencyLevel.Any) { if (protocolVersion < 3) { throw new NotSupportedException("Serial consistency level for BATCH request is supported in Cassandra 2.1 or above."); } if (statement.SerialConsistencyLevel < ConsistencyLevel.Serial) { throw new RequestInvalidException("Non-serial consistency specified as a serial one."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _serialConsistency = statement.SerialConsistencyLevel; } if (_timestamp != null) { if (protocolVersion < 3) { throw new NotSupportedException("Timestamp for BATCH request is supported in Cassandra 2.1 or above."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } }
public BatchRequest(int protocolVersion, BatchStatement statement, ConsistencyLevel consistency) { if (protocolVersion < 2) { throw new NotSupportedException("Batch request is supported in C* >= 2.0.x"); } _type = statement.BatchType; _requests = statement.Queries .Select(q => q.CreateBatchRequest(protocolVersion)) .ToArray(); Consistency = consistency; _timestamp = statement.Timestamp; if (statement.IsTracing) { _headerFlags = FrameHeader.HeaderFlag.Tracing; } if (statement.SerialConsistencyLevel != ConsistencyLevel.Any) { if (protocolVersion < 3) { throw new NotSupportedException("Serial consistency level for BATCH request is supported in Cassandra 2.1 or above."); } if (statement.SerialConsistencyLevel < ConsistencyLevel.Serial) { throw new RequestInvalidException("Non-serial consistency specified as a serial one."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithSerialConsistency; _serialConsistency = statement.SerialConsistencyLevel; } if (_timestamp != null) { if (protocolVersion < 3) { throw new NotSupportedException("Timestamp for BATCH request is supported in Cassandra 2.1 or above."); } _batchFlags |= QueryProtocolOptions.QueryFlags.WithDefaultTimestamp; } }