/// <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);
        }
示例#3
0
        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));
        }
示例#4
0
        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; }
 }
示例#7
0
 public IndexRanking(IReadOnlyIndex index, AtomicQuery resolvedQuery, int ranking)
 {
     Index         = index;
     ResolvedQuery = resolvedQuery;
     Ranking       = ranking;
 }
示例#8
0
 IReadOnlyNodeState IReadOnlyDictionary <IReadOnlyIndex, IReadOnlyNodeState> .this[IReadOnlyIndex key] {
     get { return(this[(IFocusIndex)key]); }
 }
示例#9
0
 /// <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,
示例#10
0
 /// <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];
示例#11
0
 /// <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];
示例#12
0
 /// <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];
示例#13
0
 /// <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];
示例#14
0
 /// <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];
示例#15
0
        /// <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]);
示例#16
0
 /// <summary>
 /// Constructs a new index.
 /// </summary>
 public DelegatedIndex(IReadOnlyIndex index, Pipeline pipeline)
 {
     _index   = index;
     Pipeline = pipeline;
 }
示例#17
0
 public static string?GetDatabaseName([NotNull] this IReadOnlyIndex index, in StoreObjectIdentifier storeObject)
示例#18
0
 /// <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];
示例#19
0
 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();
示例#22
0
 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)
示例#24
0
 /// <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,
示例#26
0
 /// <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);
 }
示例#28
0
 /// <inheritdoc />
 protected override bool AreCompatible(IReadOnlyIndex index, IReadOnlyIndex duplicateIndex, in StoreObjectIdentifier storeObject)
 bool IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .Remove(IReadOnlyIndex key)
 {
     return(Remove((ILayoutIndex)key));
 }
示例#30
0
 void IDictionary <IReadOnlyIndex, IReadOnlyNodeState> .Add(IReadOnlyIndex key, IReadOnlyNodeState value)
 {
     Add((IFrameIndex)key, (IFrameNodeState)value);
 }