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; } }