/// <summary> /// Returns the default name that would be used for this index. /// </summary> /// <param name="index">The index.</param> /// <returns>The default name that would be used for this index.</returns> public static string GetDefaultDatabaseName(this IReadOnlyIndex index) { var tableName = index.DeclaringEntityType.GetTableName(); var baseName = new StringBuilder() .Append("IX_") .Append(tableName) .Append('_') .AppendJoin(index.Properties.Select(p => p.GetColumnBaseName()), "_") .ToString(); return(Uniquifier.Truncate(baseName, index.DeclaringEntityType.Model.GetMaxIdentifierLength())); }
/// <summary> /// Returns the value of a guid. /// </summary> /// <param name="index">Index of the node.</param> /// <param name="propertyName">Name of the property to read.</param> public virtual Guid GetGuidValue(IReadOnlyIndex index, string propertyName) { Debug.Assert(Contains(index)); IReadOnlyNodeState State = StateTable[index]; Debug.Assert(State.ValuePropertyTypeTable.ContainsKey(propertyName)); Debug.Assert(State.ValuePropertyTypeTable[propertyName] == Constants.ValuePropertyType.Guid); Guid Value = NodeTreeHelper.GetGuid(State.Node, propertyName); return(Value); }
private static IEnumerable <DocumentInfo> GetTermDocuments(IReadOnlyIndex index, string term) { if (term.EndsWith("*")) { return(index.GetWordsStartWith(term.TrimEnd('*')).SelectMany(wordDocuments => wordDocuments)); } if (term.StartsWith("*")) { term = term.TrimStart('*'); return(index.GetWordsMatching(word => word.EndsWith(term, index.WordComparison)).SelectMany(wordDocuments => wordDocuments)); } return(index.GetExactWord(term)); }
public static string ToDebugString( [NotNull] this IReadOnlyIndex index, MetadataDebugStringOptions options, int indent = 0) { var builder = new StringBuilder(); var indentString = new string(' ', indent); builder.Append(indentString); var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0; if (singleLine) { builder.Append("Index: "); } builder .AppendJoin( ", ", index.Properties.Select( p => singleLine ? p.DeclaringEntityType.DisplayName() + "." + p.Name : p.Name)); builder.Append(" " + index.Name ?? "<unnamed>"); if (index.IsUnique) { builder.Append(" Unique"); } if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(index.AnnotationsToDebugString(indent + 2)); } return(builder.ToString()); }
bool IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .ContainsKey(IReadOnlyIndex key) { return(ContainsKey((ILayoutIndex)key)); }
IReadOnlyNodeState IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .this[IReadOnlyIndex key] { get { return(this[(ILayoutIndex)key]); } set { this[(ILayoutIndex)key] = (ILayoutNodeState)value; } }
public IndexRanking(IReadOnlyIndex index, AtomicQuery resolvedQuery, int ranking) { Index = index; ResolvedQuery = resolvedQuery; Ranking = ranking; }
IReadOnlyNodeState IReadOnlyDictionary <IReadOnlyIndex, IReadOnlyNodeState> .this[IReadOnlyIndex key] { get { return(this[(IFocusIndex)key]); } }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static bool AreCompatibleForNpgsql( [NotNull] this IReadOnlyIndex index, [NotNull] IReadOnlyIndex duplicateIndex, in StoreObjectIdentifier storeObject,
/// <summary> /// Returns the text search configuration for this tsvector expression index, or <c>null</c> if this is not a /// tsvector expression index. /// </summary> /// <param name="index">The index.</param> /// <remarks> /// https://www.postgresql.org/docs/current/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX /// </remarks> public static string?GetTsVectorConfig(this IReadOnlyIndex index) => (string?)index[NpgsqlAnnotationNames.TsVectorConfig];
/// <summary> /// Returns a value indicating whether the index is created concurrently. /// </summary> /// <param name="index">The index.</param> /// <returns><c>true</c> if the index is created concurrently.</returns> public static bool?IsCreatedConcurrently(this IReadOnlyIndex index) => (bool?)index[NpgsqlAnnotationNames.CreatedConcurrently];
/// <summary> /// Returns included property names, or <c>null</c> if they have not been specified. /// </summary> /// <param name="index">The index.</param> /// <returns>The included property names, or <c>null</c> if they have not been specified.</returns> public static IReadOnlyList <string>?GetIncludeProperties(this IReadOnlyIndex index) => (IReadOnlyList <string>?)index[NpgsqlAnnotationNames.IndexInclude];
/// <summary> /// Returns the index method to be used, or <c>null</c> if it hasn't been specified. /// <c>null</c> selects the default (currently <c>btree</c>). /// </summary> /// <remarks> /// http://www.postgresql.org/docs/current/static/sql-createindex.html /// </remarks> public static string?GetMethod(this IReadOnlyIndex index) => (string?)index[NpgsqlAnnotationNames.IndexMethod];
/// <summary> /// Returns the column NULL sort orders to be used, or <c>null</c> if they have not been specified. /// </summary> /// <remarks> /// https://www.postgresql.org/docs/current/static/indexes-ordering.html /// </remarks> public static IReadOnlyList <NullSortOrder>?GetNullSortOrder(this IReadOnlyIndex index) => (IReadOnlyList <NullSortOrder>?)index[NpgsqlAnnotationNames.IndexNullSortOrder];
/// <summary> /// Returns the column collations to be used, or <c>null</c> if they have not been specified. /// </summary> /// <remarks> /// https://www.postgresql.org/docs/current/static/indexes-collations.html /// </remarks> #pragma warning disable 618 public static IReadOnlyList <string>?GetCollation(this IReadOnlyIndex index) => (IReadOnlyList <string>?)( index[RelationalAnnotationNames.Collation] ?? index[NpgsqlAnnotationNames.IndexCollation]);
/// <summary> /// Constructs a new index. /// </summary> public DelegatedIndex(IReadOnlyIndex index, Pipeline pipeline) { _index = index; Pipeline = pipeline; }
public static string?GetDatabaseName([NotNull] this IReadOnlyIndex index, in StoreObjectIdentifier storeObject)
/// <summary> /// Returns the column operators to be used, or <c>null</c> if they have not been specified. /// </summary> /// <remarks> /// https://www.postgresql.org/docs/current/static/indexes-opclass.html /// </remarks> public static IReadOnlyList <string>?GetOperators(this IReadOnlyIndex index) => (IReadOnlyList <string>?)index[NpgsqlAnnotationNames.IndexOperators];
bool IReadOnlyDictionary <IReadOnlyIndex, IReadOnlyNodeState> .ContainsKey(IReadOnlyIndex key) { return(ContainsKey((IFocusIndex)key)); }
public static void ReadOnlyViews() { ControllerTools.ResetExpectedName(); Main RootNode; IReadOnlyRootNodeIndex RootIndex; RootNode = CreateRoot(ValueGuid0, Imperfections.None); RootIndex = new ReadOnlyRootNodeIndex(RootNode); ReadOnlyController Controller = ReadOnlyController.Create(RootIndex); using (ReadOnlyControllerView ControllerView0 = ReadOnlyControllerView.Create(Controller)) { Assert.That(ControllerView0.Controller == Controller); Assert.That(ControllerView0.RootStateView == ControllerView0.StateViewTable[Controller.RootState]); using (ReadOnlyControllerView ControllerView1 = ReadOnlyControllerView.Create(Controller)) { Assert.That(ControllerView0.IsEqual(CompareEqual.New(), ControllerView0)); Assert.That(CompareEqual.CoverIsEqual(ControllerView0, ControllerView1)); } foreach (KeyValuePair <IReadOnlyBlockState, ReadOnlyBlockStateView> Entry in ControllerView0.BlockStateViewTable) { IReadOnlyBlockState BlockState = Entry.Key; Assert.That(BlockState != null); ReadOnlyBlockStateView BlockStateView = Entry.Value; Assert.That(BlockStateView != null); Assert.That(BlockStateView.ControllerView == ControllerView0); } foreach (KeyValuePair <IReadOnlyNodeState, IReadOnlyNodeStateView> Entry in ControllerView0.StateViewTable) { IReadOnlyNodeState State = Entry.Key; Assert.That(State != null); Assert.That(State.Comment != null); IReadOnlyNodeStateView StateView = Entry.Value; Assert.That(StateView != null); Assert.That(StateView.State == State); IReadOnlyIndex ParentIndex = State.ParentIndex; Assert.That(ParentIndex != null); Assert.That(Controller.Contains(ParentIndex)); Assert.That(StateView.ControllerView == ControllerView0); switch (StateView) { case ReadOnlyPatternStateView AsPatternStateView: Assert.That(AsPatternStateView.State == State); break; case ReadOnlySourceStateView AsSourceStateView: Assert.That(AsSourceStateView.State == State); break; case ReadOnlyPlaceholderNodeStateView AsPlaceholderNodeStateView: Assert.That(AsPlaceholderNodeStateView.State == State); break; case ReadOnlyOptionalNodeStateView AsOptionalNodeStateView: Assert.That(AsOptionalNodeStateView.State == State); break; } } } }
/// <summary> /// Returns the name of the index in the database. /// </summary> /// <param name="index">The index.</param> /// <returns>The name of the index in the database.</returns> public static string GetDatabaseName(this IReadOnlyIndex index) => (string?)index[RelationalAnnotationNames.Name] ?? index.Name ?? index.GetDefaultDatabaseName();
public static Index AsIndex([NotNull] this IReadOnlyIndex index, [NotNull][CallerMemberName] string methodName = "") => MetadataExtensions.AsConcreteMetadataType <IReadOnlyIndex, Index>(index, methodName);
/// <summary> /// Returns the default name that would be used for this index. /// </summary> /// <param name="index">The index.</param> /// <param name="storeObject">The identifier of the store object.</param> /// <returns>The default name that would be used for this index.</returns> public static string?GetDefaultDatabaseName(this IReadOnlyIndex index, in StoreObjectIdentifier storeObject)
/// <summary> /// Returns a value indicating whether the index is clustered. /// </summary> /// <param name="index"> The index. </param> /// <returns> <see langword="true" /> if the index is clustered. </returns> public static bool?IsClustered(this IReadOnlyIndex index) => index is RuntimeIndex ? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static bool AreCompatible( this IReadOnlyIndex index, IReadOnlyIndex duplicateIndex, in StoreObjectIdentifier storeObject,
/// <summary> /// Returns a value indicating whether the index is clustered. /// </summary> /// <param name="index"> The index. </param> /// <param name="storeObject"> The identifier of the store object. </param> /// <returns> <see langword="true" /> if the index is clustered. </returns> public static bool?IsClustered(this IReadOnlyIndex index, in StoreObjectIdentifier storeObject)
void IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .Add(IReadOnlyIndex key, IReadOnlyNodeState value) { Add((ILayoutIndex)key, (ILayoutNodeState)value); }
/// <inheritdoc /> protected override bool AreCompatible(IReadOnlyIndex index, IReadOnlyIndex duplicateIndex, in StoreObjectIdentifier storeObject)
bool IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .Remove(IReadOnlyIndex key) { return(Remove((ILayoutIndex)key)); }
void IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .Add(IReadOnlyIndex key, IReadOnlyNodeState value) { Add((IFrameIndex)key, (IFrameNodeState)value); }