Skip to content

Commit

Permalink
API review changes (#24747)
Browse files Browse the repository at this point in the history
Part of #24743

* Rename `DisableConcurrencyDetection` to `EnableThreadSafetyChecks`
* Rename `IRelationalCommand.PopulateFromTemplate` to `PopulateFrom`
* Rename parameter of above from `templateCommand` to `command`
  • Loading branch information
ajcvickers authored Apr 24, 2021
1 parent e51058e commit b0a3186
Show file tree
Hide file tree
Showing 31 changed files with 101 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private sealed class QueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>
private readonly string _partitionKey;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

public QueryingEnumerable(
CosmosQueryContext cosmosQueryContext,
Expand All @@ -48,7 +48,7 @@ public QueryingEnumerable(
Type contextType,
string partitionKeyFromExtension,
bool standAloneStateManager,
bool concurrencyDetectionEnabled)
bool threadSafetyChecksEnabled)
{
_cosmosQueryContext = cosmosQueryContext;
_sqlExpressionFactory = sqlExpressionFactory;
Expand All @@ -58,7 +58,7 @@ public QueryingEnumerable(
_contextType = contextType;
_queryLogger = cosmosQueryContext.QueryLogger;
_standAloneStateManager = standAloneStateManager;
_concurrencyDetectionEnabled = concurrencyDetectionEnabled;
_threadSafetyChecksEnabled = threadSafetyChecksEnabled;

var partitionKey = selectExpression.GetPartitionKey(cosmosQueryContext.ParameterValues);
if (partitionKey != null && partitionKeyFromExtension != null && partitionKeyFromExtension != partitionKey)
Expand Down Expand Up @@ -133,7 +133,7 @@ public Enumerator(QueryingEnumerable<T> queryingEnumerable)
_queryLogger = queryingEnumerable._queryLogger;
_standAloneStateManager = queryingEnumerable._standAloneStateManager;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _cosmosQueryContext.ConcurrencyDetector
: null;
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public AsyncEnumerator(QueryingEnumerable<T> queryingEnumerable, CancellationTok
_standAloneStateManager = queryingEnumerable._standAloneStateManager;
_cancellationToken = cancellationToken;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _cosmosQueryContext.ConcurrencyDetector
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ private sealed class ReadItemQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnume
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

public ReadItemQueryingEnumerable(
CosmosQueryContext cosmosQueryContext,
ReadItemExpression readItemExpression,
Func<CosmosQueryContext, JObject, T> shaper,
Type contextType,
bool standAloneStateManager,
bool concurrencyDetectionEnabled)
bool threadSafetyChecksEnabled)
{
_cosmosQueryContext = cosmosQueryContext;
_readItemExpression = readItemExpression;
_shaper = shaper;
_contextType = contextType;
_queryLogger = _cosmosQueryContext.QueryLogger;
_standAloneStateManager = standAloneStateManager;
_concurrencyDetectionEnabled = concurrencyDetectionEnabled;
_threadSafetyChecksEnabled = threadSafetyChecksEnabled;
}

public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -196,7 +196,7 @@ public Enumerator(ReadItemQueryingEnumerable<T> readItemEnumerable, Cancellation
_readItemEnumerable = readItemEnumerable;
_cancellationToken = cancellationToken;

_concurrencyDetector = readItemEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = readItemEnumerable._threadSafetyChecksEnabled
? _cosmosQueryContext.ConcurrencyDetector
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public partial class CosmosShapedQueryCompilingExpressionVisitor : ShapedQueryCo
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;
private readonly string _partitionKeyFromExtension;

/// <summary>
Expand All @@ -42,7 +42,7 @@ public CosmosShapedQueryCompilingExpressionVisitor(
_sqlExpressionFactory = sqlExpressionFactory;
_querySqlGeneratorFactory = querySqlGeneratorFactory;
_contextType = cosmosQueryCompilationContext.ContextType;
_concurrencyDetectionEnabled = dependencies.CoreSingletonOptions.IsConcurrencyDetectionEnabled;
_threadSafetyChecksEnabled = dependencies.CoreSingletonOptions.AreThreadSafetyChecksEnabled;
_partitionKeyFromExtension = cosmosQueryCompilationContext.PartitionKeyFromExtension;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
Expression.Constant(_partitionKeyFromExtension, typeof(string)),
Expression.Constant(
QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution),
Expression.Constant(_concurrencyDetectionEnabled));
Expression.Constant(_threadSafetyChecksEnabled));

case ReadItemExpression readItemExpression:

Expand All @@ -113,7 +113,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
Expression.Constant(_contextType),
Expression.Constant(
QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution),
Expression.Constant(_concurrencyDetectionEnabled));
Expression.Constant(_threadSafetyChecksEnabled));

default:
throw new NotSupportedException(CoreStrings.UnhandledExpressionNode(shapedQueryExpression.QueryExpression));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ private sealed class QueryingEnumerable<T> : IAsyncEnumerable<T>, IEnumerable<T>
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

public QueryingEnumerable(
QueryContext queryContext,
IEnumerable<ValueBuffer> innerEnumerable,
Func<QueryContext, ValueBuffer, T> shaper,
Type contextType,
bool standAloneStateManager,
bool concurrencyDetectionEnabled)
bool threadSafetyChecksEnabled)
{
_queryContext = queryContext;
_innerEnumerable = innerEnumerable;
_shaper = shaper;
_contextType = contextType;
_queryLogger = queryContext.QueryLogger;
_standAloneStateManager = standAloneStateManager;
_concurrencyDetectionEnabled = concurrencyDetectionEnabled;
_threadSafetyChecksEnabled = threadSafetyChecksEnabled;
}

public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -86,7 +86,7 @@ public Enumerator(QueryingEnumerable<T> queryingEnumerable, CancellationToken ca
_cancellationToken = cancellationToken;
Current = default!;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _queryContext.ConcurrencyDetector
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal
public partial class InMemoryShapedQueryCompilingExpressionVisitor : ShapedQueryCompilingExpressionVisitor
{
private readonly Type _contextType;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -29,7 +29,7 @@ public InMemoryShapedQueryCompilingExpressionVisitor(
: base(dependencies, queryCompilationContext)
{
_contextType = queryCompilationContext.ContextType;
_concurrencyDetectionEnabled = dependencies.CoreSingletonOptions.IsConcurrencyDetectionEnabled;
_threadSafetyChecksEnabled = dependencies.CoreSingletonOptions.AreThreadSafetyChecksEnabled;
}

/// <summary>
Expand Down Expand Up @@ -93,7 +93,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
Expression.Constant(_contextType),
Expression.Constant(
QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution),
Expression.Constant(_concurrencyDetectionEnabled));
Expression.Constant(_threadSafetyChecksEnabled));
}

private static readonly MethodInfo _tableMethodInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static int ExecuteSqlRaw(
Check.NotNull(parameters, nameof(parameters));

var facadeDependencies = GetFacadeDependencies(databaseFacade);
var concurrencyDetector = facadeDependencies.CoreOptions.IsConcurrencyDetectionEnabled
var concurrencyDetector = facadeDependencies.CoreOptions.AreThreadSafetyChecksEnabled
? facadeDependencies.ConcurrencyDetector
: null;
var logger = facadeDependencies.CommandLogger;
Expand Down Expand Up @@ -398,7 +398,7 @@ public static async Task<int> ExecuteSqlRawAsync(
Check.NotNull(parameters, nameof(parameters));

var facadeDependencies = GetFacadeDependencies(databaseFacade);
var concurrencyDetector = facadeDependencies.CoreOptions.IsConcurrencyDetectionEnabled
var concurrencyDetector = facadeDependencies.CoreOptions.AreThreadSafetyChecksEnabled
? facadeDependencies.ConcurrencyDetector
: null;
var logger = facadeDependencies.CommandLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public sealed record RelationalModelRuntimeInitializerDependencies
/// </summary>
[EntityFrameworkInternal]
public RelationalModelRuntimeInitializerDependencies(
RelationalModelDependencies singletonModelDependencies,
RelationalModelDependencies relationalModelDependencies,
IRelationalAnnotationProvider relationalAnnotationProvider)
{
Check.NotNull(singletonModelDependencies, nameof(singletonModelDependencies));
Check.NotNull(relationalModelDependencies, nameof(relationalModelDependencies));
Check.NotNull(relationalAnnotationProvider, nameof(relationalAnnotationProvider));

RelationalModelDependencies = singletonModelDependencies;
RelationalModelDependencies = relationalModelDependencies;
RelationalAnnotationProvider = relationalAnnotationProvider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FromSqlQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _detailedErrorsEnabled;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -46,7 +46,7 @@ public FromSqlQueryingEnumerable(
Type contextType,
bool standAloneStateManager,
bool detailedErrorsEnabled,
bool concurrencyDetectionEnabled)
bool threadSafetyChecksEnabled)
{
_relationalQueryContext = relationalQueryContext;
_relationalCommandCache = relationalCommandCache;
Expand All @@ -56,7 +56,7 @@ public FromSqlQueryingEnumerable(
_queryLogger = relationalQueryContext.QueryLogger;
_standAloneStateManager = standAloneStateManager;
_detailedErrorsEnabled = detailedErrorsEnabled;
_concurrencyDetectionEnabled = concurrencyDetectionEnabled;
_threadSafetyChecksEnabled = threadSafetyChecksEnabled;
}

/// <summary>
Expand Down Expand Up @@ -176,7 +176,7 @@ public Enumerator(FromSqlQueryingEnumerable<T> queryingEnumerable)
_detailedErrorsEnabled = queryingEnumerable._detailedErrorsEnabled;
Current = default!;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _relationalQueryContext.ConcurrencyDetector
: null;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ private static bool InitializeReader(Enumerator enumerator)
enumerator._relationalQueryContext.ParameterValues);

var relationalCommand = enumerator._relationalCommand = enumerator._relationalQueryContext.Connection.RentCommand();
relationalCommand.PopulateFromTemplate(relationalCommandTemplate);
relationalCommand.PopulateFrom(relationalCommandTemplate);

enumerator._dataReader = relationalCommand.ExecuteReader(
new RelationalCommandParameterObject(
Expand Down Expand Up @@ -289,7 +289,7 @@ public AsyncEnumerator(FromSqlQueryingEnumerable<T> queryingEnumerable)
_detailedErrorsEnabled = queryingEnumerable._detailedErrorsEnabled;
Current = default!;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _relationalQueryContext.ConcurrencyDetector
: null;
}
Expand Down Expand Up @@ -344,7 +344,7 @@ private static async Task<bool> InitializeReaderAsync(AsyncEnumerator enumerator
enumerator._relationalQueryContext.ParameterValues);

var relationalCommand = enumerator._relationalCommand = enumerator._relationalQueryContext.Connection.RentCommand();
relationalCommand.PopulateFromTemplate(relationalCommandTemplate);
relationalCommand.PopulateFrom(relationalCommandTemplate);

enumerator._dataReader = await relationalCommand.ExecuteReaderAsync(
new RelationalCommandParameterObject(
Expand Down
14 changes: 7 additions & 7 deletions src/EFCore.Relational/Query/Internal/SingleQueryingEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SingleQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _detailedErrorsEnabled;
private readonly bool _concurrencyDetectionEnabled;
private readonly bool _threadSafetyChecksEnabled;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -43,7 +43,7 @@ public SingleQueryingEnumerable(
Type contextType,
bool standAloneStateManager,
bool detailedErrorsEnabled,
bool concurrencyDetectionEnabled)
bool threadSafetyChecksEnabled)
{
_relationalQueryContext = relationalQueryContext;
_relationalCommandCache = relationalCommandCache;
Expand All @@ -52,7 +52,7 @@ public SingleQueryingEnumerable(
_queryLogger = relationalQueryContext.QueryLogger;
_standAloneStateManager = standAloneStateManager;
_detailedErrorsEnabled = detailedErrorsEnabled;
_concurrencyDetectionEnabled = concurrencyDetectionEnabled;
_threadSafetyChecksEnabled = threadSafetyChecksEnabled;
}

/// <summary>
Expand Down Expand Up @@ -143,7 +143,7 @@ public Enumerator(SingleQueryingEnumerable<T> queryingEnumerable)
_detailedErrorsEnabled = queryingEnumerable._detailedErrorsEnabled;
Current = default!;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _relationalQueryContext.ConcurrencyDetector
: null;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ private static bool InitializeReader(Enumerator enumerator)
enumerator._relationalQueryContext.ParameterValues);

var relationalCommand = enumerator._relationalCommand = enumerator._relationalQueryContext.Connection.RentCommand();
relationalCommand.PopulateFromTemplate(relationalCommandTemplate);
relationalCommand.PopulateFrom(relationalCommandTemplate);

enumerator._dataReader = relationalCommand.ExecuteReader(
new RelationalCommandParameterObject(
Expand Down Expand Up @@ -281,7 +281,7 @@ public AsyncEnumerator(SingleQueryingEnumerable<T> queryingEnumerable)
_detailedErrorsEnabled = queryingEnumerable._detailedErrorsEnabled;
Current = default!;

_concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
_concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
? _relationalQueryContext.ConcurrencyDetector
: null;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ private static async Task<bool> InitializeReaderAsync(AsyncEnumerator enumerator
enumerator._relationalQueryContext.ParameterValues);

var relationalCommand = enumerator._relationalCommand = enumerator._relationalQueryContext.Connection.RentCommand();
relationalCommand.PopulateFromTemplate(relationalCommandTemplate);
relationalCommand.PopulateFrom(relationalCommandTemplate);

enumerator._dataReader = await relationalCommand.ExecuteReaderAsync(
new RelationalCommandParameterObject(
Expand Down
Loading

0 comments on commit b0a3186

Please sign in to comment.